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 NullPointStrategies, 03-13-2026, 05:17 AM
      0 responses
      87 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      151 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      80 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      53 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      62 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X