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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    90 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    137 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    120 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    72 views
    0 likes
    Last Post PaulMohn  
    Working...
    X