Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Multi timeframe - current day
Collapse
X
-
I commented out the BIP 0 and 2 conditionals - and BIP = 1 did show up.
I then cleared the output, removed the comments, and ran the strategy.
This is the complete output:
BIP = 1 only shows up as the very first entry.BIP = 1: 2/1/2010 2:00:00 PM; 2/2/2010 12:00:00 AM; 2/1/2010 2:00:00 PM
BIP = 0: 2/2/2010 7:35:00 AM; 2/2/2010 12:00:00 AM; 2/1/2010 2:00:00 PM
BIP = 2: 2/2/2010 7:35:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 7:35:00 AM
BIP = 0: 2/2/2010 7:40:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 7:35:00 AM
BIP = 2: 2/2/2010 7:40:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 7:40:00 AM
BIP = 0: 2/2/2010 7:45:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 7:40:00 AM
BIP = 2: 2/2/2010 7:45:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 7:45:00 AM
BIP = 0: 2/2/2010 7:50:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 7:45:00 AM
BIP = 2: 2/2/2010 7:50:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 7:50:00 AM
BIP = 0: 2/2/2010 7:55:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 7:50:00 AM
BIP = 2: 2/2/2010 7:55:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 7:55:00 AM
BIP = 0: 2/2/2010 8:00:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 7:55:00 AM
BIP = 2: 2/2/2010 8:00:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 8:00:00 AM
BIP = 0: 2/2/2010 8:05:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 8:00:00 AM
BIP = 2: 2/2/2010 8:05:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 8:05:00 AM
BIP = 0: 2/2/2010 8:10:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 8:05:00 AM
BIP = 2: 2/2/2010 8:10:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 8:10:00 AM
BIP = 0: 2/2/2010 8:15:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 8:10:00 AM
BIP = 2: 2/2/2010 8:15:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 8:15:00 AM
BIP = 0: 2/2/2010 8:20:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 8:15:00 AM
BIP = 2: 2/2/2010 8:20:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 8:20:00 AM
BIP = 0: 2/2/2010 8:25:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 8:20:00 AM
BIP = 2: 2/2/2010 8:25:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 8:25:00 AM
BIP = 0: 2/2/2010 8:30:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 8:25:00 AM
BIP = 2: 2/2/2010 8:30:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 8:30:00 AM
BIP = 0: 2/2/2010 8:35:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 8:30:00 AM
BIP = 2: 2/2/2010 8:35:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 8:35:00 AM
BIP = 0: 2/2/2010 8:40:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 8:35:00 AM
BIP = 2: 2/2/2010 8:40:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 8:40:00 AM
BIP = 0: 2/2/2010 8:45:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 8:40:00 AM
BIP = 2: 2/2/2010 8:45:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 8:45:00 AM
BIP = 0: 2/2/2010 8:50:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 8:45:00 AM
BIP = 2: 2/2/2010 8:50:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 8:50:00 AM
BIP = 0: 2/2/2010 8:55:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 8:50:00 AM
BIP = 2: 2/2/2010 8:55:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 8:55:00 AM
BIP = 0: 2/2/2010 9:00:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 8:55:00 AM
BIP = 2: 2/2/2010 9:00:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 9:00:00 AM
BIP = 0: 2/2/2010 9:05:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 9:00:00 AM
BIP = 2: 2/2/2010 9:05:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 9:05:00 AM
BIP = 0: 2/2/2010 9:10:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 9:05:00 AM
BIP = 2: 2/2/2010 9:10:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 9:10:00 AM
BIP = 0: 2/2/2010 9:15:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 9:10:00 AM
BIP = 2: 2/2/2010 9:15:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 9:15:00 AM
BIP = 0: 2/2/2010 9:20:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 9:15:00 AM
BIP = 2: 2/2/2010 9:20:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 9:20:00 AM
BIP = 0: 2/2/2010 9:25:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 9:20:00 AM
BIP = 2: 2/2/2010 9:25:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 9:25:00 AM
BIP = 0: 2/2/2010 9:30:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 9:25:00 AM
BIP = 2: 2/2/2010 9:30:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 9:30:00 AM
BIP = 0: 2/2/2010 9:35:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 9:30:00 AM
BIP = 2: 2/2/2010 9:35:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 9:35:00 AM
BIP = 0: 2/2/2010 9:40:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 9:35:00 AM
BIP = 2: 2/2/2010 9:40:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 9:40:00 AM
BIP = 0: 2/2/2010 9:45:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 9:40:00 AM
BIP = 2: 2/2/2010 9:45:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 9:45:00 AM
BIP = 0: 2/2/2010 9:50:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 9:45:00 AM
BIP = 2: 2/2/2010 9:50:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 9:50:00 AM
BIP = 0: 2/2/2010 9:55:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 9:50:00 AM
BIP = 2: 2/2/2010 9:55:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 9:55:00 AM
BIP = 0: 2/2/2010 10:00:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 9:55:00 AM
BIP = 2: 2/2/2010 10:00:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 10:00:00 AM
BIP = 0: 2/2/2010 10:05:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 10:00:00 AM
BIP = 2: 2/2/2010 10:05:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 10:05:00 AM
BIP = 0: 2/2/2010 10:10:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 10:05:00 AM
BIP = 2: 2/2/2010 10:10:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 10:10:00 AM
BIP = 0: 2/2/2010 10:15:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 10:10:00 AM
BIP = 2: 2/2/2010 10:15:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 10:15:00 AM
BIP = 0: 2/2/2010 10:20:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 10:15:00 AM
BIP = 2: 2/2/2010 10:20:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 10:20:00 AM
BIP = 0: 2/2/2010 10:25:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 10:20:00 AM
BIP = 2: 2/2/2010 10:25:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 10:25:00 AM
BIP = 0: 2/2/2010 10:30:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 10:25:00 AM
BIP = 2: 2/2/2010 10:30:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 10:30:00 AM
BIP = 0: 2/2/2010 10:35:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 10:30:00 AM
BIP = 2: 2/2/2010 10:35:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 10:35:00 AM
BIP = 0: 2/2/2010 10:40:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 10:35:00 AM
BIP = 2: 2/2/2010 10:40:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 10:40:00 AM
BIP = 0: 2/2/2010 10:45:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 10:40:00 AM
BIP = 2: 2/2/2010 10:45:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 10:45:00 AM
BIP = 0: 2/2/2010 10:50:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 10:45:00 AM
BIP = 2: 2/2/2010 10:50:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 10:50:00 AM
BIP = 0: 2/2/2010 10:55:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 10:50:00 AM
BIP = 2: 2/2/2010 10:55:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 10:55:00 AM
BIP = 0: 2/2/2010 11:00:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 10:55:00 AM
BIP = 2: 2/2/2010 11:00:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 11:00:00 AM
BIP = 0: 2/2/2010 11:05:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 11:00:00 AM
BIP = 2: 2/2/2010 11:05:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 11:05:00 AM
BIP = 0: 2/2/2010 11:10:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 11:05:00 AM
BIP = 2: 2/2/2010 11:10:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 11:10:00 AM
BIP = 0: 2/2/2010 11:15:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 11:10:00 AM
BIP = 2: 2/2/2010 11:15:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 11:15:00 AM
BIP = 0: 2/2/2010 11:20:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 11:15:00 AM
BIP = 2: 2/2/2010 11:20:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 11:20:00 AM
BIP = 0: 2/2/2010 11:25:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 11:20:00 AM
BIP = 2: 2/2/2010 11:25:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 11:25:00 AM
BIP = 0: 2/2/2010 11:30:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010 11:25:00 AM
BIP = 2: 2/2/2010 11:30:00 AM; 2/2/2010 12:00:00 AM; 2/2/2010
EDIT: I had to remove text so the entry would post. I removed it from the bottom of the output.
EDIT #2: I pasted everything into notepad and did a search for BIP = 1; it looks like it prints as the first/last entry on the new/old date.Last edited by Day Trading Fool; 02-11-2010, 10:59 AM.
Comment
-
This has been a pretty confusing ordeal.
I put together this bit of code:
The output is in the attachment. I used minutes as primary, then day as primary, and mins second and week third, then day primary, week second and minutes third.Code:if (BarsInProgress == 0) { Print ("BIP = 0: "+BarsPeriods[0].Id+": " +Times[0][0] + "; 1 = "+BarsPeriods[1].Id+": "+Times[1][0]+"; 2 = "+BarsPeriods[2].Id+": "+Times[2][0]); } if (BarsInProgress == 1) { Print ("BIP = 1: "+BarsPeriods[0].Id+": " +Times[0][0] + "; 1 = "+BarsPeriods[1].Id+": "+Times[1][0]+"; 2 = "+BarsPeriods[2].Id+": "+Times[2][0]); } if (BarsInProgress == 2) { Print ("BIP = 2: "+BarsPeriods[0].Id+": " +Times[0][0] + "; 1 = "+BarsPeriods[1].Id+": "+Times[1][0]+"; 2 = "+BarsPeriods[2].Id+": "+Times[2][0]); }
It looks like the order of declaration makes no difference. Well, not really any difference. NT processes the primary first, and then the shortest interval, up until it bumps into the next longest interval (red cells), and then processes the shortest interval until it reaches the next longest interval again - and THEN updates the next longest (green cells); and then reverts back to processing the shortest.
It appears that the only time NT is able to access the minutes within the current day is the very first iteration - dependent upon the order of declaration. That seems weird: i.e., changing the order of processing after the first day.
Anyhoo - this is mostly about clarifying it for myself, but I am still going to try and access the minutes for the current test day - maybe by indexing backwards or something...
If something looks wrong here, don't hesitate to let me know. Or if you can think of an easy way for me to write this up. Thanks for the help.
Comment
-
Day Trading Fool,
Your screenshot was too small to be read.
This is how it works very simply:
BIP0 = Week
BIP1 = Day
BIP2 = Min
2/5 BIP0 Week update
2/5 BIP1 Day update
2/5 BIP2 Min 9:30
2/5 BIP2 Min 10:30
2/5 BIP2 Min 11:30 etc.
...
2/8 BIP1 Day update
2/8 BIP2 Min 9:30
2/8 BIP2 Min 10:30 etc.
...
2/9 BIP1 Day
2/9 BIP2 Min 9:30
2/9 BIP2 Min 10:30 etc.
...
...
2/12 BIP0 Week
2/12 BIP1 Day
2/12 BIP2 Min 9:30
2/12 BIP2 Min 10:30 etc.
When working from BIP2 you will have the correctly updated week and day contexts when series are added in the order described above.Josh P.NinjaTrader Customer Service
Comment
-
Same topic, but a different approach.
I am trying to calculate mid-bar (weekly) EMA using something along the lines of:
EMA = Price(t) * k + EMA(y) * (1 – k)
Where Price(t) is the day's close and EMA(y) is the EMA for the week prior. I seem to have run into a problem in code execution. Here is what I am trying to use (on BIP == 0):
The results come out as:Code:testVar = Close[0]*(2/11) + EMA(Closes[1],10).Value[0]*(1-2/11); Print (Time[0]+"; "+Close[0]+"; "+EMA(Closes[1],10).Value[0]+"; "+testVar);
1/11/2010 12:00:00 AM; 31.64; 29.0900480330482; 29.0900480330482
1/12/2010 12:00:00 AM; 31.17; 29.0900480330482; 29.0900480330482
1/13/2010 12:00:00 AM; 31.32; 29.0900480330482; 29.0900480330482
1/14/2010 12:00:00 AM; 31.65; 29.0900480330482; 29.0900480330482
1/15/2010 12:00:00 AM; 30.66; 29.0900480330482; 29.0900480330482
1/19/2010 12:00:00 AM; 30.89; 29.3754938452212; 29.3754938452212
1/20/2010 12:00:00 AM; 30.69; 29.3754938452212; 29.3754938452212
1/21/2010 12:00:00 AM; 30.67; 29.3754938452212; 29.3754938452212
1/22/2010 12:00:00 AM; 29.66; 29.3754938452212; 29.3754938452212
1/25/2010 12:00:00 AM; 29.96; 29.4272222369992; 29.4272222369992
1/26/2010 12:00:00 AM; 29.25; 29.4272222369992; 29.4272222369992
1/27/2010 12:00:00 AM; 29.06; 29.4272222369992; 29.4272222369992
1/28/2010 12:00:00 AM; 29.56; 29.4272222369992; 29.4272222369992
1/29/2010 12:00:00 AM; 30.2; 29.4272222369992; 29.4272222369992
2/1/2010 12:00:00 AM; 30.49; 29.5677272848175; 29.5677272848175
2/2/2010 12:00:00 AM; 30.88; 29.5677272848175; 29.5677272848175
2/3/2010 12:00:00 AM; 30.83; 29.5677272848175; 29.5677272848175
2/4/2010 12:00:00 AM; 29.06; 29.5677272848175; 29.5677272848175
2/5/2010 12:00:00 AM; 28.88; 29.5677272848175; 29.5677272848175
As you can see, the testVar value is not changing on a daily basis.
To test, I used this code:
And received this output:Code:testVar = Close[0]*0.18 + EMA(Closes[1],10).Value[0]*0.82; Print (Time[0]+"; "+Close[0]+"; "+EMA(Closes[1],10).Value[0]+"; "+testVar);
1/11/2010 12:00:00 AM; 31.64; 29.0900480330482; 29.5490393870995
1/12/2010 12:00:00 AM; 31.17; 29.0900480330482; 29.4644393870995
1/13/2010 12:00:00 AM; 31.32; 29.0900480330482; 29.4914393870995
1/14/2010 12:00:00 AM; 31.65; 29.0900480330482; 29.5508393870995
1/15/2010 12:00:00 AM; 30.66; 29.0900480330482; 29.3726393870995
1/19/2010 12:00:00 AM; 30.89; 29.3754938452212; 29.6481049530814
1/20/2010 12:00:00 AM; 30.69; 29.3754938452212; 29.6121049530814
1/21/2010 12:00:00 AM; 30.67; 29.3754938452212; 29.6085049530814
1/22/2010 12:00:00 AM; 29.66; 29.3754938452212; 29.4267049530814
1/25/2010 12:00:00 AM; 29.96; 29.4272222369992; 29.5231222343393
1/26/2010 12:00:00 AM; 29.25; 29.4272222369992; 29.3953222343393
1/27/2010 12:00:00 AM; 29.06; 29.4272222369992; 29.3611222343393
1/28/2010 12:00:00 AM; 29.56; 29.4272222369992; 29.4511222343393
1/29/2010 12:00:00 AM; 30.2; 29.4272222369992; 29.5663222343393
2/1/2010 12:00:00 AM; 30.49; 29.5677272848175; 29.7337363735504
2/2/2010 12:00:00 AM; 30.88; 29.5677272848175; 29.8039363735504
2/3/2010 12:00:00 AM; 30.83; 29.5677272848175; 29.7949363735504
2/4/2010 12:00:00 AM; 29.06; 29.5677272848175; 29.4763363735504
2/5/2010 12:00:00 AM; 28.88; 29.5677272848175; 29.4439363735504
The testVar value changes on a daily basis.
2/11 = 0.1818181818...
The 11 is actually dependent on the EMA period otherwise I would just use a constant. Any idea what is going on?
Thanks for the help.
Comment
-
-
Hi there, I've verified what you're saying and I have sent it along for further analysis. I'm not sure where/why it isn't calculating every OnBarUpdate() like it should, but I have an idea for a workaround while we figure out what is happening.
}Code:// in vars, try these variable types: double, float, and decimal private double testValue; OnBarUpdate() { if (CurrentBar == 0) testValue = 2 / ema_period //not sure if that's exactly what you're using but you can adjust it if necessary if (BarsInProgress == 0) { testVar = Close[0] * testValue + EMA(Closes[1],10).Value[0] * (1 - testValue); Print(Time[0] + "; " + Close[0] + "; " + EMA(Closes[1],10).Value[0] + "; " + testVar); } }AustinNinjaTrader Customer Service
Comment
-
Comment
-
Day Trading Fool,
To clarify, this is expected Microsoft C# behavior. You cannot divide 2/11 and stuff it into a double. You need to cast them as doubles to begin with if you are trying to stuff it into a double.
(double) 2 / (double) 11
or you could just do
2.0 / 11.0Josh P.NinjaTrader Customer Service
Comment
-
Neither of those seemed to offer a solution to the daily bar update.
I.e. - I cast the 2 and 11 as doubles and still no daily update.
I set 2 to 2.0 and 11 to 11.0 and no daily update.
I use the 0.18 and 0.82 values and the output prints the daily update.
Thanks!
Comment
-
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
671 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
379 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
111 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
575 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
582 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment