Hi everyone, I encountered error code 138 when backtesting. I've looked on the internet that RefreshRates() can fix this. However after using it the problem still exist. Here's my code:
after looking into backtest journal I found that some of the order (image attached) closed but instead of closing it still modify the stoploss of the trade, I think the order isn't really closed. Does anyone knows why error 138 still occur even after using RefreshRates()?
//+----------------------------------------------------------for SELL order-------------------------------------------------------------+ if(OrderSymbol() == Symbol() && OrderType()==OP_SELL) { //+--------------------------------------------------------Closing Order-------------------------------------------------------------+ if(CheckClosePosition(1)==2) { RefreshRates(); bool resCO = OrderClose(ticket,lots,Bid,slippage); Print("Sell order #",OrderTicket(), " closed"); if(!resCO) { Print("Error in Closing Order. Error code=",GetLastError()); return; } else Print("Closing Order successfully for ticket: ", OrderTicket()); }
You can't Close Sell Orders on the Bid Price.
Hi everyone, I encountered error code 138 when backtesting. I've looked on the internet that RtefreshRates() can fix this. However after using it the problem still exist. Here's my code:
after looking into backtest journal I found that some of the order (image attached) closed but instead of closing it still modify the stoploss of the trade, I think the order isn't really closed. Does anyone knows why error 138 still occur even after using RefreshRates()?
You select by ticket but do not verify that the order is still open.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi everyone, I encountered error code 138 when backtesting. I've looked on the internet that RefreshRates() can fix this. However after using it the problem still exist. Here's my code:
after looking into backtest journal I found that some of the order (image attached) closed but instead of closing it still modify the stoploss of the trade, I think the order isn't really closed. Does anyone knows why error 138 still occur even after using RefreshRates()?