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 aussugardefender, Today, 01:07 AM
    0 responses
    3 views
    0 likes
    Last Post aussugardefender  
    Started by pvincent, 06-23-2022, 12:53 PM
    14 responses
    238 views
    0 likes
    Last Post Nyman
    by Nyman
     
    Started by TraderG23, 12-08-2023, 07:56 AM
    9 responses
    384 views
    1 like
    Last Post Gavini
    by Gavini
     
    Started by oviejo, Today, 12:28 AM
    0 responses
    4 views
    0 likes
    Last Post oviejo
    by oviejo
     
    Started by pechtri, 06-22-2023, 02:31 AM
    10 responses
    125 views
    0 likes
    Last Post Leeroy_Jenkins  
    Working...
    X