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 SalmaTrader, 07-07-2026, 10:26 PM
      0 responses
      47 views
      0 likes
      Last Post SalmaTrader  
      Started by CarlTrading, 07-05-2026, 01:16 PM
      0 responses
      22 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 06-17-2026, 10:32 AM
      0 responses
      15 views
      0 likes
      Last Post CaptainJack  
      Started by kinfxhk, 06-17-2026, 04:15 AM
      0 responses
      21 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 06-17-2026, 04:06 AM
      0 responses
      23 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Working...
      X