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 Mindset, 04-21-2026, 06:46 AM
      0 responses
      88 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      134 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      119 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      69 views
      0 likes
      Last Post PaulMohn  
      Working...
      X