Announcement

Collapse
No announcement yet.

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

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    633 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    364 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    105 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    567 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    568 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X