Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SetStopLoss not triggering in Market Replay

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

    SetStopLoss not triggering in Market Replay

    I have searched the forum and the manual for days and I couldn't find a solution to my ongoing problem. SetStopLoss is not triggerring.Other people have mentioned similar problems.

    Q1.I use SetStopLoss("trade1", CalculationMode.Price, Position.AvgPrice + (T1*TickSize) , false);
    Should I use "true" instead of false for market replay and hist. backtesting ? I run it w.

    CalculateOnBarClose = false;
    EntryHandling = EntryHandling.UniqueEntries;

    Here is the code for Long:

    if (Position.MarketPosition == MarketPosition.Long)
    {
    if(Close[0] <= (Support().S1[0] - 3*TickSize) && (BarsSinceEntry() >= 2 ) )
    {
    SetStopLoss("trade1", CalculationMode.Price, GetCurrentBid(), false );
    SetStopLoss("trade2", CalculationMode.Price, GetCurrentBid(), false );
    SetStopLoss("trade3", CalculationMode.Price, GetCurrentBid(), false );
    }

    if (High[0] > Position.AvgPrice + (T1*TickSize) )
    SetStopLoss("trade1", CalculationMode.Price, Position.AvgPrice + TickSize , false);

    if (High[0] > Position.AvgPrice + (T1*TickSize) )
    SetStopLoss("trade2", CalculationMode.Price, Position.AvgPrice + TickSize , false);

    if (High[0] > Position.AvgPrice + (T1*TickSize) )
    SetStopLoss("trade3", CalculationMode.Price, Position.AvgPrice + TickSize , false);
    }

    Q2: The strategy uses the same names for going short.Is it ok ? It is either long or short, not both direction at the same time.

    Q3: After the targets for trade 1 and 2 are hit, it doesn't go to breakeven (but it should), but keeps the original stoploss which is entered when initiating all 3 trades at the same time.

    Q4: I use SetStopLoss more than once here for the same trade. Is it a problem ?

    Q5: Maybe there are well explained strategy templates for using stoplosses and trailing stops without any bugs which actually work. If not, it would be really great, if someone made some. Detailed video tutorials with coding examples for stoplosses,trailing stops and targets would be greatly appeciated by many others, not just me. Coding and using stoplosses, trailing stops and profit targets should be intuitive and easy to use.

    Thank you for your answers. monnn

    #2
    Q1.I use SetStopLoss('trade1', CalculationMode.Price, Position.AvgPrice + (T1*TickSize) , false); Should I use 'true' instead of false for market replay and hist. backtesting ? I run it w.
    True/false only matters as to how you want the order submitted. Do you want NinjaTrader to monitor and submit stop loss orders, or do you want an order to exist on the broker's servers?

    Q2: The strategy uses the same names for going short.Is it ok ? It is either long or short, not both direction at the same time.
    I would suggest using different names for going long/short as it helps separate your logic and the stop-losses / take-profits tied to them.

    Q3: After the targets for trade 1 and 2 are hit, it doesn't go to breakeven (but it should), but keeps the original stoploss which is entered when initiating all 3 trades at the same time.
    Unfortunately I don't have enough information as to why this would occur, please either post your strategy or clarify and I would be happy to comment further.

    Q4: I use SetStopLoss more than once here for the same trade. Is it a problem ?
    Not really, it just means that your stop loss is being reset.

    Q5: Maybe there are well explained strategy templates for using stoplosses and trailing stops without any bugs which actually work. If not, it would be really great, if someone made some. Detailed video tutorials with coding examples for stoplosses,trailing stops and targets would be greatly appeciated by many others, not just me. Coding and using stoplosses, trailing stops and profit targets should be intuitive and easy to use.
    We are working on adding some coding tutorials. However, currently your best bet is to use our reference samples : http://www.ninjatrader.com/support/f...splay.php?f=30

    There are several there dealing with stop loss management.
    Adam P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    647 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
    573 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X