Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Set SL/TP based on ATR in Strategy Builder (no-coding)

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

    Set SL/TP based on ATR in Strategy Builder (no-coding)

    Hi,
    I have created a strategy that enters the market based on MACD cross signal if the price is above/below a few moving averages.
    Now, for the SL/TP I would like to use ATR value (1.5 ATR for the stoploss and 3 ATR for the profit target).

    For example, my '1 Set' is the conditions to enter SHORT,
    Then in 'Do the following' I have 'Enter Short' and for the SL/TP
    I have created variables: 'StopLossPrice' and 'TakeProfitPrice', where I am setting the SL/TP prices with the relevant offset from the last 'Close price' based on the ATR.

    Then in '2 Set' conditions if 'current market position is short',
    Do the following 'Exit short stop market' = 'StopLossPrice' from above and
    'Exit short limit' = 'TakeProfitPrice' also from above.

    Then when I am testing it, it looks not accurate. What am I doing wrong?

    Thanks, Ilya.

    #2
    Hi Ilya, thanks for writing in. The ATR has very small values relative to most futures instruments. E.g. it would not work to set a stop and target for say 5.75 ATR on the ES which is around 4000 dollars at the moment. You would need to add/subtract the ATR value from the price of the ES but its not possible to do arithmetic in the builder, your script would need to be unlocked to do this e.g. ExitLongStopMarket(Close[0]-ATR(14)[0]);

    Kind regards,
    -ChrisL

    Chris L.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by AaronKoRn, Yesterday, 09:49 PM
    0 responses
    11 views
    0 likes
    Last Post AaronKoRn  
    Started by carnitron, Yesterday, 08:42 PM
    0 responses
    10 views
    0 likes
    Last Post carnitron  
    Started by strategist007, Yesterday, 07:51 PM
    0 responses
    11 views
    0 likes
    Last Post strategist007  
    Started by StockTrader88, 03-06-2021, 08:58 AM
    44 responses
    3,981 views
    3 likes
    Last Post jhudas88  
    Started by rbeckmann05, Yesterday, 06:48 PM
    0 responses
    9 views
    0 likes
    Last Post rbeckmann05  
    Working...
    X