View Full Version : Order of Bars in Progress
Freddie
05-02-2007, 12:55 PM
I have a strategy that needs to take the value of a second time frame and use it to calculate whether to enter or not in the default data series. The series is setup as series #2.
What appears to be happening is on, for example, the 9:45 bar I get a buy signal on series #2 (which is 15 minute time frame) and I get a buy signal on the same bar in the default series (which is 5 minutes) but the signal from the 15 minute bar is not recognized until the next 5 minute bar calculation.
It looks to me that the dataseries are processed starting with the default data series, series #1 and then series #2. So, as the buy order can only be initiated in the default series, it is run at 9:45 with the data signal from 9:30 (the previous bar)for data series #2.
Is there a way to have the program calculate data series #2 (ie. 15 min bars) prior to the default series (ie. 5 min bars) so that the result of the 15 min bars can be used to initiate trades when the default series is run on the same bar closing?
thx,
Fred
Freddie
05-02-2007, 01:00 PM
Here's a copy of what I'm seeing:
0 02/05/2007 9:45:00 AM TimeCheck = 1 LTFLong = 0 STFLong = 1 LTFShort = 0 STFShort = 0
1 02/05/2007 9:45:00 AM TimeCheck = 1 LTFLong = 0 STFLong = 1 LTFShort = 0 STFShort = 0
2 02/05/2007 9:45:00 AM TimeCheck = 1 LTFLong = 1 STFLong = 1 LTFShort = 0 STFShort = 0
You see that LTFLong = 1 for series 2 but is not calculated until after series "0" is run. I need the LTFlong signal at 9:45 to be used in the 9:45 series 0 calculation as to whether to enter or not.
Fred
NinjaTrader_Dierk
05-02-2007, 05:14 PM
Freddie wrote: I have a strategy that needs to take the value of a second time frame and use it to calculate whether to enter or not in the default data series. The series is setup as series #2.
What appears to be happening is on, for example, the 9:45 bar I get a buy signal on series #2 (which is 15 minute time frame) and I get a buy signal on the same bar in the default series (which is 5 minutes) but the signal from the 15 minute bar is not recognized until the next 5 minute bar calculation.
It looks to me that the dataseries are processed starting with the default data series, series #1 and then series #2.
>> correct
So, as the buy order can only be initiated in the default series, it is run at 9:45 with the data signal from 9:30 (the previous bar)for data series #2.
Is there a way to have the program calculate data series #2 (ie. 15 min bars) prior to the default series (ie. 5 min bars) so that the result of the 15 min bars can be used to initiate trades when the default series is run on the same bar closing?
>> no, you would need to switch the series in your setup
thx,
Fred
Freddie
05-03-2007, 01:14 AM
Dierk,
If I switch the series in the setup then the 15 minute series becomes default and then I cannot initiate trades on the 5 minute time frame.
So for example if at 9:45 the 15 minutes signal is to buy and the 5 minute has not triggered yet then I don't enter the trade. At 9:50, I'd like to check again if the 5 min signal has triggered given that I know that the 9:45 signal on the 15 minute is still a buy as it will not change again until 10 am but I won't be able to if the 15 minute is the default time frame.
It looks to me, based on your last reply, that you can only use multi time frames in instances where you want to trade in the longer time period and use signals from short time periods. Is that correct?
Fred
NinjaTrader_Dierk
05-03-2007, 02:52 AM
This likely is the same issue as here: http://ninjatrader.mywowbb.com/view_topic.php?id=2075&forum_id=16&jump_to=9784#p9 784
Sorry, but right now I can not provide you a better answer.
Freddie
05-03-2007, 03:07 AM
Dierk,
I might have found a work around for it. Is there a way to place an order at the open of the current bar even though the bar is calculated on the close? This would work for backtesting but not for using the strategy for automated trading.
The program is setup now to run the logic for the default series first. I've put the 5 min signal in dataseries #1, 15 min signal in dataseries #2. So when it runs dataseries #0 first it is using the values from the close of the previous bar in terms of 5 minute and 15 minute signals.
Fred
.
NinjaTrader_Dierk
05-03-2007, 03:09 AM
Freddie wrote: Dierk,
I might have found a work around for it. Is there a way to place an order at the open of the current bar even though the bar is calculated on the close?
>> sorry no
Freddie
05-03-2007, 05:54 AM
Thx Dierk for your help.
Just one follow-up; in the software there is a sample multi-timeframe sample strategy. I've run it on numerous instruments but no entries or exits. Not sure why but anyways it is similar to what I want to do.
Why would this one work and mine not? It appears to me that it will have the same problems that I'm having with having data not line up on the current bar during calculation and thus using some data from the previous bar. Can you help me understand the differences between this program and mine?
Fred
NinjaTrader_Dierk
05-03-2007, 05:57 AM
Hmm .. hard to tell. I suggest taking the NT sample, copying to your code and change it step by step to see where it finally breaks...
Freddie
05-03-2007, 06:20 AM
Dierk,
I've run the sample code as I said and it does not trigger any signals on any instruments and based on our discussion I don't see how it could work.
Does it work on your computer?
Fred
NinjaTrader_Dierk
05-03-2007, 06:23 AM
All samples are tested and do work. It could be that the signal conditions are not triggerd based on your test data set. Please try simplifying them or even eliminating them.
Freddie
05-03-2007, 07:48 AM
Dierk,
I'd really appreciate it if you ran the multi time frame sample as it really does not work. I ran the sample MA crossover and it works fine. Basically the two are the same strategy except one uses multi time frames.
I'm really trying to understand why my strategy does not work or how I could modify to make it work differently and am trying to find something that might give me an idea of how it might be modified (ie. the sample multi time frame strategy) but it appears, as I said, not to work. Maybe none of the multi time frame strategies work. Based on what I know and what you've told me I can't see how any of them could work accurately.
I'm willing and have put a lot of work in on my end to get up to speed on the programming, etc. and I don't want to have it all go to waste and have to start over with a new software program. If the software cannot do multi timeframes then let me know and I'll figure out another way to do it.
thx,
NinjaTrader_Dierk
05-03-2007, 07:53 AM
Freddie,
NT for sure has the limitations as outlined below: http://ninjatrader.mywowbb.com/view_topic.php?id=2075&forum_id=16&jump_to=9784#p9 784 (view_topic.php?id=2075&forum_id=16&jump_to=9784#p 9784)
Unfortuntely we can not offer a work around for you at this time.
Sorry
NinjaTrader_Dierk
05-03-2007, 06:12 PM
More clarification on that issue:
- as you have a strategy with 2 different time frames on the same instrument you only can place orders/signals in the OnBarUpdate method of series #1 but not in the OnBarUpdate method of series #2: you'll see log entries that these orders/signals will be rejected
- as you have a strategy with 2 series on different instruments you can place orders/signals in the OnBarUpdate method of series #1 and series #2, but you can not place an order/signal for series #1 while in the OnBarUpdate method of series #2 (and vice versa)
We will consider eliminating this limitation later on this year.