Below things I see:
As per your code, single for loop will suffice..It should looks something like this:
for(x = 0; x < limit; x++) { bandup_1 = iBands(NULL,0,20,1,bands_shift,applied_price,MODE_UPPER,x); banddn_1 = iBands(NULL,0,20,1,bands_shift,applied_price,MODE_LOWER,x); if( iClose(NULL,0,x) <= bandup_1 && iClose(NULL,0,x) >= banddn_1 ) { s1[x] = 1; } if(TimeFrame2bool) { bandup_1 = iBands(NULL,TimeFrame2,20,1,bands_shift,applied_price,MODE_UPPER,iBarShift(NULL, TimeFrame2, Time[x], false)); banddn_1 = iBands(NULL,TimeFrame2,20,1,bands_shift,applied_price,MODE_LOWER,iBarShift(NULL, TimeFrame2, Time[x], false)); if( iClose(NULL,TimeFrame2,x) <= bandup_1 && iClose(NULL,TimeFrame2,x) >= banddn_1 ) { s2[x] = 1; } } if(TimeFrame3bool) { if( s1[x] == 1 && s2[x] == 1 ) { s3[x] = 1; } } }
In below
iClose(NULL,TimeFrame2,x)
change x to iBarShift, since its on different timeframe. Also add debug statements e.g. print in your code, to check if its returning correct value. Just for testing, set limit to small amount, say 20.
dineshydv:
Below things I see:
As per your code, single for loop will suffice..It should looks something like this:
In below
change x to iBarShift, since its on different timeframe. Also add debug statements e.g. print in your code, to check if its returning correct value. Just for testing, set limit to small amount, say 20.
Get it!
Thanks a lot!
bandup_1 = iBands(NULL,TimeFrame2,20,1,bands_shift,applied_price,MODE_UPPER,iBarShift(NULL, TimeFrame2, Time[x], false)); banddn_1 = iBands(NULL,TimeFrame2,20,1,bands_shift,applied_price,MODE_LOWER,iBarShift(NULL, TimeFrame2, Time[x], false)); if( iClose(NULL,TimeFrame2,x) <= bandup_1 && iClose(NULL,TimeFrame2,x)If you stop writeing unreadable code you would see the problem.
double GetBand(int eTF, int iTF, int eMODE){ // Hide common, non changing, external values. return( iBands(NULL,eTF,20,1,bands_shift,applied_price,eMODE,iTF) ); } //////////// int iBar = x; // Use readable names. The chart's bar index. 'x' says nothing and in mathematics a double. int iTF2 = iBarShift(NULL, TimeFrame2, Time[iBar]); double bandup_1 = GetBand(TimeFrame2, iTF2, MODE_UPPER), banddn_1 = GetBand(TimeFrame2, iTF2, MODE_LOWER), closeTF2 = iClose(NULL, TimeFrame2, iBar); // <--- TimeFrame2 and iBAR are NOT compatible // TimeFrame2 and iTF2 ARE compatible if (closeTF2 <= bandup_1 && closeTF2 ...
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
Dear all
I wrote an indicator to look for following condition:
If price is within ibands(deviation 1, upper) and ibands(deviation 1, lower) for 2 timeframes, give me a "1" result.
However, it doesn't work when I put it on GBPUSD H1 chart. Can anybody tell me how to fix it?
Thanks a lot!
wing