Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Move to Breakeven with SetStopLoss in Strategy

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Move to Breakeven with SetStopLoss in Strategy

    Hi,

    I am developing a strategy that moves Stop Loss to Breakeven after price moves certain amount of ticks but I have run into an issue when backtesting. During backtesting there is a situation when price moves sharply within the single bar and in that case stop loss is moved to breakeven which is fine. Problem is that stop loss is now higher than bar's low and it gets executed at the bar close although the current price is well above stop loss.

    I'm using Calculate.OnEachTick.
    Primary data series is 1 minute data on ES futures
    I have added secondary data series (1 tick data) and I'm submitting orders to that data series in backtesting (as described in sample SampleIntrabarBacktest).

    I have 2 questions:
    1. is this normal behaviour or it is a bug?
    2. can I work around this issue by using unmanaged approach (since I'm using Rithmic)?

    Thank you,
    FalcoTrader



    Click image for larger version

Name:	image.png
Views:	302
Size:	10.8 KB
ID:	1273581

    #2
    Hello alausic,

    Thank you for your post.

    A strategy running real-time will produce different results than the performance results generated during a backtest.

    In backtest, Calculate is always OnBarClose unless TickReplay is enabled. Set methods cannot use TickReplay for intra-bar fills, so it is necessary to use ExitLongStopMarket submitted from OnExecutionUpdate when the entry fills, with isLiveUntilCancelled as true, and using the barsInProgress index of an added 1 tick series (intrabar granularity).

    Calculate - https://ninjatrader.com/support/help.../calculate.htm
    ExitLongStopMarket - https://ninjatrader.com/support/help...stopmarket.htm

    Please read the forum post below for more details and instructions on how to implement intrabar granularity:
    https://forum.ninjatrader.com/forum/...ive#post773377

    If you have any other questions, please let us know.

    Comment


      #3
      Hello Gaby,

      thank you for your explanation. I missed that piece of information that Set functions cannot use TickRepay. It is really pity.

      Anyway, that means I must rewrite strategy and I'm probably going to switch to unmanaged approach.

      Regards

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      43 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      20 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      30 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      47 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      38 views
      0 likes
      Last Post CarlTrading  
      Working...
      X