Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
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.
Brandon H.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by fx.practic, 10-15-2013, 12:53 AM
|
5 responses
5,406 views
0 likes
|
Last Post
by Bidder
Today, 12:22 AM
|
||
Started by Shai Samuel, 07-02-2022, 02:46 PM
|
4 responses
98 views
0 likes
|
Last Post
by Bidder
Today, 12:11 AM
|
||
Started by DJ888, Yesterday, 10:57 PM
|
0 responses
8 views
0 likes
|
Last Post
by DJ888
Yesterday, 10:57 PM
|
||
Started by MacDad, 02-25-2024, 11:48 PM
|
7 responses
160 views
0 likes
|
Last Post Yesterday, 10:23 PM | ||
Started by Belfortbucks, Yesterday, 09:29 PM
|
0 responses
9 views
0 likes
|
Last Post
by Belfortbucks
Yesterday, 09:29 PM
|
Comment