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 charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      67 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      150 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      162 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      100 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      288 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Working...
      X