Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Setting IOrder Variable to NULL

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

    Setting IOrder Variable to NULL

    In the documentation found at:



    the IOrder variable is set to null after the order is filled. Can you tell me why? When and where is it necessary to set the IOrder variable to null?

    #2
    Hello,

    This is because the logic in OnBarUpdate is using this.

    If we look at the example:

    Code:
    private IOrder entryOrder = null;
    protected override void [B]OnBarUpdate[/B]()
    {
        [B]if (entryOrder == null [/B]&& Close[0] > Open[0])
             entryOrder = [B]EnterLong[/B]();
    }
     
    protected override void OnOrderUpdate(IOrder order)
    {
        if (entryOrder != null && entryOrder == order)
        {
             Print(order.ToString());
            if (order.OrderState == OrderState.Filled)
                  [B]entryOrder = null;[/B]
        }
    }
    OnBarUpdate is variable, this could be on 1 minute data or 1 tick data. To ensure that EnterLong does not get called Multiple times, the if statement checks if there was already an order.

    If there is not a current order or if entryOrder equals null, it sends EnterLong, otherwise does nothing. This just makes only 1 order at a time for the entire life of the order.

    This exact scenario may not apply to your script, this is intended to show how to store an IOrder and use it for logic in the entire script or between override methods and also how to check if the filled order was that stored order.

    I look forward to being of further assistance.

    Comment


      #3
      Maybe I was overthinking it - entryOrder is just a variable - when I'm done using it, I'm free to set it to NULL and re-use if needed.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      571 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      330 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      549 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      549 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X