Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order not being cancelled when I disable strategy

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

    Order not being cancelled when I disable strategy

    Hi,

    I have a basic strategy and for some reason my order remains when I disable the strategy. I'm sure this is not normal? Here is my code. I should also add I have tried changing liveuntilcancelled = false also which has the same outcome. When I eable to strategy aagin it's at this point whe the pre-existing order is cancelled and the new order for the now enabled strategy is placed.

    Code:
      protected override void Initialize()
            {
                IncludeCommission         = true;
                
                ExitOnClose             = true;                    // Cancel all orders & open positions at end of session.
                ExitOnCloseSeconds         = 1800;                    // Cancel all orders & open positions 1800 seconds (30 min) before end of session.
                
                TraceOrders                = true;                // Display order information in Output window for debugging. 
                
                CalculateOnBarClose        = false;
        
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
                 // At the start of a new session
                if (Bars.SessionBreak)
                {
                // Reset the priorTrade variable
                    priorTrade = 0;
                }
                
                // First, we need to make sure we are flat before entering a trade.
                if (Position.MarketPosition == MarketPosition.Flat)
                
                    {
                    if (entryOrder == null)
                        
                        {
                                 if (CurrentDayOHL().CurrentLow[0] >= Combo(3).CHM2[0]
                                    && priorTrade != Combo(3).CHM2[0])
                                    
                                    {
                                    entryOrder = EnterLongLimit(0, true, 1, Combo(3).CHM2[0], "long entry");    
                                    barNumberOfOrder = CurrentBar;
                                    //Print("");
                                    }
                                    
                        }
                    
                    }
            }
    Another issue I have noticed lately is when I load a strategy either on the chart or from the strategies tab it takes sometime to load is there any way I can fix this?

    Regards,
    suprsnipes
    Last edited by suprsnipes; 01-23-2013, 07:21 PM.

    #2
    suprsnipes, the order cancellation on strategy disablement would need to be enabled, it's not dictated by code per se. This setting could be found under Tools > Options > Strategies > NinjaScript >> Order Handling section.

    Comment

    Latest Posts

    Collapse

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