Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Good till cancel stop order

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

    Good till cancel stop order

    Good afternoon,

    I am trying to figure out how to keep a stop order active until I set parameters to cancel it.

    Currently have:

    protected override void OnBarUpdate()
    {
    if (BarsInProgress!= 0)
    return;

    if (CurrentBars[0] < 1)
    return;

    // Set 1
    if (Open[0] > (Close[1] * 1.0025))

    {

    openBarHigh = High[0];
    EnterLongStopLimit(Convert.ToInt32(DefaultQuantity ), openBarHigh + (10 + TickSize), (openBarHigh + (1 * TickSize)) , "R");

    }


    This seems to work fine so long as the stop order is triggered on the next candle.
    Why doesn't the variable openBarHigh not store the value and keep the stop order open indefinitely? The direction I am going is to cancel the stop order if price trades below openBarHigh Low and keep the order open until end of day.

    Any help would be greatly appreciated.
    Thank you.

    #2
    Hello Tonkingrf1551,

    From the given code I can't tell where openBarHigh is defined and used to say why it may not be holding the value. As long as that is a user variable or class level variable that would retain a value until the next time you had set it.

    I would suggest to take a look at the following strategy builder example, you can unlock it if you are manually coding as well. This shows how to use a variable for the price and another variable to determine a "state" which drives the logic. That second variable controls which set is currently working and holds the order open.

    Comment


      #3
      Thank you Jesse I will look into that and let you know if I have any questions. Thanks

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      80 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      40 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      64 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      66 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      54 views
      0 likes
      Last Post CarlTrading  
      Working...
      X