Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ATRTrailingStop

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

    ATRTrailingStop

    I am new to the ninjatrader. I would like to convert the below code to Ninjatrader. I tried but I am getting errors. any help is appreciated.

    #xATRTrailingStop = 0.0
    def xATRTrailingStop =compoundValue(1, if(src > nz(xATRTrailingStop[1], 0) and src[1] > nz(xATRTrailingStop[1], 0), max(nz(xATRTrailingStop[1]), src - nLoss),
    if(src < nz(xATRTrailingStop[1], 0) and src[1] < nz(xATRTrailingStop[1], 0), min(nz(xATRTrailingStop[1]), src + nLoss),
    if(src > nz(xATRTrailingStop[1], 0), src - nLoss, src + nLoss))),0);​​

    #2
    Hello sunilbpv,

    Thank you for your post and welcome to the NinjaTrader forum community!

    While we do not offer hands-on conversion services, this thread will remain open for any members of the forum community who would like to assist you with this.

    That said, through email or on the forum we are happy to answer any questions you may have about NinjaScript if you decide to code this yourself. We are also happy to assist with finding resources in our help guide as well as simple examples, and we are happy to assist with guiding you through the debugging process to assist you with understanding unexpected behavior.

    You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our NinjaTrader Ecosystem team to follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request or provide one on one educational services.​

    The following post contains plenty of helpful tips and resources for getting started with NinjaScript:We also have some helpful examples directly related to using an indicator, such as ATR, to set the stop order price. There are examples both using the Strategy Builder as well as unlocked NinjaScript and those examples are listed at the following link:Please let me know if I may be of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    648 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    369 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    109 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    573 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    575 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X