Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 bill2023, Yesterday, 08:21 AM
      2 responses
      14 views
      0 likes
      Last Post bill2023  
      Started by ynoldsany, Today, 01:00 AM
      0 responses
      3 views
      0 likes
      Last Post ynoldsany  
      Started by Carolscogginsi, Yesterday, 10:45 PM
      0 responses
      7 views
      0 likes
      Last Post Carolscogginsi  
      Started by RaddiFX, Yesterday, 10:15 AM
      2 responses
      15 views
      0 likes
      Last Post RaddiFX
      by RaddiFX
       
      Started by patrickmlee007, Yesterday, 09:33 AM
      2 responses
      19 views
      0 likes
      Last Post patrickmlee007  
      Working...
      X