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

Error Message: Failed to cal method..

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

  • NinjaTrader_PatrickH
    replied
    Hello sburtt,

    Thank you for your response.

    In your response you detail the error that occurred, you have also provided some information into the cause:
    28/06/2012 22:00:00 Entered internal PlaceOrder() method at 28/06/2012 22:00:00: BarsInProgress=0 Action=SellShort OrderType=Stop Quantity=71,788 LimitPrice=0 StopPrice=1.5481 SignalName='Short' FromEntrySignal=''

    29/06/2012 22:00:00
    Entered internal PlaceOrder() method at 29/06/2012 22:00:00: BarsInProgress=0 Action=Buy OrderType=Stop Quantity=48,869 LimitPrice=0 StopPrice=1.5716 SignalName='Long' FromEntrySignal=''
    29/06/2012 22:00:00 Ignored PlaceOrder() method at 29/06/2012 22:00:00: Action=Buy OrderType=Stop Quantity=48,869 LimitPrice=0 StopPrice=1.5716 SignalName=Long' FromEntrySignal='' Reason='An Enter() method to submit an entry order has been ignored.
    Two orders to enter are submitted at the same time, the first order is accepted while the second order is rejected based on the following rule from the Internal Order Handling Rules:
    Methods that generate orders to enter a position will be ignored if:
    • The strategy position is flat and an order submitted by an enter method (EnterLongLimit() for example) is active and the order is used to open a position in the opposite direction
    Based on this information you will need to focus on conditions and methods that may result in both entry orders being submitted at the same time.

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

    Leave a comment:


  • sburtt
    replied
    Originally posted by NinjaTrader_Lance View Post
    I tried running the script on my end and didn't see any problematic errors.

    Only ignored order I see is
    7/26/2013 10:00:00 AM Ignore order amendment: Action=BuyToCover OrderType=Stop Quantity=399159 LimitPrice=0 StopPrice=1.5371 SignalName=New Stop-Loss' FromEntrySignal='Short' Reason='Order already has this stop price/limit price/quantity'

    This was triggered because the order change didn't change anything.

    Could you give me the timeframe you ran this on?
    the output.txt file below is a strategy running on a daily timeframe, bu the issue happens on any timeframe, there are no problematic errors, but every now and then I get something like this (see below) but running through the script I can't figure out why, any idea?

    Code:
    New Account Balance: 104091.8968
    Time: 28/06/2012 22:00:00
    CumProfit: 4091.89680000002
    Position Size: 71788
    28/06/2012 22:00:00 Entered internal PlaceOrder() method at 28/06/2012 22:00:00: BarsInProgress=0 Action=SellShort OrderType=Stop Quantity=71,788 LimitPrice=0 StopPrice=1.5481 SignalName='Short' FromEntrySignal=''
    
    New Account Balance: 104091.8968
    Time: 29/06/2012 22:00:00
    CumProfit: 4091.89680000002
    Position Size: 48869
    29/06/2012 22:00:00 Entered internal PlaceOrder() method at 29/06/2012 22:00:00: BarsInProgress=0 Action=Buy OrderType=Stop Quantity=48,869 LimitPrice=0 StopPrice=1.5716 SignalName='Long' FromEntrySignal=''
    [B]29/06/2012 22:00:00 Ignored PlaceOrder() method at 29/06/2012 22:00:00: Action=Buy OrderType=Stop Quantity=48,869 LimitPrice=0 StopPrice=1.5716 SignalName=Long' FromEntrySignal='' Reason='An Enter() method to submit an entry order has been ignored. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.'[/B]
    [B]**NT** An Enter() method to submit an entry order at '29/06/2012 22:00:00' has been ignored. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.[/B]
    29/06/2012 22:00:00 Cancelled expired order: BarsInProgress=0: Order='NT-00025/Backtest' Name='Short' State=Working Instrument='$GBPUSD' Action=SellShort Limit price=0 Stop price=1.5481 Quantity=71,788 Strategy='PPPP' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='12f3ac74856d49dc8055fd97d63756f1' Gtd='01/12/2099 00:00:00'
    
    New Account Balance: 104091.8968
    Time: 06/07/2012 22:00:00
    CumProfit: 4091.89680000002
    Position Size: 108429
    06/07/2012 22:00:00 Entered internal PlaceOrder() method at 06/07/2012 22:00:00: BarsInProgress=0 Action=SellShort OrderType=Stop Quantity=108,429 LimitPrice=0 StopPrice=1.5457 SignalName='Short' FromEntrySignal=''
    09/07/2012 22:00:00 Cancelled expired order: BarsInProgress=0: Order='NT-00026/Backtest' Name='Short' State=Working Instrument='$GBPUSD' Action=SellShort Limit price=0 Stop price=1.5457 Quantity=108,429 Strategy='PPPP' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='8324e797b0124fe3891ccb85aced0d90' Gtd='01/12/2099 00:00:00'

    Leave a comment:


  • NinjaTrader_Lance
    replied
    I tried running the script on my end and didn't see any problematic errors.

    Only ignored order I see is
    7/26/2013 10:00:00 AM Ignore order amendment: Action=BuyToCover OrderType=Stop Quantity=399159 LimitPrice=0 StopPrice=1.5371 SignalName=New Stop-Loss' FromEntrySignal='Short' Reason='Order already has this stop price/limit price/quantity'

    This was triggered because the order change didn't change anything.

    Could you give me the timeframe you ran this on?

    Leave a comment:


  • sburtt
    replied
    Originally posted by NinjaTrader_Bertrand View Post
    No, the updating of the order would not be the issue - if you used the same signal name (you differentiate between stop loss and new stop loss - would suggest removing that and just update the order).

    You see this as you would have a resting stop lying around with your script (as it's submitted with liveUntilCancelled set) - this will trigger the message then.

    Would suggest further debugging with the TraceOrders option to find which exact event sequence is causing it, so you can issue the needed CancelOrder() call in your script.

    http://www.ninjatrader.com/support/f...ead.php?t=3627
    Bertrand, attached is the strategy and the output.txt, as you can see the error persists, I tried looking into it, but I am no expert and don't understand what could be creating this issue, I would appreciate if you could look into this and let me know what you think. I owe you a beer after this..
    Attached Files

    Leave a comment:


  • sburtt
    replied
    Originally posted by NinjaTrader_Bertrand View Post
    No, the updating of the order would not be the issue - if you used the same signal name (you differentiate between stop loss and new stop loss - would suggest removing that and just update the order).

    You see this as you would have a resting stop lying around with your script (as it's submitted with liveUntilCancelled set) - this will trigger the message then.

    Would suggest further debugging with the TraceOrders option to find which exact event sequence is causing it, so you can issue the needed CancelOrder() call in your script.

    http://www.ninjatrader.com/support/f...ead.php?t=3627
    ok I will try this asap and revert if needed, thanks

    Leave a comment:


  • NinjaTrader_Bertrand
    replied
    No, the updating of the order would not be the issue - if you used the same signal name (you differentiate between stop loss and new stop loss - would suggest removing that and just update the order).

    You see this as you would have a resting stop lying around with your script (as it's submitted with liveUntilCancelled set) - this will trigger the message then.

    Would suggest further debugging with the TraceOrders option to find which exact event sequence is causing it, so you can issue the needed CancelOrder() call in your script.

    Leave a comment:


  • sburtt
    replied
    Originally posted by NinjaTrader_Bertrand View Post
    Issue with the ignored orders is due to the Internal order handling rules that you are hitting, having a stop loss order working with liveUntilCancelled and then attempting to issue a new order that would take you in the opposite direction, this will not work unless you cancelled the working order first.

    The full managed mode order rules are explained here in the bottom section -

    http://www.ninjatrader.com/support/h...ghtsub=managed
    Bertrand, this strategy only exits a trade via stoploss and only initiates a trade if market position is flat.

    correct me if wrong, the problem (but I am not sure) is that I am trying to adjust the original stop-loss to a new level without previously cancelling the original stoploss, could that be the case? If yes, how could I fix it?

    Leave a comment:


  • NinjaTrader_Bertrand
    replied
    sburtt, the first issue is not related to the script you posted. It's for the AAATest, you want to refer to this script's Initialize().

    Issue with the ignored orders is due to the Internal order handling rules that you are hitting, having a stop loss order working with liveUntilCancelled and then attempting to issue a new order that would take you in the opposite direction, this will not work unless you cancelled the working order first.

    The full managed mode order rules are explained here in the bottom section -

    Leave a comment:


  • sburtt
    started a topic Error Message: Failed to cal method..

    Error Message: Failed to cal method..

    Guys

    could anybody indicate why i get the following message (see attached) in my script:

    1.
    "Failed to Call ...."
    I suspect it might have to do with a missing DataSeries I should report in the Initialize() method, but I am unable to figure it out;

    2.
    "An entry() method..Please search on the term Internal Order Handling.."
    I suspect I am doing something wrong when placing my stop-loss, maybe because using ExitLongStop rather than Set() but this is what is advised in the tutorial, please could you help me solve this?

    Code:
    #region Using declarations
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Indicator;
    using NinjaTrader.Strategy;
    #endregion
     
    namespace NinjaTrader.Strategy
    {
    [Description("")]
    public class PPPP : Strategy
    {
        #region Variables
    	
    	private IOrder entryOrderLong = null;
    	private IOrder stopOrderLong = null;
    	private IOrder entryOrderShort = null;
    	private IOrder stopOrderShort = null;
    	private double  stopLoss = 0;
    	private double  AccBalNew = 0;
    	private double  AccountSize = 100000;
    	private double  Riskf = 1;
    	private double	Psize = 0;
    	private double priorTradesCumProfit = 0;
    	private double slippage = 3;
    
    	
        #endregion
    
    	protected override void Initialize()
    	{
    		CalculateOnBarClose = true;
    		ExitOnClose = false;
    	}
    
    	protected override void OnBarUpdate()
    	{ 
    		
    			#region Long Stop-Loss Adj
    		
    		//ADJUST STOP LOSS
    		if (Position.MarketPosition == MarketPosition.Long && stopOrderLong != null)
    			{	
    				if(Close[0] < Close[1] && Low[0] < Low[1])
    				{
    					stopOrderLong = ExitLongStop(0, true, stopOrderLong.Quantity, Low[0]-slippage*TickSize, "New Stop-Loss", "Long");
    				}
    			}		
    	
    		#endregion
    			
    		#region Short Stop-Loss Adj
    		
    		//ADJUST STOP LOSS
    		if (Position.MarketPosition == MarketPosition.Short && stopOrderShort != null)
    			{	
    				if(Close[0] > Close[1] && High[0] > High[1])
    				{
    					stopOrderShort = ExitShortStop(0, true, stopOrderShort.Quantity, High[0]+slippage*TickSize, "New Stop-Loss", "Short");
    				}
    			}
    
    			
    		#endregion			
    		
    		#region Long Entry
    			
    		
    		if (Position.MarketPosition == MarketPosition.Flat && entryOrderLong ==null)
    			{
    				if(Close[0] >MAX(High,5)[1])
    					{
    						stopLoss = High[0] - Low[0] + slippage * 2 * TickSize;
    						PositionSize();
    						entryOrderLong = EnterLongStop(0, false, (int)Psize, High[0]+slippage*TickSize,"Long");	
    					}
    			}
    		
    		#endregion	
    			
    		#region Short Entry
    		
    		
    		if(Position.MarketPosition == MarketPosition.Flat && entryOrderShort ==null)
    			{
    				if(Close[0] < MIN(Low,5)[1])
    				{
    					stopLoss = High[0] - Low[0] + slippage * 2 * TickSize;
    					PositionSize();
    					entryOrderShort = EnterShortStop(0, false, (int)Psize, Low[0]-slippage*TickSize,"Short");
    				}
    			}
    		
    		#endregion
    	}	
    	
    	protected override void OnOrderUpdate(IOrder order)
    	{
    		#region Reset Long Entry
    		
    		if (entryOrderLong != null && entryOrderLong == order)
    		{
    			if (order.OrderState == OrderState.Cancelled && order.Filled == 0)
    			{
    				entryOrderLong = null;
    			}
    		}
    		
    		#endregion
    
    		#region Reset Short Entry
    		
    		if (entryOrderShort != null && entryOrderShort == order)
    		{
    			if (order.OrderState == OrderState.Cancelled && order.Filled == 0)
    			{
    				entryOrderShort = null;
    			}
    		}
    		
    		#endregion
    	}
    	        
    	protected override void OnExecution(IExecution execution)
    	{		
    		#region Long Stop-Loss & Partial Fill Reset
    		
    		if (entryOrderLong != null && entryOrderLong == execution.Order)
    		{
    			if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
    			{
    				stopOrderLong = ExitLongStop(0, true, execution.Order.Filled, Low[0]-slippage*TickSize, "Stop-Loss", "Long");
    			}
    				
    			if (execution.Order.OrderState != OrderState.PartFilled)
    			{
    				entryOrderLong 	= null;
    			}
    		}
    		
    		#endregion
    						
    		#region Reset Long Stop-Loss & Target Profit
    		
    		if ((stopOrderLong != null && stopOrderLong == execution.Order))
    		{
    			if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled)
    			{
    				stopOrderLong = null;
    			}
    		}
    		
    		#endregion
    		
    		#region Short Stop-Loss & Partial Fill Reset
    		
    		if (entryOrderShort != null && entryOrderShort == execution.Order)
    		{
    			if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
    			{
    				stopOrderShort = ExitShortStop(0, true, execution.Order.Filled, High[0]+slippage*TickSize, "Stop-Loss", "Short");
    			}
    				
    			if (execution.Order.OrderState != OrderState.PartFilled)
    			{
    				entryOrderShort = null;
    			}
    		}
    		
    		#endregion
    						
    		#region Reset Short Stop-Loss & Target Profit
    		
    		if ((stopOrderShort != null && stopOrderShort == execution.Order) )
    		{
    			if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled)
    			{
    				stopOrderShort = null;
    			}
    		}	
    		
    		#endregion
    	}
    
    		#region PositionSizeFunction
    			//POSITION SIZING ONLY FOR DIRECT RATES	
    			void PositionSize()
    
    				{
    					priorTradesCumProfit = (double)Performance.AllTrades.TradesPerformance.Currency.CumProfit;
    					AccBalNew = AccountSize + priorTradesCumProfit;
    					Psize = Math.Round(AccBalNew * Riskf / 100 / stopLoss); 
    					//For fixed amount stopLoss to be defined as variable e.i. 50 pips = 50, then use formula: Psize = Math.Round(AccBalNew * Riskf / 100 / (stopLoss) / TickSize);
    					
    					Print("");
    					Print("New Account Balance: "+AccBalNew);
    					Print("Time: "+Time[0]);
    					Print("CumProfit: "+priorTradesCumProfit);
    					Print("Position Size: "+Psize);
    				}
    				
    		#endregion
    							
    		#region Properties
    							
    		[Description("Account Balance (US$)")]
    		[Category("Parameters")]
    		[Gui.Design.DisplayNameAttribute("\t\t\t\tAccount Balance (USD)")]
    		public double AccBal
    				{
    					get { return AccountSize; }
    					set { AccountSize = Math.Max(0, value); }
    				}              
    		
    		[Description("Risk Factor (%)")]
    		[Category("Parameters")]
    		[Gui.Design.DisplayNameAttribute("\t\t\tRisk Factor (%)")]
    		public double RiskF
    				{
    					get { return Riskf; }
    					set { Riskf = Math.Max(0, value); }
    				}              
    
    		[Description("Slippage(Pips)")]
    		[Category("Parameters")]
    		[Gui.Design.DisplayNameAttribute("\t\t\t\tSlippage(Pips)")]
    		public double Slippage
    				{
    					get { return slippage; }
    					set { slippage = Math.Max(0, value); }
    				}  				
    		#endregion
    	}
    }
    Attached Files
    Last edited by sburtt; 07-25-2013, 05:18 PM.

Latest Posts

Collapse

Topics Statistics Last Post
Started by RDTrader16, Today, 10:19 PM
0 responses
2 views
0 likes
Last Post RDTrader16  
Started by gemify, 03-08-2023, 08:02 AM
9 responses
148 views
0 likes
Last Post culpepper  
Started by elirion, Today, 10:03 PM
0 responses
1 view
0 likes
Last Post elirion
by elirion
 
Started by RaddiFX, Today, 09:55 PM
0 responses
6 views
0 likes
Last Post RaddiFX
by RaddiFX
 
Started by Trader146, 03-29-2024, 01:22 PM
4 responses
25 views
0 likes
Last Post Trader146  
Working...
X