Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Auto Breakeven script

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

    Auto Breakeven script

    Hi,

    A newbie question: how do I programmatically implement Auto Breakeven?

    All the threads I found are either very old (2008-ish), or contain Wizard Scripts (without meaningful variable names and such) or subsequent changes are required. Also, they mention race conditions involving MarketPosition.Flat

    Is there a readily available script that I can just borrow? Something that closely mimics the Stop Strategy dialog, with inputs called "profit trigger" and "plus"?

    I understand it's very simple, but this is my first experience with Ninja Script and I've got to provide estimate for this and other functionality ASAP. And it just seems logical that programmers should have an easy access to all the features available via GUI.

    Thank you

    #2
    Hello asdfadf,

    Thank you for your inquiry.

    You would be able to implement an auto breakeven in this way. This example will set your stop loss to breakeven once you reach 50 ticks in profit:

    Code:
    [FONT="Courier New"]if (Close[0] > Position.AvgPrice + 50 * TickSize)
    {
    SetStopLoss (CalculationMode.Price, Position.AvgPrice);
    }[/FONT]
    Our forum has an extremely helpful references sample section for both strategies and indicators: http://www.ninjatrader.com/support/f...splay.php?f=30

    The code I've mentioned above is a snippet from the code in the "Strategy: Modifying the price of stop loss and profit target orders" post.

    The NinjaTrader help guide also has a very handy alphabetical reference for NinjaScript as well: http://www.ninjatrader.com/support/h..._reference.htm

    Please, let us know if we may be of further assistance, and enjoy diving into NinjaScript!
    Zachary G.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

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