int x=0; //Make the value 1 if you only want to check closed bars while (x<100) { if(CCI_buffer[x]>100) break; x++; } //x=the shift that you want
.
ok, this code is particle works. but... I need to make the function for each column return its own value.
for example:
- last value bigger than 150 is on bar[10], next last is on bar[20]
and function return for
- bar[0] - 10
- bar[1] - 9
- bar[2] - 8
- ....
- bar[10] - 0
until this point the function works well
the problem occurs after bar[10]. the function returns for each additional bar 0 (bar[11] - 0, bar[12] - 0,...)
I need this:
- bar[11] - 9
- bar[12] - 8
- ....
- bar[20] - 0
I tried everything possible but without result. I do not know where I'm making a mistake. I need it for the test (to see the last value for each bar). In live trading it works well.
my code:
for(int i = limit-1; i >= 0; i--) { int x = 0; while (x <= 100) { //search in last 100 bars if(CCI_buffer[x] > 150){ //if CCI is bigger than 150 last_bar[i] = 0; break; } x++; } if(x-i <= 0){ last_long[i] = 0; } else if(x == 100) { last_long[i] = NULL; } else { last_long[i] = x-i; } }
no idea anyone?
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi all,
I try to insert a variable into the custom indicator that returns to me the closest (lowest) BAR index (for example CCI) where value is greater than 100.
example:
For last 10 bars CCI have values [0, 50, 50, 20, 50, 99, 103, 102, 101, 0]
For this example shift = 6;
Any idea?