Somewhere in your code I think you need to use Period() for the moving average.
hmrt135:
Hi,
in attachment you see the source code of custom Moving average. I want to change it so that two Moving averages with several Periods combines together but the output shows only 1 Buffer. For example i have this changes for SMA mode like below:
please help me what is here wrong or what should changes here?
Hi Hmrt...
#property indicator_buffers 1
Change the above line to 3 to get all 3 buffers.
#property indicator_buffers 3
Recompile and run the indicator and that should work for you.
Hope that helps,
Robert
cosmicbeing:
Hi Hmrt...
Change the above line to 3 to get all 3 buffers.
Recompile and run the indicator and that should work for you.
Hope that helps,
Robert
Thank you, I change the code like below and worked well.
//+------------------------------------------------------------------+ //| | //| Hamirta MA.mq4 | //+------------------------------------------------------------------+ #property link "Hamirta" #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 Red #property indicator_color2 Blue extern int MA_Period_1 = 13; extern int MA_Period_2 = 12; extern int MA_Type_1 = MODE_SMA; extern int MA_Type_2 = MODE_SMA; extern int MA_Shift1 =0; extern int MA_Shift2 =0; double UpBuffer1[]; double UpBuffer2[]; double CLOSE[]; double ma_1,ma_2; int init() { IndicatorBuffers(3); // SetIndexStyle(0,DRAW_HISTOGRAM, STYLE_SOLID,2); SetIndexStyle(0,DRAW_LINE); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(0,UpBuffer1); SetIndexShift(0,MA_Shift1); SetIndexBuffer(1,UpBuffer2); SetIndexShift(1,MA_Shift2); SetIndexBuffer(2,CLOSE); return(0); } int deinit() { return(0); } void start() { int limit; int counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1); limit=Bars-counted_bars-1; for(int shift=0; shift<limit; shift++) CLOSE[shift] = iClose(NULL,0,shift); for(shift=0; shift<limit; shift++) { ma_1 = iMAOnArray(CLOSE,0,MA_Period_1,0,MA_Type_1,shift); ma_2 = iMAOnArray(CLOSE,0,MA_Period_2,0,MA_Type_2,shift); UpBuffer1[shift]=ma_1; UpBuffer2[shift]=ma_2; } return(0); }

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,
in attachment you see the source code of custom Moving average. I want to change it so that two Moving averages with several Periods combines together but the output shows only 1 Buffer. For example i have this changes for SMA mode like below:
please help me what is here wrong or what should changes here?