you need to add code that compares the current Bid or Ask (depending on whether you are opening buy or sell orders) with the open price of the last trade
if(OrderCount=3)
{
return(0);
}
int OpenOrders=OrdersTotal();
OrderSelect(OpenOrders-1,SELECT_BY_POS);
Oprice=OpenOrderPrice();
if(Bid-Oprice>30)
{
OrderSend(BUY.....);
OrderCount=OrderCount+1
}
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Need some help with managing the tickets...
Currently the code is buying and selling but how can I manage the open tickets so that, for example, if it places a buy and the price goes up 30 pips it will place another buy for? and repeat that again for a total of 3 "buy" orders?
int cnt, ticket, total;
total = OrdersTotal();
if(total < 1)
{
if(cnt_buy ==2)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());
return(0);
}
if(cnt_sell == 2)
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*Point);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());
}
else Print("Error opening SELL order : ",GetLastError());
return(0);
}
}
//----MANAGING THE TICKETS ---
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if()
{
}
}