Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

CancelOrder() secondary time frame

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

    CancelOrder() secondary time frame

    Hi,

    I'm running into a problem with canceling managed orders in a multi time frame strategy.

    From the primary timeframe I sent an EnterLongStop order (live until cancelled = true) to one minute timeframe.

    Now I want it to be cancelled on the next open of my primary timeframe. I used a counter to sent a CancelOrder() after one bar. But then backtests show no more trades. When playing a littel with the code I found that if I set the counter to a huge number (1000) the trades reappear.

    If I set live untill canceled to false the order holds for only one minute.

    If anyone can help me with this, please see th code below

    Code:
    			if (BarsInProgress == 0)
    			{
    			
       			if (CurrentBar > barNumberOfOrderL + 5)
    			{
    				CancelOrder(entryOrderL);
    			}
    			
    			if (CurrentBar > barNumberOfOrderS + 5)
    			{
    				CancelOrder(entryOrderS);
    			}
    				
    			stopOrderL = ExitLongStop(1, true, DefaultQuantity, updatedstopL, "ExitLong 1min", "LongStopEntry 1min");
    			stopOrderS = ExitShortStop(1, true, DefaultQuantity, updatedstopS, "ExitShort 1min", "ShortStopEntry 1min");
        		
    			if (	"My entrylong code")
    				{
    					entryOrderL = EnterLongStop(1, true, DefaultQuantity, entrypriceL, "LongStopEntry 1min");
    					stopOrderL = ExitLongStop(1, true, DefaultQuantity, stoppriceL, "ExitLong 1min", "LongStopEntry 1min");	
    					
    					barNumberOfOrderL = CurrentBar;
    				}
    			
    			if (	"My entryshort code"
    )
    				{
    					entryOrderS = EnterShortStop(1, true, DefaultQuantity, entrypriceS, "ShortStopEntry 1min");
    					stopOrderS = ExitShortStop(1, true, DefaultQuantity, stoppriceS, "ExitShort 1min", "ShortStopEntry 1min");
    				
    					barNumberOfOrderS = CurrentBar;
    				}
    				
    	
    			}

    #2
    marco,

    I see you have another thread open with Bertrand helping you. I would suggest working through this issue there as well if its the same strategy.

    Support for the development of custom automated trading strategies using NinjaScript.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Hi Adam

      yes it is! sorry for being impatient. We'll deal with this in one thread.

      Marco

      Comment

      Latest Posts

      Collapse

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