You probably would like to remove/move the "}" after the OP_BUY if because it closes the for statement before checking for OP_SELL.
for(cnt=0;cnt<total;cnt++) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); double price; if (OrderType()==OP_BUY) price = MarketInfo(OrderSymbol(), MODE_BID); } // ----> this one closes the for cnt statement
thank you
Automated
--
real time grid trading video, +531 pips in 24 hours:
http://www.gridtradingcourse.com/videos/news_grid_trading_chfjpy_3/Grid_Trading_CHFJPY.html
http://grid9.forexmosaic.com/ - 8621 pips in 7 weeks of grid trading
keylove:
i discovered that it closes at minus without the profit realised.
- Related thread -> https://www.mql5.com/en/forum/125528.
- Your should loop down and not up in your order closing loop (see here -> https://www.mql5.com/en/forum/119840).
One more thing:


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
i want my ea to be closing all the trade s when the equity is greater than accountbalance, but all my efforts are in vain. this how i used ;
int start()
if(AccountEquity()-AccountBalance()>=my_profit*my_lot)closenow=true;
if(closenow==true)
{
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
double price;
if (OrderType()==OP_BUY)
price = MarketInfo(OrderSymbol(), MODE_BID);
}
if (OrderType()==OP_SELL)
price = MarketInfo(OrderSymbol(), MODE_ASK);
{
OrderClose(OrderTicket(), OrderLots(), price, Slippage,Violet);
Print("??????? ???????", OrderTicket());
}
}
}
return(0);
i discovered that it closes at minus without the profit realised.
please help