![]() |
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Jan 2009
Posts: 114
Thanks: 0
Thanked 0 times in 0 posts
|
I'm building a strategy which needs calculate two sets of pivot points--one set on a futures contract using regular hours (8:30AM - 3:15PM) H, L, C, and another set which uses 24 hours H, L, C. The chart on which the strategy will be placed includes the Globex session. I am extracting the regular session H,L,C from a 2nd data set with a bar interval of 30m. I start counting Highs and lows as soon as the 30m bar time = 9000000, meaning the first bar of the regular session. I stop counting Highs and lows when the bar time = 153000, meaning the last bar of the regular session (which actually ends at 15:15, but there are no trades between 15:15 and 15:30). All of my calculations work fine except that sometimes the regular session close which I take from the 30m bar which ends at 15:30 is off by a tick. I'm not sure why. Sometimes its correct, but other tiems the close doesn't match the close on my comparison chart which is a 30m chart set to session start/stop = 8:30AM/3:15PM.
Do you know what the problem is? OR...is there an easier way of doing what I'm trying to do here, (i.e. extract regular session H,L,C from a 24hour chart which is not necessarily set to minute intervals)? Thanks, rsi77 |
|
|
|
|
|
#2 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
rsi77,
If the data says there is a tick coming in at 15:30 that moves it for you then that is what you will get in your calculations. I suggest you use CalculateOnBarClose = false and just look in real-time to see when and what your data comes in as.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Jan 2009
Posts: 114
Thanks: 0
Thanked 0 times in 0 posts
|
"If the data says there is a tick coming in at 15:30 that moves it for you then that is what you will get in your calculations. I suggest you use CalculateOnBarClose = false and just look in real-time to see when and what your data comes in as."
So if I want to know the beginning of the session I would use if (ToTime(Time[0]) > 83000 and ToTime(Time[1]) < 83000) { start tracking H, L; } and if (ToTime(Time[0]) > 151500 and ToTime(Time[1]) < 151500) { RegSesClose=Close[1]; } Am I understanding this correctly??? Thanks |
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
Not sure why you would check Time[0] and Time[1] also. The conditions you have outlined are mutually inclusive. If Time[0] > 8:30 for sure Time[1] < 8:30.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Jan 2009
Posts: 114
Thanks: 0
Thanked 0 times in 0 posts
|
No, if time[0] = 9:50 and time[1]=9:48 they are both > 8:30....I wanted to isolate the case where I'm looking at the first bar after 8:30.
I'm not sure I understand what you're getting at. In any case I solved my problem by adding another data stream with 15m interval. It calculates regular session close properly every time. I still need the 30m bars because I'm using them to calculate MP numbers which are also part of my strategy. rsi77 |
|
|
|
|
|
#6 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
Not sure I am following you. If you want the bar after 8:30 just check for time to be equal to the next bar. On 30 minute series that would mean 9:00. On 15 minute that would mean 8:45.
In either case, since you have it resolved we will leave it at that.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Jan 2009
Posts: 114
Thanks: 0
Thanked 0 times in 0 posts
|
OK, I had forgotten that I had "=" instead of ">".
So setting on bar update to false will make it work with 30m bars? Will this mean that the strategy will be slower since it's checking more often? Is there an advantage to keep using 15m bars with "on bar update = true" in terms of speed of the strategy? Thanks. |
|
|
|
|
|
#8 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
CalculateOnBarClose will not change your timestamps. On thirty minute bars Time[0] is always 9:30 for instance. You cannot check 9:15 timestamps on 30 min series because there will be no bars with that timestamp regardless of if you use true or false. You will still need 15min series.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#9 | |
|
Senior Member
Join Date: Jan 2009
Posts: 114
Thanks: 0
Thanked 0 times in 0 posts
|
Quote:
Thanks |
|
|
|
|
|
|
#10 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
Misunderstanding, I suggested you use as a means for you to see exactly what data you have as a check. It does not change anything for the bars. Furthermore it does not change timestamps.
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Put Session Begin and Session End times in chart title | Jim W. | Suggestions And Feedback | 1 | 03-12-2009 03:32 AM |
| Get last regular session date? | suedeuno | General Programming | 1 | 01-12-2009 07:28 AM |
| early close session prior to holiday | traderzbs | Miscellaneous Support | 1 | 12-26-2008 06:41 AM |
| Session times vs Open & Close Times | Laserdan | Charting | 1 | 10-15-2008 05:46 PM |
| Determining "Last Bar On Chart" | NinjaTrader_Ray | General Programming | 2 | 01-16-2007 03:17 PM |