Hi Y'all
I'm trying to modify the 9ofX indi from dwain to show divergences. I've been using a CCI divergence indicator as a template. I've included it for clarity
I keep getting array out of range during the divergence routine but for the life of me I cant work out what the hell is going on.
Printing the indexes to the terminal shows that there are enough data points in the array.
The 9ofX indi used was v2.
Cheers
Array out of Range Divergence Indicator
-
BobbyT
- Trader
- Posts: 232
- Joined: Thu Aug 21, 2014 1:34 am
- Location: Seattle
Array out of Range Divergence Indicator
You do not have the required permissions to view the files attached to this post.
Procrastination provides exponentially negative returns - BobbyT
- SteveHopwood
- Owner
- Posts: 9904
- Joined: Tue Nov 15, 2011 8:43 am
- Location: Misterton - an insignificant village in England. Very pleasant to live in.
Array out of Range Divergence Indicator
Just so you know, I have read your post several times and still have no idea what you are talking about.BobbyT » Sun Feb 24, 2019 11:14 pm wrote:Hi Y'all
I'm trying to modify the 9ofX indi from dwain to show divergences. I've been using a CCI divergence indicator as a template. I've included it for clarity
I keep getting array out of range during the divergence routine but for the life of me I cant work out what the hell is going on.
Printing the indexes to the terminal shows that there are enough data points in the array.
The 9ofX indi used was v2.
Cheers
I am a bit on the thick side of thingies. Even so, those on the brighter side of thingies might need you to be a tad on the clearer side of thingies if they are going to be able to help.
Read the effing manual, ok?
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.
Afterprime is the official SHF broker. Read about them at https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?p=175790#p175790.
I still suffer from OCCD. Good thing, really.
Anyone here feeling generous? My paypal account is always in the market for a tiny donation. pianodoodler@hotmail.com is the account.
To see The Weekly Roundup of stuff you guys might have missed Click here
My special thanks to Thomas (tomele) for all the incredible work he does here.
-
BobbyT
- Trader
- Posts: 232
- Joined: Thu Aug 21, 2014 1:34 am
- Location: Seattle
Array out of Range Divergence Indicator
Fair point Steve. I'll see if I can't make this a bit easier for everyone.
I'm trying to combine the attached cci indicator with the attached 9ofX indicator. This is the result of some toying I have done with 9ofX/price divergence and scalping on the short time frames.
I thought it would be as easy as just swapping out the calls to CCI in the divergence indicator but as I'm sure you can appreciate, indis be a strange beast wto tame.
If this still doesn't make sense then I can always try again haha
Cheers
Edit: the array out of range error appears linked to Strengthbuffer being accessed when trying to find the most recent trough.....am I helping.....probably not.....
I'm trying to combine the attached cci indicator with the attached 9ofX indicator. This is the result of some toying I have done with 9ofX/price divergence and scalping on the short time frames.
I thought it would be as easy as just swapping out the calls to CCI in the divergence indicator but as I'm sure you can appreciate, indis be a strange beast wto tame.
If this still doesn't make sense then I can always try again haha
Cheers
Edit: the array out of range error appears linked to Strengthbuffer being accessed when trying to find the most recent trough.....am I helping.....probably not.....
Procrastination provides exponentially negative returns - BobbyT
- renexxxx
- Trader
- Posts: 860
- Joined: Sat Dec 31, 2011 3:48 am
Array out of Range Divergence Indicator
Hi BobbyT,
You might want to have a look at this loop:
The j variable will iterate up to (and including) Bars-1. However, you access Strengthbuffer[j+2], which means (when j reaches Bars-1), that you access Strengthbuffer[Bars+1]. Strengthbuffer is an automatic array, created by the indicator and has only Bars elements, indexed from 0 to Bars-1. So, the index Bars+1 for Strengthbuffer is out of range.
Hope this helps.
Rene.
You might want to have a look at this loop:
Code: Select all
for (int j = i; j < Bars; j++)
{
Print("i: " + i + "; j: " + j + "; Bars: " + Bars + "; Strengthbuffer size: " + ArraySize(Strengthbuffer));
if(Strengthbuffer[j] <= Strengthbuffer[j+1] && Strengthbuffer[j] < Strengthbuffer[j+2] &&
Strengthbuffer[j] <= Strengthbuffer[j-1] && Strengthbuffer[j] < Strengthbuffer[j-2])
return(j);
}Hope this helps.
Rene.
-
BobbyT
- Trader
- Posts: 232
- Joined: Thu Aug 21, 2014 1:34 am
- Location: Seattle
Array out of Range Divergence Indicator
Thanks for dropping in Rene.
So changing (to accommodate for the shift issue you pointed out) hangs the terminal. There is no spike in memory usage from the terminal but I'm guessing it's too much for it to handle.
Changing (currently set at 1000) results in a new array out or range error (but at least doesn't hang the terminal). This is generated by (the previous offender) as it fails to find a trough and therefore returns -1. Arrays don't have -1 elements, at least not last time I checked 
So the question now becomes....what on earth is wrong with this indi? The original CCI divergence indicator that I have been using finds divergences just fine. Why on earth the peak/trough logic no longer works with a different line has me beat :/
So changing
Code: Select all
Bars to Bars-2Changing
Code: Select all
Bars to BarsToDrawCode: Select all
GetIndicatorLastTroughSo the question now becomes....what on earth is wrong with this indi? The original CCI divergence indicator that I have been using finds divergences just fine. Why on earth the peak/trough logic no longer works with a different line has me beat :/
Procrastination provides exponentially negative returns - BobbyT