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 Trail StopLoss again

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

    ATR Trail StopLoss again

    Hi All,

    is a good way to set an ATR Trail Stop Loss this simple way (long side):

    Code:
    protected override void OnBarUpdate()
            {					
    			double distance = ATR(periodATR)[0];
    			double sl;
    			
    			sl = Close[0] - distance;
    			SetStopLoss(CalculationMode.Price, sl);
            }
    Maybe is not efficient.

    Best,
    Vince.
    Last edited by vibarco; 01-10-2013, 02:27 PM.

    #2
    Hello Vince,

    You may want to make sure that the Stop Loss price that you are setting to is a valid tick/price of the instrument by using the Round2TickSize() method. For Example:

    Code:
    double distance = Instrument.MasterInstrument.Round2TickSize(ATR(periodATR)[0]);
    Also, you will want to make sure that it is only called when you would like the Stop Loss to be moved, as it stands now everytime OnBarUpdate() will be called it will set the Stop Loss based upon the ATR would almost make it very hard to be filled as it will go down as the price goes down. You may view the following thread that will give you an example of how to modify your Stop Loss orders.




    Let us know if we can be of further assistance.
    JCNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by bmartz, 03-12-2024, 06:12 AM
    5 responses
    32 views
    0 likes
    Last Post NinjaTrader_Zachary  
    Started by Aviram Y, Today, 05:29 AM
    4 responses
    13 views
    0 likes
    Last Post Aviram Y  
    Started by algospoke, 04-17-2024, 06:40 PM
    3 responses
    28 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by gentlebenthebear, Today, 01:30 AM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by cls71, Today, 04:45 AM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Working...
    X