Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Here's some code in an indicator that I am trying to understand (Cycle_Identifier):
============================================
int rnglength = 250;
// pLength is set to 3
double range = 0.0, srange = 0.0;
int j=0;
for (int i=0;i<rnglength;i++) {
if(i>=CurrentBar) break;
j++;
srange = srange + (High[i] - Low[i]);
}
range = srange / j * pLength;
====================================================
1) Looks to me like for each bar, the indicator is recalculation for the last 250 bars, the cumulative bar range (H - L) / 750
Is that right?
2) the code tests to be sure there are at least 250 bars on chart
(if(CurrentBar<rnglength) return; ),
so why is "if(i>=CurrentBar) break;" necessary?
Can you help answer these questions from other members on NexusFi?
1) it calculates average range of the last 250 bars x 3;
2) my guess is code blew up when bar < 250
then other code was put in to fix that error but the old code didn't get taken out.
The formula should be "range = (srange / j) * pLength+.000001;" (which I have changed it to); or simply not allow a value of pLength = 0; it is initialized to '3' but user changeable.
however it strikes me as very inefficient. First off, for a range chart, it will remain virtually constant (esp across 250 bars); secondly, even on a tick, volume or minute bar, could one calculate srange by subtracting the value 250 bars ago and adding in the current value rather than summing 250 values on each bar?