Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

So does Gtc work in backtest?

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

    So does Gtc work in backtest?

    Hi, maybe this is not a NT 6.5 specific issue, but I noticed it in NT 6.5.

    As you can see in the attached picture, my strategy failed get out at the top of a trend, at around $0.7900 even though the strategy placed a Gtc limit order that should have filled the *next day*. If the order type is a day order, this behavior is perfectly reasonable, but I see Time in force value set to Gtc in the Backtest window. As you can see from order trace, the limit sell order was entered successfully for Jan 22. So I am confused on whether I really understand how Gtc order works in NT.

    1/22/2007 12:00:00 AM Entered internal PlaceOrder() method at 1/22/2007 12:00:00 AM: Action=Sell OrderType=Limit Quantity=1 LimitPrice=0.7921 StopPrice=0 SignalName='' FromEntrySignal=''
    1/22/2007 12:00:00 AM Entered internal PlaceOrder() method at 1/22/2007 12:00:00 AM: Action=SellShort OrderType=Limit Quantity=1 LimitPrice=0.7921 StopPrice=0 SignalName='' FromEntrySignal=''
    1/23/2007 12:00:00 AM Entered internal PlaceOrder() method at 1/23/2007 12:00:00 AM: Action=SellShort OrderType=Limit Quantity=1 LimitPrice=0.7921 StopPrice=0 SignalName='' FromEntrySignal=''
    1/26/2007 12:00:00 AM Entered internal PlaceOrder() method at 1/26/2007 12:00:00 AM: Action=Sell OrderType=Market Quantity=0 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
    Attached Files

    #2
    Did you also set the Exit On Close setting to false?
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Yes. In fact, it would not even enter into any position unless ExitOnClose is false.

      Comment


        #4
        Are you also using the liveUntilCancelled set to true?

        EnterLongLimit(int barsInProgressIndex, bool liveUntilCancelled, int quantity, double limitPrice, string signalName)

        Code:
        EnterLongLimit(0, true, 1, Low[0], "");
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Thanks Josh. I got the same result with
          EnterLongLimit(0, true, 1, limitPrice, "");

          In fact, I seem to get a fill only with Gtc and closeAtEndOfDay = false, but this order behaves like Day order. Quite bizzare...
          Is it because I am using 1440 minute bar?

          Comment


            #6
            It shouldn't matter what minute chart you are running. Please try my attached test strategy. It will submit an order that should never be filled and will stay active. Running it in the Strategy Analyzer and bringing up the Orders tab will confirm this.

            If the test strategy works for you then there has to be something your strategy is doing to cause behavior you are seeing. You will need to debug.
            Attached Files
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Josh thanks for the file. I ran it against the same data set and indeed the strategy did not fill. When I turned around and thought about the implication though, I am not sure how this fact relates to my problem, which is that my order is NOT filled. Originally, I was using Day order, and got the following traces:

              12/19/2007 12:00:00 AM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Ticks Value=87 Currency=0 Simulated=False
              12/19/2007 12:00:00 AM Entered internal PlaceOrder() method at 12/19/2007 12:00:00 AM: Action=Buy OrderType=Limit Quantity=1 LimitPrice=0.8517 StopPrice=0 SignalName='' FromEntrySignal=''
              12/19/2007 12:00:00 AM Cancelled order due to end of session handling: BarsInProgress=0: Order='NT-00100/Back101' Name='Buy' State=Working Instrument='$AUDUSD' Action=Buy Limit price=0.851748563432997 Stop price=0 Quantity=1 Strategy='TRADStrategy' Type=Limit Tif=Day Oco='' Filled=0 Fill price=0 Token='1b7172f6474140cd9c44b6aafe5d2c25' Gtd='12/1/2099 12:00:00 AM'

              As you can see, the order is cancelled as soon as it is entered because 12:00 AM is considered the end of the day. This is why I started looking into the Gtc order, even though that's not really what I want.

              Now if we take a step back and think about how a typical Day order works when testing with daily historical data (using OpenTick for example), I believe that if I place an order on 12/19, when the bar is complete, the order will show up in the simulator (or the market too if I were trading for real?) the next day, 12/20. This behavior seems logical and different than what I am seeing with 1440 minute bars.

              I am happy to debug my program. I just want us to be on the same page about where to look first before I look at my program, which behaves fine on historical daily data. Does this sound reasonable?

              -Henry

              Comment


                #8
                I guess the point is that the sample strategy Josh provided demonstrates that GTC in fact really does not cancel at the end of the day. If this is true, then the next step is to debug your code to try and isolate what is causing the unexpected behaviour.
                RayNinjaTrader Customer Service

                Comment


                  #9
                  Also curious as to why you use 1440 min bars? Why don't you just use daily bars?
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    I would love to use daily bars. But you (or Gain) don't provide historical bar. Since there are 1440 minutes in a day in FX, 1440 minute bar is a poor man's daily bar. I would really appreciate having a daily bar (that I can specify the start and stop time of), so please let me know if and when you do have it.

                    -Henry

                    Comment


                      #11
                      Thanks for the suggestion. We'll put it on the list.
                      Josh P.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      599 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      344 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      103 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      558 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      557 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X