((High-Bollinger)/(High-Low))*100
CB
cloudbreaker:
((High-Bollinger)/(High-Low))*100
CB
double BollValueUpper = iBands(NULL,0,20,2,0,PRICE_CLOSE,MODE_UPPER,0); double BollValueLower = iBands(NULL,0,20,2,0,PRICE_CLOSE,MODE_LOWER,0); double CandleHeight = MathAbs(High[0] - Low[0]); if (Bid>BollValueUpper) {CandlePercentage = (High[0]-BollValueUpper/CandleHeight)*100;} if (Bid<BollValueLower) {CandlePercentage = (BollValueLower-Low[0]/CandleHeight)*100;} Comment ("Current candle % +/- to band " + DoubleToStr(CandlePercentage,2));
If I wanted to also calculate this for the previous candle, do I have to add a bollinger buffer?
SanMiguel:
If I wanted to also calculate this for the previous candle, do I have to add a bollinger buffer?
I am getting some weird values for the candlepercentage in this code?????
double BollValueUpper ; double BollValueLower ; if (Period() == PERIOD_H1) { BollValueUpper = iBands(NULL,PERIOD_H1,20,2,0,PRICE_CLOSE,MODE_UPPER,0); BollValueLower = iBands(NULL,PERIOD_H1,20,2,0,PRICE_CLOSE,MODE_LOWER,0); } if (Period() == PERIOD_M15) { BollValueUpper = iBands(NULL,PERIOD_M15,20,2,0,PRICE_CLOSE,MODE_UPPER,0); BollValueLower = iBands(NULL,PERIOD_M15,20,2,0,PRICE_CLOSE,MODE_LOWER,0); } double CandleHeight = MathAbs(High[0] - Low[0]); if (High[0]>BollValueUpper) {CandlePercentage = (High[0]-BollValueUpper/CandleHeight)*100;} if (Low[0]<BollValueLower) {CandlePercentage = (BollValueLower-Low[0]/CandleHeight)*100;} Comment ("High="+DoubleToStr(High[0],5)+ "\nHigh-Boll="+DoubleToStr(High[0]-BollValueUpper,5)+ "\nCandle height: "+DoubleToStr(CandleHeight,5)+ "\nCurrent candle % outside band " + DoubleToStr(CandlePercentage,2)); }
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
Is there a way we could calculate the percentage of a candle outside a bollinger band?
For example, an upper bollinger band is at 1.5000 and a candle moves outside of this value to a high of 1.5020 and the low was 1.4990.
Do we just calculate the height of the candle and how much of this is above the bollinger?