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

Trades not taken and/or confirmed in sim and replay

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

    Trades not taken and/or confirmed in sim and replay

    I am pretty sure this topic has been tabled here before, however, I couldn't find any threads that covered exactly this.

    As long as I exit (ExitLong or ExitShort) with the same number of contracts that I entered with all is well. However, when I exit with different number of contracts than I enter with things get a bit strange. For example, if I EnterShort( 2 ) then a few bars later I ExitShort( 1 ) and then a few bars later I ExitShort( 1 ) the second exit is often ignored. Every time my strategy enters or exits it Print()s.
    I also do this:
    Code:
    protected override void OnExecution( IExecution execution )
    		{
    			// Remember to check the underlying IOrder object for null before trying to access its properties
    			if( execution.Order != null && execution.Order.OrderState == OrderState.Filled )		Print( execution.ToString() );
    		}
    Output window:
    Short enter 2 3/13/2015 1:09:52 PM
    Execution='NT-00144' Instrument='NQ 03-15' Account='Replay101' Name='Sell short' Exchange=Default Price=4292.75 Quantity=2 Market position=Short Commission=0 Order='NT-00144' Time='3/13/2015 1:10:09 PM'
    Short exit 1 3/13/2015 1:12:33 PM
    Execution='NT-00145' Instrument='NQ 03-15' Account='Replay101' Name='Buy to cover' Exchange=Default Price=4290.25 Quantity=1 Market position=Long Commission=0 Order='NT-00145' Time='3/13/2015 1:12:38 PM'
    Short exit 1 3/13/2015 1:15:38 PM
    Notice no confirmation after the second exit order. The order symbol is also not showing up on the chart.

    What m I missing?

    #2
    The problem I illustrated is true for sim and replay. When I apply the strategy to an existing chart all trades are taken and confirmed, virtually, of course.

    I think I remember reading on here somewhere that sim and replay can be inconsistent and that real live data is handled properly.

    Comment


      #3
      Hello bernie_c,
      Thanks for posting today.

      When using the EnterLong or EnterShort entry methods you can only ExitLong or ExitShort with the same number of contracts.

      If you wish to have two contracts and exit at two different prices you would need to create two separate entry methods.

      This must be done when using the managed approach to order methods such as the EnterLong, EnterShort, ExitLong, and ExitShort methods.

      Here is a link to the help guide discussing the managed approach for strategy development.
      http://www.ninjatrader.com/support/h...d_approach.htm

      Please let us know if we may be of further assistance for anything NinjaTrader.
      Alex G.NinjaTrader Customer Service

      Comment


        #4
        Alex,

        I understand what you are saying, but the documentation seems to contradict. According to the documentation you refer me to what I was trying to do should be fine.
        From your link:
        How to close a position
        ...
        Closing a Partial Position using an Exit Method

        You can close out a partial position by specifying the exit quantity. The following example goes long 3 contracts. Each subsequent bar update will submit a market order to exit one contract until the position is completely closed. ExitLong(1) will be ignored if a long market position does not exist.

        protected override void OnBarUpdate()
        {
        if (CrossAbove(SMA(10), SMA(20), 1))
        EnterLong(3);

        ExitLong(1);
        }

        Comment


          #5
          Hello bernie_c,
          Thanks for the clarification.

          I discussed this with another NinjaScript Tech here. This is an known issue based on the data being used.

          The strategy you mentioned, and documented in the Help Guide, will work while back testing and using historical data. However, when using live data will fail as you have seen.

          Here is a link to a forum post discussing this issue.



          Please let us know if we may be of further assistance for anything NinjaTrader.
          Alex G.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by benmarkal, Yesterday, 12:52 PM
          3 responses
          23 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by helpwanted, Today, 03:06 AM
          1 response
          19 views
          0 likes
          Last Post sarafuenonly123  
          Started by Brevo, Today, 01:45 AM
          0 responses
          11 views
          0 likes
          Last Post Brevo
          by Brevo
           
          Started by pvincent, 06-23-2022, 12:53 PM
          14 responses
          244 views
          0 likes
          Last Post Nyman
          by Nyman
           
          Started by TraderG23, 12-08-2023, 07:56 AM
          9 responses
          388 views
          1 like
          Last Post Gavini
          by Gavini
           
          Working...
          X