#property strict #property indicator_chart_window #property indicator_buffers 6 //---Indicator Colours #property indicator_color1 clrGreen//UpArrow #property indicator_color2 clrRed//DownArrow #property indicator_color3 clrBlue//BollingerUpper #property indicator_color4 clrBlue//BollingerLower #property indicator_color5 clrWhiteSmoke//EnvelopeUpper #property indicator_color6 clrWhiteSmoke//EnvelopeLower //---Indicator Width #property indicator_width1 2 #property indicator_width2 2 #include <WinUser32.mqh> extern bool show=true;//Show Indicators? extern double EnvelopePercent=50; double UpArrow[]; double DownArrow[]; double BollingerUpper[]; double BollingerLower[]; double EnvelopeUpper[]; double EnvelopeLower[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,UpArrow); SetIndexStyle(0,DRAW_ARROW); SetIndexArrow(0,233); SetIndexLabel(0,"Buy Signal."); //--- SetIndexBuffer(1,DownArrow); SetIndexStyle(1,DRAW_ARROW); SetIndexArrow(1,234); SetIndexLabel(1,"Sell Signal."); //--- SetIndexBuffer(2,BollingerUpper); SetIndexStyle(2,DRAW_LINE); SetIndexLabel(2,"BollingerUpper."); //--- SetIndexBuffer(3,BollingerLower); SetIndexStyle(3,DRAW_LINE); SetIndexLabel(3,"BollingerLower."); //--- SetIndexBuffer(4,EnvelopeUpper); SetIndexStyle(4,DRAW_LINE); SetIndexLabel(4,"EnvelopeUpper."); //--- SetIndexBuffer(5,EnvelopeLower); SetIndexStyle(5,DRAW_LINE); SetIndexLabel(5,"EnvelopeLower."); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //---for loop int counted_bars=IndicatorCounted(); int limit= Bars-counted_bars; for(int i=1;i<limit;i++) { double BolUp=iBands(NULL,0,20,2,0,PRICE_MEDIAN,MODE_UPPER,i); double BolLow=iBands(NULL,0,20,2,0,PRICE_MEDIAN,MODE_LOWER,i); double EnvUp=iEnvelopes(NULL,0,14,MODE_EMA,0,PRICE_MEDIAN,EnvelopePercent,MODE_UPPER,i); double EnvLow=iEnvelopes(NULL,0,14,MODE_EMA,0,PRICE_MEDIAN,EnvelopePercent,MODE_LOWER,i); double ADXMain=iADX(NULL,0,5,PRICE_MEDIAN,MODE_MAIN,i); double ADXPlus=iADX(NULL,0,13,PRICE_MEDIAN,MODE_PLUSDI,i); double ADXMinus=iADX(NULL,0,13,PRICE_MEDIAN,MODE_MINUSDI,i); double Stochastic=iStochastic(NULL,0,14,3,7,MODE_EMA,0,MODE_MAIN,i); double Price=(High[i]+Low[i])/2; double PriceBack=(High[i+1]+Low[i+1])/2; if(show==true) { BollingerUpper[i]=BolUp; BollingerLower[i]=BolLow; EnvelopeUpper[i]=EnvUp; EnvelopeLower[i]=EnvLow; } if(Price>BolUp && Price>EnvUp) { UpArrow[i]=Open[i]; } //if() { //DownArrow[i]=Open[i]; } } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+
It is on the chart! But not where you expect it. ;) Squeeze the chart to its vertical maximum.
Change EnvelopePercent=50; to EnvelopePercent=0.5;
Or devide the 50 by 100 (%)
ok great thanks, I can get it to show now, however it does not redraw when I change the value and recompile. Any suggestions??
mickeyferrari:
ok great thanks, I can get it to show now, however it does not redraw when I change the value and recompile. Any suggestions??
ok great thanks, I can get it to show now, however it does not redraw when I change the value and recompile. Any suggestions??
int i=0;i<=limit
int counted_bars=IndicatorCounted(); int limit= Bars-counted_bars; for(int i=1;i<limit;i++) { double BolUp=iBands(NULL,0,20,2,0,PRICE_MEDIAN,MODE_UPPER,i); double BolLow=iBands(NULL,0,20,2,0,PRICE_MEDIAN,MODE_LOWER,i); double EnvUp=iEnvelopes(NULL,0,14,MODE_EMA,0,PRICE_MEDIAN,EnvelopePercent,MODE_UPPER,i); double EnvLow=iEnvelopes(NULL,0,14,MODE_EMA,0,PRICE_MEDIAN,EnvelopePercent,MODE_LOWER,i); double ADXMain=iADX(NULL,0,5,PRICE_MEDIAN,MODE_MAIN,i); double ADXPlus=iADX(NULL,0,13,PRICE_MEDIAN,MODE_PLUSDI,i); double ADXMinus=iADX(NULL,0,13,PRICE_MEDIAN,MODE_MINUSDI,i); double Stochastic=iStochastic(NULL,0,14,3,7,MODE_EMA,0,MODE_MAIN,i); double Price=(High[i]+Low[i])/2; double PriceBack=(High[i+1]+Low[i+1])/2;Handle your look backs properly. [i+1] is 1 Bands is 20 envelopes is 14, etc. Max=20
int counted_bars=IndicatorCounted(); #define LOOKBACK 20 for(int i = Bars - 1 - MathMax(LOOKBACK, counted_bars); i>=1; --i){
Get in the habit of always counting down.
Why is main=5 but plus/minus 13?
WHRoeder:
Handle your look backs properly. [i+1] is 1 Bands is 20 envelopes is 14, etc. Max=20
Handle your look backs properly. [i+1] is 1 Bands is 20 envelopes is 14, etc. Max=20
Get in the habit of always counting down.
Why is main=5 but plus/minus 13?
MathMax
Maybe MathMin?
because i use it as a MA.....
is this correct ??
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 can anybody suggest why the envelopes are not showing when I drop this on a chart?
I believe I have coded it correctly ??
Thanks