Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to avoid Order rejected issue with IB

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

    How to avoid Order rejected issue with IB

    Hi guys,

    I am running an automated strategy on forex, my broker is Interactive brokers. I noticed that every day between 10pm GMT and 10.05pm GMT my orders get rejected, as if the connection between NT and IB gets reset. This is the error message I get and it sounds very much as this is a broker issue rather than NT issue:

    Order rejected - reason:The exchange is closed. (201)
    What I am thinking is how to get my strategy to avoid entering new orders or adjusting my stop loss in the time window between 10 and 10.05 pm, would adding the part in bold be sufficient:

    Code:
    		
    if(BarsInProgress == 1) // secondary time frame (e.i. 1 min)
    		{		
    
    			if(long_condition) 
    			{
    				if (Position.MarketPosition == MarketPosition.Flat && entryOrderLong ==null [B]&& ToTime(Times[1][0]) < (220000) && ToTime(Times[1][0]) > (220500)[/B])
    					{
    						entryOrderLong = EnterLongStop(...);
    					}
    			}
    		}
    Futhermore, I am managing my stop loss in the primary time frame (e.i. 60 min bar)
    Code:
    				
    if(BarsInProgress == 0)	// primary time frame (e.i. 30 min)
    		{							
    			if(Position.MarketPosition == MarketPosition.Long && stopOrderLong != null)
    			{    
    				double newStop = 0;
    				if(stop_condition) newStop = Low[0];		 
    				if(newStop > stopOrderLong.StopPrice && newStop < Close[0])	// check if new stop loss is higher than current stop loss
    				{	
    					stopOrderLong = ExitLongStop(...);			
    				}
    			}
    		}
    this wouldn't allow me to adjust an existing order only 5 minutes after the close of the bar, therefore I assume I would need to move my stop loss management in the secondary time frame, is this assumption correct?

    Thanks
    Last edited by sburtt; 10-10-2013, 04:00 PM.

    #2
    Hello sburtt,

    Thank you for your post.

    Your assumption is correct on the Stop Loss adjustments. For the Time I would use or rather than and, the time will never be less than 10 PM and greater than 10:05 PM at the same time.

    Change it to the following:
    Code:
    && ToTime(Times[1][0]) < (220000) || ToTime(Times[1][0]) > (220500)
    For a reference sample on time filters please visit the following link: http://www.ninjatrader.com/support/f...ead.php?t=3226

    Please let me know if I may be of further assistance.

    Comment


      #3
      Originally posted by NinjaTrader_PatrickH View Post
      Hello sburtt,

      Thank you for your post.

      Your assumption is correct on the Stop Loss adjustments. For the Time I would use or rather than and, the time will never be less than 10 PM and greater than 10:05 PM at the same time.

      Change it to the following:
      Code:
      && ToTime(Times[1][0]) < (220000) || ToTime(Times[1][0]) > (220500)
      For a reference sample on time filters please visit the following link: http://www.ninjatrader.com/support/f...ead.php?t=3226

      Please let me know if I may be of further assistance.
      yes right! sorry it was late and i was tired

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      52 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      142 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      160 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      96 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      276 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Working...
      X