Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How stop orders work in backtesting

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

    How stop orders work in backtesting

    Hello,

    I am wondering how stop orders work in backtesting of my strategy.

    I have simply strategy based on insidebar. Strategy should put buy stop order when the high of insidebar is violated. SL 36 tick below entry, and Take profit 72 tick above entry.

    Sometimes prices achieve 72 points profit but earlier SL order is feeling? I dont know why because this is testing on daily datas and strategy don't know how prices where moving during session.

    This is the example on daily datas usdjpy:
    Attached Files

    #2
    Hello Danielj,

    The stop loss orders are automatically applied upon entry execution so you can see cases like this where the stop loss fill happens on the same bar as the entry. It looks at the high or low of a bar (depending on direction) to determine if stop loss should fill.

    To resolve this you should move away from set statements and use ExitLongStop() or ExitShortStop(). You can also see this reference sample for help achieving intrabar granularity.

    Backtesting NinjaScript Strategies with an intrabar granularity
    Ryan M.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    648 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    369 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    108 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    572 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    574 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X