I am new to this language ( mql4 ) and so forgive me for my errors
With Prorealtime I have created this indicator ( a sort of autoenevelope bands ) :
where
factor = 27
This is my try with mql4 :
The indicator returns only the EMA, but don't the bands.
Possible errors ?
Writing High[x] and Low[x], MT4 does calcolate the low and the high of the candle ?
Thanks for any help
With Prorealtime I have created this indicator ( a sort of autoenevelope bands ) :
Inserted Code
mov=ExponentialAverage[20](close) b=abs(high-mov) c=abs(low-mov) d=max(b,c) e=(2*d)/mov f=STD[100](e) g=(f*factor)/10 h=g*mov upperband=mov+h/2 lowerband=mov-h/2 RETURN mov, upperband, lowerband
where
factor = 27
This is my try with mql4 :
Inserted Code
//+------------------------------------------------------------------+ //| autoenvelope bands.mq4 | //| | //| Copyright | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright " #property link "http://" //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ #property indicator_chart_window #property indicator_buffers 3 #property indicator_color1 White #property indicator_color2 White #property indicator_color3 White double upper[], middle[], lower[]; extern int MA_PERIOD = 20; extern int MA_MODE = 0; extern int PRICE_MODE = 5; extern int factor = 27; double b; double c; double d; double e; double f; double g; double h; int init() { SetIndexStyle(0,DRAW_LINE); SetIndexShift(0,0); SetIndexDrawBegin(0,0); SetIndexBuffer(0,upper); SetIndexStyle(1,DRAW_LINE,STYLE_DOT); SetIndexShift(1,0); SetIndexDrawBegin(1,0); SetIndexBuffer(1,middle); SetIndexStyle(2,DRAW_LINE); SetIndexShift(2,0); SetIndexDrawBegin(2,0); SetIndexBuffer(2,lower); //---- indicators //---- return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int limit; int counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; for(int x=0; x<limit; x++) { middle[x] = iMA(NULL, 0, MA_PERIOD, 0, MA_MODE, PRICE_MODE, x); b = MathAbs(High[x]-middle[x]); c = MathAbs(Low[x]-middle[x]); d=MathMax(b,c); e=(2*d)/middle[x]; f=iStdDev(e,0,100,0,MODE_EMA,0,x); g=(f*factor)/10; h=g*middle[x]; upper[x] = middle[x] + h/2; lower[x] = middle[x] - h/2; } return(0); }
The indicator returns only the EMA, but don't the bands.
Possible errors ?
Inserted Code
b = MathAbs(High[x]-middle[x]); c = MathAbs(Low[x]-middle[x]);
Writing High[x] and Low[x], MT4 does calcolate the low and the high of the candle ?
Thanks for any help