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 NullPointStrategies, Today, 05:17 AM
    0 responses
    44 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    124 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    65 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    42 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    46 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X