New Bug

Created at 10 Dec 2020, 18:45
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
NO

Nobody

Joined 14.01.2016

New Bug
10 Dec 2020, 18:45


i have a new bug during backtesting since today and have change nothing in my code since it appears (this morning all was fine)...

It seems that sometimes, and i don't know why, SL is not set properly and i get a crash error when i use the position.StopLoss value...

 

Here the line where i send order :


          //Send order to broker
          TradeResult result;
          result = _robot.ExecuteMarketOrder(tradetype, _robot.SymbolName, vol, _cBotLabel, Math.Round(sl_pips, 1), Math.Round(tp_pips, 1), my_comment);

          //Check response
          if (!result.IsSuccessful)
            _log.Write("!!! ALERT : Execute order refused. Error = " + result.Error + "(vol=" + vol + " SL=" + Math.Round(sl_pips, 1) + " TP=" + Math.Round(tp_pips, 1) + ")");
          else
            _log.Write("Order Executed : (vol=" + vol + " SL=" + Math.Round(sl_pips, 1) + " TP=" + Math.Round(tp_pips, 1) + ")");

 

=> i get this in the log file :

18/10/2017 14:17:00 BOT_DISRUPTION_EURUSD_Minute_Minute5  : Order Executed : (vol=18000 SL=0,3 TP=2,7)
18/10/2017 14:17:00 BOT_DISRUPTION_EURUSD_Minute_Minute5  : OnPositionOpened : UpdateOpenedPositions
18/10/2017 14:17:00 BOT_DISRUPTION_EURUSD_Minute_Minute5  : OnPositionOpened : Calculate risk_reward entryprice=1,17482 TakeProfit=1,17455 stoploss=
18/10/2017 14:17:00 BOT_DISRUPTION_EURUSD_Minute_Minute5  : RiskReward=0
18/10/2017 14:17:00 BOT_DISRUPTION_EURUSD_Minute_Minute5  : STOP LOSS NULL !
18/10/2017 14:18:00 BOT_DISRUPTION_EURUSD_Minute_Minute5  : Bot stopped

=> we can see that order is sent with a 0,3 pip value bu

 

in ctrader we can see that SL is recorded with no value (null ???) :

and in the next instruction when i use position.stoploss i get a crash (object that allow null value shoud have a value) :

 

i am sure that comes from SL and impossible to understant why it is not memorized...


@Nobody
Replies

PanagiotisCharalampous
11 Dec 2020, 08:31

Hi Nobody,

Please provide the complete cBot code and steps to reproduce the problem, like cBot parameters, backtesting dates etc.

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

Nobody
11 Dec 2020, 10:15 ( Updated at: 11 Dec 2020, 10:22 )

RE:

PanagiotisCharalampous said:

Hi Nobody,

Please provide the complete cBot code and steps to reproduce the problem, like cBot parameters, backtesting dates etc.

Best Regards,

Panagiotis 

Join us on Telegram

Hi Pangiotis,

i just found error using logger, it occurs when SL (pips) too much near prices, crash disappears when i add this condition before sending order :

         //Control SL value from actual price
          if(tradetype ==TradeType.Buy && sl_pips > 0 && ((_ms.ClosePrices.Last(0)-sl_pips) > _robot.Symbol.Bid))
          {
            _log.Write("Buy Order rejected : SL over Bid price !");
            return;
          }
          else if (tradetype ==TradeType.Sell && sl_pips > 0 && ((_ms.ClosePrices.Last(0)+sl_pips) > _robot.Symbol.Ask))
          {
            _log.Write("Sell Order rejected : SL under Ask price !");
            return;
          }
          //Send order
          TradeResult result;
          result = _robot.ExecuteMarketOrder(tradetype, _robot.SymbolName, vol, _cBotLabel, sl_pips, tp_pips, my_comment);
       

Core should reject order in this context or recording SL with some value (0 ?) that won't make program crashed ...

Regards,

Alex


@Nobody