Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Calculate High for every x minutes
Collapse
X
-
After much thought about how to implement DateTime.Now I don't think it is going to work. It can potentially work for incoming ticks, but for any historical data it simply can't be done to count 3 minutes because the DateTime.Now in accessing the historical data are all the same.
Here is what I came up with, but its just not cutting it.
Code:if(Bars.FirstBarOfSession) { time = Time[0]; timecounter = time; } if (barcounter <= 1) { ticktimer = DateTime.Now; } else { prevticktimer = ticktimer; ticktimer = DateTime.Now; } if(timecounter < time.AddMinutes(Period)) { if(high<High[0]) high = High[0]; TimeSpan valuetoadd = ticktimer - prevticktimer; timecounter = timecounter.AddSeconds(valuetoadd.Minutes*60 + valuetoadd.Seconds); } DynamicR = high; Resistance.Set(DynamicR);Josh P.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by CaptainJack, 05-29-2026, 05:09 AM
|
0 responses
262 views
0 likes
|
Last Post
by CaptainJack
05-29-2026, 05:09 AM
|
||
|
Started by CaptainJack, 05-29-2026, 12:02 AM
|
0 responses
168 views
0 likes
|
Last Post
by CaptainJack
05-29-2026, 12:02 AM
|
||
|
Started by charlesugo_1, 05-26-2026, 05:03 PM
|
0 responses
170 views
1 like
|
Last Post
by charlesugo_1
05-26-2026, 05:03 PM
|
||
|
Started by DannyP96, 05-18-2026, 02:38 PM
|
1 response
257 views
0 likes
|
Last Post
|
||
|
Started by CarlTrading, 05-11-2026, 05:56 AM
|
0 responses
209 views
0 likes
|
Last Post
by CarlTrading
05-11-2026, 05:56 AM
|

Comment