Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

AutoBreakeven Strategy Builder

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

    AutoBreakeven Strategy Builder

    Hello, I am stumped on trying to implement a breakeven stop in my strategy. I have reviewed the examples provided and I am not able to get it working. I have created a variable MoveToBE as a double. I then went to conditions and actions and set it so that if I am in a position long and that position is 5 ticks above my average price, set a stop order at the average position price. I am not sure where I made the mistake and hopefully someone will be able to point it out. Thank you in advance.

    Code is below:

    // Set 2
    if ((Position.MarketPosition == MarketPosition.Long)
    && (Close[0] >= (Position.AveragePrice + (5 * TickSize)) ))
    {
    MoveToBE = Position.AveragePrice;
    ExitLongStopMarket(Convert.ToInt32(DefaultQuantity ), MoveToBE, "", "")​


    Edit: Figured it out. Stops and Targets tab can not have anything in them in order for the breakeven condition to work. My apologies for the post.
    Last edited by jordanq2; 08-22-2023, 03:39 PM.

    #2
    Hello jordanq2,

    Below are links to examples in the Strategy Builder and in an unlocked script I think you will find very helpful.
    https://ninjatrader.com/support/foru...596#post806596
    https://ninjatrader.com/support/foru...269#post802269

    Use prints to understand the behavior in your script.

    Enable TraceOrders, print the time of the bar and all values in the condition set. Include labels for every value and comparison operator.

    Below is a link to a forum post on using Print() to understand behavior and includes a link to a video of 'Debugging using prints with the Strategy Builder'.
    https://ninjatrader.com/support/foru...121#post791121


    "Stops and Targets tab can not have anything in them in order for the breakeven condition to work."

    Yes, this would be correct and would be shown in the TraceOrders output.

    This would violate the internal order handling rules.

    From the help guide:
    "Methods that generate orders to exit a position will be ignored if::
    A position is open and an order submitted by a set method (SetStopLoss() for example) is active"
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    87 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    132 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    65 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    118 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    67 views
    0 likes
    Last Post PaulMohn  
    Working...
    X