Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Opening entries

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

    Opening entries

    hi,

    my strategy works well with backtesting.
    History shows the results I am seeking.

    But, when I forward test, the strategy buys multiple entries when it shouldn't.
    This is a grid-based strategy, where the price of the first entry is stored.

    For example, I want 2 separate entries:

    Code:
                
     if (Position.MarketPosition  !=   MarketPosition.Long)
                {
                    EnterLong(Quantity, "Buy");
                    FirstPrice = SMA(1)[0];
                }
    
    
    if (Position.MarketPosition  ==   MarketPosition.Long   &&  SMA(1)[0]     <    FirstPrice  - 10 * TickSize )
                {
                    EnterLong(Quantity, "Entry2");
                }
    Why does this work perfectly with history shown, but buy Entry2 immediately with the first entry during forward testing ?

    #2
    Faspomy,

    This may be relevant : http://www.ninjatrader.com/support/f...37&postcount=2

    From this code, it would possibly open 2 depending on the settings you have, which are explained at the aforementioned link. Since there is not more code listed here, I cannot really comment further.

    Please feel free to post more and I would be happy to review.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_AdamP View Post
      Please feel free to post more and I would be happy to review.
      Thank you.
      My settings are here:

      Code:
                  EntriesPerDirection             = 1;
                  EntryHandling                     = EntryHandling.UniqueEntries;
      In the history, one position is opened, then 10 pips down, a second position is opened.
      But in forward testing, both positions are opened simultaneously.

      I tried to take this further with more entries at other values (20 pips down, etc.), and they all enter at the same time as the first entry. The strategy should wait until the price drops to the appropriate level, like it does in the history view.

      Comment


        #4
        Also, I just tried switching to

        Code:
                    EntriesPerDirection             = 10;
                     EntryHandling                     = EntryHandling.AllEntries;
        I have the same result.

        Comment


          #5
          faspomy,

          What is your calculate on bar close setting? If false its possible it would generate two orders, especially with UniqueEntries setting.
          Adam P.NinjaTrader Customer Service

          Comment


            #6
            Thank you.

            It was set to false.

            I set it to true, and got a similar result:
            The first order opened as planned. But the second, third, fourth, etc., all opened at the same time as the second though they all had different price values.

            Comment


              #7
              Wait a second--

              I just tried this on one currency pair AUDCAD and it seems to not buy all at once.
              Then I tried on another, NZDUSD, and it bought all at once.

              So this seems to be an issue only with certain currency pairs...
              Odd...

              Comment


                #8
                Fapsomy,

                It could be that the strategy defaults the Calculate on Bar Close setting to False. Then you would need to change it for every chart.

                Please let me know if I may assist further.
                Adam P.NinjaTrader Customer Service

                Comment


                  #9
                  Thank you.

                  I hard-coded the Calculate On Bar close to true.

                  The issue still persists with NZDUSD.
                  Maybe its pip values are different ?

                  With NZDUSD, the strategy opens one order, then 10 more a moment (1 minute bar) later.
                  Regardless of the price.

                  Comment


                    #10
                    Faspomy,

                    The chart can override this still. Does the chart have it set to this?
                    Adam P.NinjaTrader Customer Service

                    Comment


                      #11
                      No.
                      I'm not sure why that one currency pair is showing this error.

                      I tested other currency pairs, which work fine...

                      Comment


                        #12
                        Faspomy,

                        The simple answer here is that your conditions for the second order are true. To check into this will need to print all values used in your condition to verify they're what you expect. The main unknown is your FirstPrice variable. Print that, and enable TraceOrders = true; to offer more insight on what your strategy is doing. Help for using these tools is here:


                        Also, look into any possible sync settings, like if your strategy is already in a historical position at the time you startup. More information on what you can expect given the various settings available and your historical strategy position is available here:
                        Ryan M.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Skifree, Today, 03:41 AM
                        3 responses
                        12 views
                        0 likes
                        Last Post Skifree
                        by Skifree
                         
                        Started by traderqz, Yesterday, 09:06 AM
                        5 responses
                        32 views
                        0 likes
                        Last Post NinjaTrader_Jesse  
                        Started by guillembm, Today, 11:25 AM
                        1 response
                        6 views
                        0 likes
                        Last Post NinjaTrader_Jesse  
                        Started by owensd, 04-21-2024, 11:34 PM
                        9 responses
                        34 views
                        0 likes
                        Last Post NinjaTrader_Gaby  
                        Started by trilliantrader, 04-10-2024, 09:33 PM
                        7 responses
                        25 views
                        0 likes
                        Last Post NinjaTrader_BrandonH  
                        Working...
                        X