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

    #16
    Originally posted by NinjaTrader_PatrickH View Post
    Hello sburtt,

    Thank you for your response.

    I have tested further with your additional information and I see the same item.

    What is occurring is (for my test) the entryOrderLong is submitted at 8:30 AM on February 27th, the next bar occurs and the entry condition for the entryOrderShort is true so this order is attempted, however the entryOrderLong is not cancelled yet and causes the conflict.

    To resolves this you would need to place a check that both IOrder objects are null before entry:
    Code:
    		if (Position.MarketPosition == MarketPosition.Flat && [B]entryOrderLong ==null && entryOrderShort == null)[/B]
    			{
    				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 && [B]entryOrderLong ==null && entryOrderShort == null)[/B]
    			{
    				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
    Please let me know if I may be of further assistance.
    Patrick, first of all thanks for taking the time to look into this.

    I have 2 question:
    1.
    wouldn't it be more appropriate to make sure the previous entryOrderLong is cancelled? Maybe adding at the top the cancellation script in the FirstTickOfBar section?

    I am saying this because the entryOrderShort that is not entered on the incoming bar could be a very profitable trade and I want the strategy to pick up all potential setups,also if consequent one to another

    2.
    By eliminating the MarketPosition condition in the entry long/short in my strategy would It mean that if I am long and a entryOrderShort condition applies the strategy will stop and reverse? If yes, at what price would it exit (e.i. Market price?)?

    Thanks, John

    Comment


      #17
      Hello sburtt,

      Thank you for your response.
      Originally posted by sburtt View Post
      1. wouldn't it be more appropriate to make sure the previous entryOrderLong is cancelled? Maybe adding at the top the cancellation script in the FirstTickOfBar section?
        I am saying this because the entryOrderShort that is not entered on the incoming bar could be a very profitable trade and I want the strategy to pick up all potential setups,also if consequent one to another
      2. By eliminating the MarketPosition condition in the entry long/short in my strategy would It mean that if I am long and a entryOrderShort condition applies the strategy will stop and reverse? If yes, at what price would it exit (e.i. Market price?)?
      1. If you wish to cancel the order first to ensure you can enter on the bar you wish, then your example is good method of doing so.
      2. Correct, the Long position will be closed then by a Stop Order submitted at the same level as the Short Stop to enter short.

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

      Comment


        #18
        Originally posted by NinjaTrader_PatrickH View Post
        Hello sburtt,

        Thank you for your response.
        1. If you wish to cancel the order first to ensure you can enter on the bar you wish, then your example is good method of doing so.
        2. Correct, the Long position will be closed then by a Stop Order submitted at the same level as the Short Stop to enter short.

        Please let me know if I may be of further assistance.
        If my understanding is right the only circumstance I would then have a problem is if I have a entryOrderLong pending (that doesn't get filled) and on the following bar a condition to go short apply. Also from my understanding using a FirstTickOfBar to cancel pending orders would help me prevent this fault in live trading. But I still have a few questions:

        1. currently the script that cancels pending orders in the OnOrderUpdate() section, my understanding is that FirstTickOfBar goes at the top of the OnBarUpdate() section. Given I am trading in a single timeframe with liveTillCancel = false in my orders, am I right to assume that I need to copy/paste the script of my strategy from OnOrderUpdate() to OnBarUpdate()?

        2. I am reading around that the FirstTickOfBar works only for live trading, how can I get a similar output for backtesting purpose? Maybe going MultiTimeFrame?

        Comment


          #19
          Hello sburtt,

          Thank you for your response.
          Originally posted by sburtt View Post
          1. currently the script that cancels pending orders in the OnOrderUpdate() section, my understanding is that FirstTickOfBar goes at the top of the OnBarUpdate() section. Given I am trading in a single timeframe with liveTillCancel = false in my orders, am I right to assume that I need to copy/paste the script of my strategy from OnOrderUpdate() to OnBarUpdate()?

          2. I am reading around that the FirstTickOfBar works only for live trading, how can I get a similar output for backtesting purpose? Maybe going MultiTimeFrame?
          1. I would not move what you have in OnOrderUpdate() to OnBarUpdate(), the items you are checking use 'order' from the the OnOrderUpdate() method. I recommend testing out your ideas in simulation, Market Replay and/or backtesting.
          2. In backtesting you will need a smaller interval added such as a 1 tick, because the FirstTickOfBar will only works in real-time with CalculateOnBarClose = false. Backtesting is done on historical data which is always CalculateOnBarClose = true.
            For a reference sample on using a smaller time frame in your strategy for backtesting please visit the following link: http://www.ninjatrader.com/support/f...ead.php?t=6652
          Please let me know if I may be of further assistance.

          Comment


            #20
            Originally posted by NinjaTrader_PatrickH View Post
            Hello sburtt,

            Thank you for your response.
            1. I would not move what you have in OnOrderUpdate() to OnBarUpdate(), the items you are checking use 'order' from the the OnOrderUpdate() method. I recommend testing out your ideas in simulation, Market Replay and/or backtesting.
            2. In backtesting you will need a smaller interval added such as a 1 tick, because the FirstTickOfBar will only works in real-time with CalculateOnBarClose = false. Backtesting is done on historical data which is always CalculateOnBarClose = true.
              For a reference sample on using a smaller time frame in your strategy for backtesting please visit the following link: http://www.ninjatrader.com/support/f...ead.php?t=6652
            Please let me know if I may be of further assistance.
            I'm a little confused at this stage, lets assume that I am ok from a back testing perspective and decide to go live with the strategy, what should I include in the FirstTickOfBar to ensure orders are cancelled on the first tick of each bar?

            Comment


              #21
              Hello sburtt,

              Thank you for your response.

              An example of this would be the following:
              Code:
              			if(FirstTickOfBar && myOrder != null)
              			{
              				CancelOrder(myOrder);
              			}
              Please let me know if I may be of further assistance.

              Comment


                #22
                Originally posted by NinjaTrader_PatrickH View Post
                Hello sburtt,

                Thank you for your response.

                An example of this would be the following:
                Code:
                			if(FirstTickOfBar && myOrder != null)
                			{
                				CancelOrder(myOrder);
                			}
                Please let me know if I may be of further assistance.
                Thanks for that. Final question, then I promise to stop bothering you:

                1. For back test purpose to avoid this "Ignored PlaceOrder()" error, lets say I am trading 60min bars, should I add a 1 min bar, enterOrders on this higher frequency time frame and set liveUntilCancelled==true and cancel the order after 59 min?

                obviously this way I will have no orders for 1 minute every hour, but it's the only solution I see, tick data is too dirty for me

                Comment


                  #23
                  Hello sburtt,

                  Thank you for your response.

                  That solution may work for you, the only way to find out for certain is to test it out on your end in your strategy.

                  Comment


                    #24
                    Originally posted by NinjaTrader_PatrickH View Post
                    Hello sburtt,

                    Thank you for your response.

                    That solution may work for you, the only way to find out for certain is to test it out on your end in your strategy.
                    sure thing i will do so, was just wondering if there were other more conventional alternatives, thanks

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by cre8able, Today, 01:01 PM
                    1 response
                    4 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by manitshah915, Today, 12:59 PM
                    1 response
                    3 views
                    0 likes
                    Last Post NinjaTrader_Erick  
                    Started by ursavent, Today, 12:54 PM
                    1 response
                    4 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by Mizzouman1, Today, 07:35 AM
                    3 responses
                    17 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Started by RubenCazorla, Today, 09:07 AM
                    2 responses
                    13 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Working...
                    X