Bot giving error when trying to put Position in Break Even

Created at 25 May 2020, 17:40
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!
GI

giogferrarizze

Joined 25.05.2020

Bot giving error when trying to put Position in Break Even
25 May 2020, 17:40


Hey guys, how are u doing?

Im building a bot based on a strategy im studying and everythin was going fine until i fixed some order opening requirements.

My bot opens the order and after it profits an specific value the bot changes the stoploss to break even, and then starts to change to take profit.

But after the 3rd position the bot starts to give-me StopLossTakeProfit error i dont know why since the first 3 orders it worked well.

 

Thats the if where the error comes from:

if (botPosition.StopLoss.Value > botPosition.EntryPrice && lastClosePips > canalPips && tendencia == trend.Baixa && botPosition.TradeType.Equals(TradeType.Sell) && !breakEven)
            {
                newStopLoss = botPosition.EntryPrice - Symbol.PipSize * 1;
                TradeResult tradeResult = ModifyPosition(botPosition, newStopLoss, 0);
                Print(newStopLoss);
                if (tradeResult.IsSuccessful)
                {
                    Print("Sell stop loss to break even on: " + SymbolName + " - " + botPosition.Label);
                }
                else
                {
                    Print("Sell stop loss to break even on: " + SymbolName + " - " + botPosition.Label + " - ERROR - " + tradeResult.Error.Value);

                }
                breakEven = true;
            }

 

 

And the logs:

 

Thanks in advance


@giogferrarizze
Replies

PanagiotisCharalampous
26 May 2020, 08:05

Hi giogferrarizze,

In order for somebody to help you, you need to provide the following.

1. The complete cBot code

2. cBot parameters and backtesting settings and dates that will allow us to reproduce this problem

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous

giogferrarizze
27 May 2020, 21:17

RE:

PanagiotisCharalampous said:

Hi giogferrarizze,

In order for somebody to help you, you need to provide the following.

1. The complete cBot code

2. cBot parameters and backtesting settings and dates that will allow us to reproduce this problem

Best Regards,

Panagiotis 

Join us on Telegram

 

Thank you for your response, thankfully i already figured it out!


@giogferrarizze