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

Order rejected - Forex.com

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

    Order rejected - Forex.com

    Hi, I'm using a fairly simple managed strategy for always being either long or short in the market. The strategy finishes itself roughly once a day. Error message I'm seeing is "'Order rejected'. Strategy has sent cancel requests, attempted to close the position and terminated itself." Now I'm at a point to completely give up NT8 and Forex.com, because I think managed approach does not work reliably. Please advise if anything seems wrong, or if anything can be done with proper error handling.

    Code:
    		
                    protected override void OnBarUpdate()
    		{
     			// check conditions for trade
    			if (CurrentBar	< BarsRequiredToTrade)
    				return;
    
    			// enter based on slave signals
      			if (mOrder == null && isUpTrend())
          			    EnterLong("myOrder");
      			if (mOrder == null && isDownTrend())
          			    EnterShort("myOrder");
    		}
    
    		protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string nativeError)
    		{
    		    // Assign entryOrder in OnOrderUpdate() to ensure the assignment occurs when expected.
    		    // This is more reliable than assigning Order objects in OnBarUpdate, as the assignment is not gauranteed to be complete if it is referenced immediately after submitting
    		    if (order.Name == "myOrder" && orderState != OrderState.Filled)
    		      	mOrder = order;
    		 
    		    if (mOrder != null && mOrder == order)
    		    {
    		        Print(DateTime.Now.ToString()+"|"+ Name + "|" + order.ToString());
    		        if (order.OrderState == OrderState.Filled)
    		       		mOrder = null;
    		    }
    		}
    The error log:
    Time Category Message
    5/29/18 5:25 Position Instrument='GBPUSD' Account='401386179' Average price=1.33168 Quantity=10,000 Market position=Short Operation=Operation_Add
    5/29/18 5:25 Execution Execution='635614510' Instrument='GBPUSD' Account='401386179' Exchange=Default Price=1.33168 Quantity=10,000 Market position=Short Operation=Operation_Add Order='635614510' Time='5/29/2018 5:25 AM'
    5/29/18 5:25 Order Order='635614510/401386179' Name='' New state='Filled' Instrument='GBPUSD' Action='Sell' Limit price=0 Stop price=0 Quantity=10,000 Type='Market' Time in force=GTC Oco='' Filled=10000 Fill price=1.33168 Error='No error' Native error=''
    5/29/18 5:25 Order Order='635614510/401386179' Name='' New state='Working' Instrument='GBPUSD' Action='Sell' Limit price=0 Stop price=0 Quantity=10,000 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
    5/29/18 5:25 Order Order='635614510/401386179' Name='' New state='Accepted' Instrument='GBPUSD' Action='Sell' Limit price=0 Stop price=0 Quantity=10,000 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
    5/29/18 5:25 Order Order='635614510/401386179' Name='' New state='Submitted' Instrument='GBPUSD' Action='Sell' Limit price=0 Stop price=0 Quantity=10,000 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
    5/29/18 5:25 Position Instrument='GBPUSD' Account='401386179' Average price=0 Quantity=0 Market position=Flat Operation=Remove
    5/29/18 5:25 Execution Execution='635614506' Instrument='GBPUSD' Account='401386179' Exchange=Default Price=1.33168 Quantity=10,000 Market position=Short Operation=Operation_Add Order='635614506' Time='5/29/2018 5:25 AM'
    5/29/18 5:25 Order Order='635614506/401386179' Name='myOrder' New state='Filled' Instrument='GBPUSD' Action='Sell short' Limit price=0 Stop price=0 Quantity=10,000 Type='Market' Time in force=GTC Oco='' Filled=10000 Fill price=1.33168 Error='No error' Native error=''
    5/29/18 5:25 Order 401386179, Another instruction has already made changes to the trades and orders. affected Order: Sell 10000 Market
    5/29/18 5:25 Order Order='8c8fdc5033e54fdda649a4b360db4a34/401386179' Name='Close position' New state='Rejected' Instrument='GBPUSD' Action='Sell' Limit price=0 Stop price=0 Quantity=10,000 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='Order rejected' Native error='Another instruction has already made changes to the trades and orders. '
    5/29/18 5:25 Default Disabling NinjaScript strategy 'TfsEmaTrendBarsV1.3/138997332'
    5/29/18 5:25 Default Strategy 'TfsEmaTrendBarsV1.3/138997332' submitted an order that generated the following error 'Order rejected'. Strategy has sent cancel requests, attempted to close the position and terminated itself.
    5/29/18 5:25 Order Order='635614506/401386179' Name='myOrder' New state='Submitted' Instrument='GBPUSD' Action='Sell short' Limit price=0 Stop price=0 Quantity=10,000 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
    5/29/18 5:25 NinjaScript NinjaScript strategy 'TfsEmaTrendBarsV1.3/138997332' submitting order
    5/29/18 5:25 NinjaScript NinjaScript strategy 'TfsEmaTrendBarsV1.3/138997332' submitting order

    #2
    Hello TraderFrank,

    Thank you for your note.

    Could you please send an email to platformsupport[at]ninjatrader[dot]com with Attn: Alan P in the Subject line. Also within the email please include a link to this thread, and attach the log and trace files for the day in subject which you can find in My Documents>NinjaTrader8>Log and My Documents>NinjaTrader8/Trace folders.

    I look forward to your email.
    Alan P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by wzgy0920, 04-20-2024, 06:09 PM
    2 responses
    26 views
    0 likes
    Last Post wzgy0920  
    Started by wzgy0920, 02-22-2024, 01:11 AM
    5 responses
    32 views
    0 likes
    Last Post wzgy0920  
    Started by wzgy0920, Yesterday, 09:53 PM
    2 responses
    49 views
    0 likes
    Last Post wzgy0920  
    Started by Kensonprib, 04-28-2021, 10:11 AM
    5 responses
    192 views
    0 likes
    Last Post Hasadafa  
    Started by GussJ, 03-04-2020, 03:11 PM
    11 responses
    3,235 views
    0 likes
    Last Post xiinteractive  
    Working...
    X