Extreme stop loss values

Created at 04 Mar 2024, 14:37
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!
FL

flappiyt

Joined 04.03.2024

Extreme stop loss values
04 Mar 2024, 14:37


I have a problem with my cBot. It incorrectly calculates stop loss levels; when the stop loss should be 10$ below the current price, it ends up being 16000$ below (depending on the instrument).

This is how my bot is calculating stop loss:

        [Parameter("Spread", DefaultValue = 10)] -------- it is used to add a value of spreed to stop loss
        public double SL { get; set; } 

        protected override void OnBarClosed()

       {

        Case1:  SL=MarketSeries.Low[index] - (Symbol.PipSize * SL);

       Case2:  SL=MarketSeries.Open[index] - (Symbol.PipSize * SL);

       Case3:  SL = MarketSeries.Low[index] + (Symbol.PipSize * SL); --------These are the only lines in code to calculate stop loss lvl 

       Case4: SL = MarketSeries.Close[index] - (Symbol.PipSize * 10);

      ExecuteMarketOrder(TradeType.Buy, Symbol, InitialVolume, "Frann", SL, TP); — entering trade

       }

      

                                


@flappiyt
Replies

PanagiotisCharalampous
05 Mar 2024, 06:46

Hi there,

SL and TP should be set in pips. You seem to pass absolute prices instead.

Best regards,

Panagiotis


@PanagiotisCharalampous