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

ATR Stoploss

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

    ATR Stoploss

    I'm trying to use the strategy wizard to set a stoploss 2 times the ATR and it doesnt seem to be working right. Hopefully you can tell me where I am going wrong.

    In the Conditions and Actions box...
    In the "Do the Following Section"
    I have...
    Variable0=(ATR(20)(0))*(1+200)


    That breaks down to mean a 20 period ATR for the current bar with a "percent" offset of 200. I'm setting a variable here so I can set that variable as my stop loss amount in the StopLoss section of the strategy wizard.


    In the "Stop Loss and Profit Targets" section I have
    SetStopLoss("LongEntry",CalculationMode. Ticks, Variable0, false)

    That means set a stop loss for the entry signal called "LongEntry". Set it Varible0 ticks away from the entry (Not simulated)

    It seems like it sets my stoploss to my entry amount, so I did something wrong with the ATR part.

    WHat do you think?

    #2
    Your percent offset is probably wrong. To be twice the ATR you would just multiply the ATR by 2 not 201.

    See if that helps.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Am I going about it the right way though? Should I be using offset?

      Is there a way to just multiply using the strategy wizard?

      Comment


        #4
        You are approaching it properly. Try this: Offset by 1 (for 100%) so your code looks like this

        Variable0 = (ATR(20)[0]) * (1 + 1)

        Now bear in mind ATR values are generally already in decimals so when you go try to pass it into the SetStopLoss() as ticks its not going to work out too well. For equities like AAPL, 1 tick would be 1 cent. You can't really say I want a stop loss at 0.6 tick.

        I think you are trying to get $0.60 as your stop loss. To do this you would unfortunately need to break away from the Wizard and do some manual edits on the code.

        Variable0 = ((ATR(20)[0]) * (1 + 1)) / TickSize;
        SetStopLoss("LongEntry",CalculationMode.Ticks, Variable0, false);
        Josh P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by f.saeidi, Yesterday, 08:12 AM
        3 responses
        24 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by algospoke, Yesterday, 06:40 PM
        1 response
        14 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by quantismo, Yesterday, 05:13 PM
        1 response
        13 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by The_Sec, 04-16-2024, 02:29 PM
        3 responses
        16 views
        0 likes
        Last Post NinjaTrader_ChristopherS  
        Started by hurleydood, 09-12-2019, 10:45 AM
        15 responses
        1,099 views
        0 likes
        Last Post Leeroy_Jenkins  
        Working...
        X