Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Static Stop & Limit Exit Orders

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

    Static Stop & Limit Exit Orders

    I am making a change to my Breakout strategy that I have written.

    Currently it says, "Determine the high and the low between 2:00 AM & 9:00 AM CET. If, after 9:00 AM the price breaks above that range, buy, if it breaks below that range then sell. Exit at a profit if the price continues an equal distance of that range. Exit at a loss if the price reverses to the other side of the range."

    An executed trade can be in play for several days.

    I have created a couple of workarounds in order to deal with the order handling rules but I am finding that there still needs to be a bit more improvement. So here it what I have in mind and need your help in figuring out how to adjust the way that my Exit Stop & Exit Limit orders are handled.

    Currently the IOrder name for a trade that goes Long is "BreakoutLong". I would like to now have multiple iOrders and call them BreakoutLong1, BreakoutLong2, BreakoutLong3, etc.

    Then my code would look something like this:
    Code:
    if (BreakoutLong1  == null
        && "other criteria - including the day's range")
            {
              EnterLongStop("BreakoutLong1");
              ExitLongStop("BreakoutLong1");
              ExitLongLimit("BreakoutLong1");
             }
    
    else if (BreakoutLong1 != null
         && BreakoutLong2 == null
         && "other criteria - including the day's range")
           {
              EnterLongStop("BreakoutLong2");
              ExitLongStop("BreakoutLong2");
              ExitLongLimit("BreakoutLong2");
           }
    
    else if (BreakoutLong1 != null
         && BreakoutLong2 != null
         && BreakoutLong3 == null
         && "other criteria - including the day's range")
           {
              etc etc etc
           }
    I think you may get the point of what I am trying to accomplish there

    Now to the point of the question, which deals with the Stop & the Limit orders. They are calculated from the range that is mentioned earlier and they are calculated from the range that is associated with the DAY that the order was executed.

    Naturally, every single day there will be a new range that is formed so I need to know how to insure that the Stop & the Limit orders will remain the same despite the range changing as new days come and go. The Stop & Limit orders of each separate category (Breakout1, Breakout2, Breakout3) must remain the same until one of them is hit and then the other is cancelled automatically.

    Thank you for your help and let me know if you need any additional information or clarification.

    #2
    Hi jg123,

    Two things,

    One, you will need to either cancel the opposing stop or target type order when the other is cancelled by using OnExecution and detecting the order then call CancelOrder.
    Or you can use the unmanaged approach and use OCO.

    Two, the orders you submit will place until the session ends if the order is a Day order, or when you cancel it if the order is a Gtc order.

    In other words, if you are placing Gtc orders and you don't want the order moved, don't move it.

    Other than that the logic will be all up to you and what you want to do.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by DawnTreader, Yesterday, 05:58 PM
    2 responses
    13 views
    0 likes
    Last Post DawnTreader  
    Started by quicksandatl, Today, 11:11 AM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by OllieFeraher, Today, 11:14 AM
    1 response
    2 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by aman jain, 10-01-2020, 09:25 PM
    3 responses
    293 views
    0 likes
    Last Post Legiboka  
    Started by reynoldsn, Today, 07:23 AM
    5 responses
    12 views
    1 like
    Last Post NinjaTrader_Gaby  
    Working...
    X