Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Dynamic ATR SetStopLoss - Price absolute vs offset?

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

    Dynamic ATR SetStopLoss - Price absolute vs offset?

    I'm using a dynamic ATR SetStopLoss in OnBarUpdate() section .. To activate the Stop as soon as position is entered (not wait for next bar), I added it in the Entry Condition below.

    1) My ExitLongLimit orders are not being triggered at all, even when the position is alive for several 100 bars and StopLoss isn't active. When i comment out the SetStopLoss, the ExitLongLimit works fine. Is there some issue with my SetStopLoss code?

    2) How do i change the SL price depending on # of Bars of position? I want to say
    if (Position.Bars ==0) SetStopLoss(entryPrice - 2*SlAtr*ATR(10)[0]);
    else SetStopLoss(entryPrice - SlAtr*ATR(10)[0])
    Note - since my SetStopLoss is in Entry condition, no Position object formed yet, so i can't check for the position bars.


    if (MACD(Close, MacdPer, MacdPer*2, 9).Diff[0] > MACD(MacdPer, MacdPer*2, 9).Diff[1])
    {
    double entryPrice = Close[0]-entryTicks*TickSize;
    EnterLongLimit(DefaultQuantity, entryPrice, "Enter-Lim");
    SetStopLoss("", CalculationMode.Price, entryPrice-SlAtr*ATR(10)[0], true); //
    }

    // Condition set 2
    if (MACD(Close, MacdPer, MacdPer*2, 9).Diff[0] < MACD(MacdPer, MacdPer*2, 9).Diff[1])
    {
    ExitLongLimit(Close[0] + exitTicks* TickSize, "Exit-lim", "");

    }
    Last edited by kbellare; 08-28-2015, 05:20 PM. Reason: nature of problem changed as i tested this out ..

    #2
    Originally posted by kbellare View Post
    I'm using a dynamic ATR SetStopLoss in OnBarUpdate() section .. To activate the Stop as soon as position is entered (not wait for next bar), I added it in the Entry Condition below.

    1) My ExitLongLimit orders are not being triggered at all, even when the position is alive for several 100 bars and StopLoss isn't active. When i comment out the SetStopLoss, the ExitLongLimit works fine. Is there some issue with my SetStopLoss code?

    2) How do i change the SL price depending on # of Bars of position? I want to say
    if (Position.Bars ==0) SetStopLoss(entryPrice - 2*SlAtr*ATR(10)[0]);
    else SetStopLoss(entryPrice - SlAtr*ATR(10)[0])
    Note - since my SetStopLoss is in Entry condition, no Position object formed yet, so i can't check for the position bars.


    if (MACD(Close, MacdPer, MacdPer*2, 9).Diff[0] > MACD(MacdPer, MacdPer*2, 9).Diff[1])
    {
    double entryPrice = Close[0]-entryTicks*TickSize;
    EnterLongLimit(DefaultQuantity, entryPrice, "Enter-Lim");
    SetStopLoss("", CalculationMode.Price, entryPrice-SlAtr*ATR(10)[0], true); //
    }

    // Condition set 2
    if (MACD(Close, MacdPer, MacdPer*2, 9).Diff[0] < MACD(MacdPer, MacdPer*2, 9).Diff[1])
    {
    ExitLongLimit(Close[0] + exitTicks* TickSize, "Exit-lim", "");

    }
    Documented in the NT Help here: http://ninjatrader.com/support/helpG...d_approach.htm

    Look at the last item on the page.

    Comment


      #3
      Hello kbellare,

      Thank you for your post.

      1. Koganam linked you over to the Internal Order Handling Rules that would dictate that the SetStopLoss or Exit method would ignore the other. Only one will work at the same time, not both.

      2. Use BarsSinceEntry: http://ninjatrader.com/support/helpG...sinceentry.htm

      I would also recommend reviewing the sample at the following link: http://ninjatrader.com/support/forum...ead.php?t=3222

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      558 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      324 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      545 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      547 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X