Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Hourly CPR Indicator feedback
Collapse
X
-
Tags: None
-
I need to add a bit more to this post. In particular it's working great. My formula for calculating the CPR for the previous1H period and displaying it on the current 1H period is as follows:
Pivot = ((Highs[1][0] + Lows[1][0] + Closes[1][0]) / 3);
Bcpr = ((Highs[1][0] + Lows[1][0]) / 2 );
Tcpr = (Pivot - Bcpr + Pivot);
I'm confused as to why the [1][0] calculates the previous 1H bar rather than the current. I'd like to calculate the current 1H bar so I can display it ahead of the current 1H period. I would think that should be [1][0] and the previous 1H would be [1][1]. I have a secondary series as AddDataSeries(Data.BarsPeriodType.Minute, 60); Maybe I'm way off on how this should be done.
-
Hello abandonedBaby,
Thanks for your post.
Highs[1][0] would refer to the current bar high price of the first added secondary series in the script. A BarSeriesIndex of 1 would refer to the first added secondary series in your script. BarsAgo 0 refers to the current bar's High price.
Highs[1][1] would refer to the previous bar's high price of the first added secondary series in the script.
Note if your indicator is set to use Calculate.OnBarClose, OnBarUpdate() logic only processes at the close of a bar. This means that Highs[1][0] would refer to the high price of the most recently closed bar of the first added secondary series.
See this help guide page about Highs: https://ninjatrader.com/support/help.../nt8/highs.htm
See this help guide page about Calculate: https://ninjatrader.com/support/help.../calculate.htm
See this help guide page about working with Multi-TimeFrame/Multi-Instrument NinjaScripts: https://ninjatrader.com/support/help...nstruments.htm
I recommend adding debugging prints to your script that prints out all the values being used for calculations to understand exactly how the logic in your script is evaluating.
Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).
Below is a link to a forum post that demonstrates how to use prints to understand behavior.
<span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
612 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
355 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
105 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
561 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
564 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment