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 smartromain, 03-13-2024, 01:42 AM
    5 responses
    92 views
    0 likes
    Last Post AndreiBig  
    Started by Noerclou, Today, 04:55 AM
    0 responses
    4 views
    0 likes
    Last Post Noerclou  
    Started by llanqui, Yesterday, 09:59 AM
    2 responses
    19 views
    0 likes
    Last Post llanqui
    by llanqui
     
    Started by ThoriSten, Today, 03:56 AM
    0 responses
    6 views
    0 likes
    Last Post ThoriSten  
    Started by PhillT, 04-19-2024, 02:16 PM
    3 responses
    25 views
    0 likes
    Last Post mangel2000  
    Working...
    X