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

Trailing Stop based off an indicator line

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

    Trailing Stop based off an indicator line

    I'd like my strategy to have a trailing stop based on a user defined amount from a particular EMA indicator line.
    I've got 3 indicator lines in the strategy defined as EMA1, EMA2 and EMA3

    Engage once I've gained X ticks past BreakEven, then I'd like to trail as Y ticks away from EMA3.

    I'm not sure how to point the trailing stop to tie itself to EMA3 instead of doing what it does now which trails the closest EMA line to the entry price.

    Any tips on how to tie the Trailing Stop to a particular EMA line (i.e. EMA3) no matter if it is short or long?

    I looked here and could not see my answer: https://ninjatrader.com/support/help...ttrailstop.htm

    #2
    Hello RonnieB, thanks for your post.

    You can call SetStopLoss within OnBarUpdate to dynamically change your stop. Set Calculation mode to CalculationMode.Price and then pass in the EMA value for the current bar, so that would be something like:

    SetStopLoss(CalculationMode.Price, EMA3[0]);

    One thing to note will be if you are long or short. If you are long you would want to make sure you are placing the sell stop below the market price and opposite that for short positions.

    Please let me know if I can assist any further with this.
    Chris L.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by benmarkal, Yesterday, 12:52 PM
    3 responses
    22 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by helpwanted, Today, 03:06 AM
    1 response
    17 views
    0 likes
    Last Post sarafuenonly123  
    Started by Brevo, Today, 01:45 AM
    0 responses
    11 views
    0 likes
    Last Post Brevo
    by Brevo
     
    Started by aussugardefender, Today, 01:07 AM
    0 responses
    6 views
    0 likes
    Last Post aussugardefender  
    Started by pvincent, 06-23-2022, 12:53 PM
    14 responses
    244 views
    0 likes
    Last Post Nyman
    by Nyman
     
    Working...
    X