Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to set trail stop

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

    How to set trail stop

    I am new to ninja script and trying to create a bot based on my strategies.
    So far I managed to do:
    * EnterLong position based on my indicators.
    * EnterShort position based on my indicators.
    and what I missing is SetTrailStop, I want when Im in position (Long, Short) the initial stopLoss will be on 60 ticks and on every 40 ticks that he gain to forward the stopLoss with 20 ticks.
    any help of how can I do it?

    #2
    Hello DanielRaz,

    To do this kind of task you would have to use a regular stoploss and then add logic which makes it trail at a frequency. The SetStopLoss method is updated based on the OnBarUpdate events and the offset is based on the average entry price. To do break-even or fixed amount of price movements like an ATM would require logic instead.

    There is a trailing stop sample in the following link which outlines how to update a target at a fixed amount of profit only. That would be the same general concept you would need to use to place an initial stop and then update it based on profit rather than the OnBarUpdate events.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    43 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    20 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    30 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    48 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    38 views
    0 likes
    Last Post CarlTrading  
    Working...
    X