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 sjsj2732, Yesterday, 04:31 AM
      0 responses
      39 views
      0 likes
      Last Post sjsj2732  
      Started by NullPointStrategies, 03-13-2026, 05:17 AM
      0 responses
      290 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      289 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      135 views
      1 like
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      96 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Working...
      X