NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > Application Technical Support > Miscellaneous Support > Historical NinjaTrader 6.5 Archive > Historical NinjaTrader 6.5 Beta Threads

 
 
Thread Tools Display Modes
Old 12-20-2007, 09:04 PM   #1
henry.omd
Member
 
Join Date: Oct 2007
Posts: 72
Thanks: 0
Thanked 0 times in 0 posts
Default 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 Images
File Type: jpg $AUDUSD 2_9_2007 (1440 Min).jpg (55.9 KB, 18 views)
henry.omd is offline  
Old 12-20-2007, 11:46 PM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Did you also set the Exit On Close setting to false?
NinjaTrader_Josh is offline  
Old 12-21-2007, 12:33 PM   #3
henry.omd
Member
 
Join Date: Oct 2007
Posts: 72
Thanks: 0
Thanked 0 times in 0 posts
Default

Yes. In fact, it would not even enter into any position unless ExitOnClose is false.
henry.omd is offline  
Old 12-21-2007, 12:56 PM   #4
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

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], "");
NinjaTrader_Josh is offline  
Old 12-21-2007, 08:24 PM   #5
henry.omd
Member
 
Join Date: Oct 2007
Posts: 72
Thanks: 0
Thanked 0 times in 0 posts
Default

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?
henry.omd is offline  
Old 12-21-2007, 11:17 PM   #6
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

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
File Type: cs gtctest.cs (1.3 KB, 7 views)
NinjaTrader_Josh is offline  
Old 12-22-2007, 09:49 AM   #7
henry.omd
Member
 
Join Date: Oct 2007
Posts: 72
Thanks: 0
Thanked 0 times in 0 posts
Default

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
henry.omd is offline  
Old 12-22-2007, 12:20 PM   #8
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

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.
NinjaTrader_Ray is offline  
Old 12-22-2007, 01:34 PM   #9
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Also curious as to why you use 1440 min bars? Why don't you just use daily bars?
NinjaTrader_Josh is offline  
Old 12-30-2007, 07:25 AM   #10
henry.omd
Member
 
Join Date: Oct 2007
Posts: 72
Thanks: 0
Thanked 0 times in 0 posts
Default

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
henry.omd is offline  
Old 12-30-2007, 04:24 PM   #11
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Thanks for the suggestion. We'll put it on the list.
NinjaTrader_Josh is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Backtest won´t work on Indices - solved by recreating the Index as a Stock. tomcat Strategy Analyzer 5 03-23-2010 06:24 AM
Strategy won't backtest... maxpi Strategy Analyzer 3 11-29-2007 08:09 AM
Backtest Problems v6.5 AO76 Strategy Analyzer 1 11-11-2007 02:47 PM
Backtest not available BradB Strategy Analyzer 9 11-10-2007 09:41 PM
stoploss and MAE in backtest ceesvh Strategy Analyzer 8 07-12-2007 08:02 AM


All times are GMT -6. The time now is 12:55 AM.