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 NullPointStrategies, Today, 05:17 AM
    0 responses
    24 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    120 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    63 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    41 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