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 Syntax please?

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

    Trailing Stop Syntax please?

    Please help. I am not experienced at writing code so be gentle with me.

    I would like to add a trailing stop to a strategy that I put together in the Strategy Wizard. I have attempted to add in the Wizard screen where Profit Targets and Stop Losses are added, but this did not test well so I have not used it. Simply put, I would like to have the strategy pull in my stop after achieving a specified profit target, then move the stop after some specified ticks. This is a pretty standard use of trailing stop so it must be pretty straight forward.

    I have searched the forums here (and elsewhere) but only find indicators or strategies that are not very helpful. Perhaps it is my ignorance but they seem to be missing the details about how to execute the test and perform functions. If there is something that I am missing in the NT tutorials, please illustrate this to me and I will migrate there.

    Thanks!

    Best regards,

    Dolfan (tired of leaving $C$ notes on the floor)

    PS. Specifically looking for syntax that I can input the stops in $$ or ticks and a trailing stop function where I can edit the initial target and specify the number of ticks to pull in and drag behind the price action,
    Last edited by Dolfan; 12-17-2015, 05:55 PM.

    #2
    Hello Dolfan,

    Thanks for your post.

    The strategy wizard uses the NinjaTrader SetTrailStop() method. The method will start at whatever tick or percent offset you specify and then as price moves in your favor will autonomously move the trailing stop up on a tick by tick basis. This is how the standard trailing stop functions. If you haven't tried the standard I would encourage you to do so.

    What you are looking for is a conditional trailing stop based on some logic you will need to provide. It can be done in the strategy wizard but will take some effort to implement. To give you some idea of this I have added a breakeven strategy wizard example (courtesy of NinjaTrader_Chelsea). You can test this and observe how it functions and how it is built. Basically it will enter a long order (only long in the example), set the breakeven trigger based on the average entry price plus a user set amount, sets an initial stop value, then tests to see if price is >= the breakeven trigger price and if so moves the stop to that point. With the example provided you could build on this to then trail the stop up according to your logic.

    So while it could be done in the wizard I think you will find that the wizard may be limiting in this area of a conditional trailing stop.

    If you decide to transition to coding the strategy directly in Ninjascript, here are a few links to get you started learning how to create a ninjascript strategy: Tutorial examples: http://ninjatrader.com/support/helpG...y_via_self.htm
    Attached Files
    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Nicholewatkinsi, Yesterday, 10:53 PM
    0 responses
    6 views
    0 likes
    Last Post Nicholewatkinsi  
    Started by dward123, 01-02-2024, 09:59 PM
    4 responses
    176 views
    0 likes
    Last Post Lancer
    by Lancer
     
    Started by ETFVoyageur, Yesterday, 04:00 PM
    2 responses
    19 views
    0 likes
    Last Post ETFVoyageur  
    Started by AaronKTradingForum, Yesterday, 03:44 PM
    1 response
    14 views
    0 likes
    Last Post AaronKTradingForum  
    Started by Felix Reichert, 04-26-2024, 02:12 PM
    11 responses
    80 views
    0 likes
    Last Post Felix Reichert  
    Working...
    X