//+------------------------------------------------------------------+ //| DK Multi MA.mq4 | //| Copyright © 2009, MetaQuotes Software Corp. | //| http://www.metaquotes.net/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2009,Darkkiller" #property link "http://www.metaquotes.net/" #property indicator_chart_window #property indicator_buffers 8 #property indicator_color1 Blue #property indicator_color2 DarkGray #property indicator_color3 DarkGray #property indicator_color4 White #property indicator_color5 Blue #property indicator_color6 DarkGray #property indicator_color7 DarkGray #property indicator_color8 White #property indicator_width1 2 #property indicator_width2 2 #property indicator_width3 2 #property indicator_width4 2 #property indicator_width5 2 #property indicator_width6 2 #property indicator_width7 2 #property indicator_width8 2 //---- input parameters extern int MA1_TF=0; extern int MA1_Period=14; extern int MA1_Method = 0; extern int MA1_Shift=0; extern int MA1_Apply_to=0; extern int MA2_TF=0; extern int MA2_Period=50; extern int MA2_Method = 0; extern int MA2_Shift=0; extern int MA2_Apply_to=0; extern int MA3_TF=0; extern int MA3_Period=100; extern int MA3_Method = 0; extern int MA3_Shift=0; extern int MA3_Apply_to=0; extern int MA4_TF=0; extern int MA4_Period=200; extern int MA4_Method = 0; extern int MA4_Shift=0; extern int MA4_Apply_to=0; extern int MA5_TF=60; extern int MA5_Period=14; extern int MA5_Method = 0; extern int MA5_Shift=0; extern int MA5_Apply_to=0; extern int MA6_TF=60; extern int MA6_Period=50; extern int MA6_Method = 0; extern int MA6_Shift=0; extern int MA6_Apply_to=0; extern int MA7_TF=60; extern int MA7_Period=100; extern int MA7_Method = 0; extern int MA7_Shift=0; extern int MA7_Apply_to=0; extern int MA8_TF=60; extern int MA8_Period=200; extern int MA8_Method = 0; extern int MA8_Shift=0; extern int MA8_Apply_to=0; //---- indicator buffers double ExtMA1Buffer[]; double ExtMA2Buffer[]; double ExtMA3Buffer[]; double ExtMA4Buffer[]; double ExtMA5Buffer[]; double ExtMA6Buffer[]; double ExtMA7Buffer[]; double ExtMA8Buffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- line shifts when drawing SetIndexShift(0,MA1_Shift); SetIndexShift(1,MA2_Shift); SetIndexShift(2,MA3_Shift); SetIndexShift(3,MA4_Shift); SetIndexShift(4,MA5_Shift); SetIndexShift(5,MA6_Shift); SetIndexShift(6,MA7_Shift); SetIndexShift(7,MA8_Shift); //---- first positions skipped when drawing SetIndexDrawBegin(0,MA1_Period-1); SetIndexDrawBegin(1,MA2_Period-1); SetIndexDrawBegin(2,MA3_Period-1); SetIndexDrawBegin(3,MA4_Period-1); SetIndexDrawBegin(4,MA5_Period-1); SetIndexDrawBegin(5,MA6_Period-1); SetIndexDrawBegin(6,MA7_Period-1); SetIndexDrawBegin(7,MA8_Period-1); //---- 3 indicator buffers mapping SetIndexBuffer(0,ExtMA1Buffer); SetIndexBuffer(1,ExtMA2Buffer); SetIndexBuffer(2,ExtMA3Buffer); SetIndexBuffer(3,ExtMA4Buffer); SetIndexBuffer(4,ExtMA5Buffer); SetIndexBuffer(5,ExtMA6Buffer); SetIndexBuffer(6,ExtMA7Buffer); SetIndexBuffer(7,ExtMA8Buffer); //---- drawing settings SetIndexStyle(0,DRAW_LINE); SetIndexStyle(1,DRAW_LINE); SetIndexStyle(2,DRAW_LINE); SetIndexStyle(3,DRAW_LINE); SetIndexStyle(4,DRAW_LINE); SetIndexStyle(5,DRAW_LINE); SetIndexStyle(6,DRAW_LINE); SetIndexStyle(7,DRAW_LINE); //---- index labels SetIndexLabel(0,"Value"); SetIndexLabel(1,"Value"); SetIndexLabel(2,"Value"); SetIndexLabel(3,"Value"); SetIndexLabel(4,"Value"); SetIndexLabel(5,"Value"); SetIndexLabel(6,"Value"); SetIndexLabel(7,"Value"); //---- initialization done return(0); } //+------------------------------------------------------------------+ //| Multi MA | //+------------------------------------------------------------------+ int start() { int limit; int counted_bars=IndicatorCounted(); //---- check for possible errors if(counted_bars<0) return(-1); //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; //---- main loop for(int i=0; i<limit; i++) { //---- ma_shift set to 0 because SetIndexShift called abowe ExtMA1Buffer[i]=iMA(NULL,MA1_TF,MA1_Period,0,MA1_Method,MA1_Apply_to,i); ExtMA2Buffer[i]=iMA(NULL,MA2_TF,MA2_Period,0,MA2_Method,MA2_Apply_to,i); ExtMA3Buffer[i]=iMA(NULL,MA3_TF,MA3_Period,0,MA3_Method,MA3_Apply_to,i); ExtMA4Buffer[i]=iMA(NULL,MA4_TF,MA4_Period,0,MA4_Method,MA4_Apply_to,i); ExtMA5Buffer[i]=iMA(NULL,MA5_TF,MA5_Period,0,MA5_Method,MA5_Apply_to,i); ExtMA6Buffer[i]=iMA(NULL,MA6_TF,MA6_Period,0,MA6_Method,MA6_Apply_to,i); ExtMA7Buffer[i]=iMA(NULL,MA7_TF,MA7_Period,0,MA7_Method,MA7_Apply_to,i); ExtMA8Buffer[i]=iMA(NULL,MA8_TF,MA8_Period,0,MA8_Method,MA8_Apply_to,i); } //---- done return(0); } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Indicator Curves created:
Implements a curve of type DRAW_LINE
Indicators Used:
Moving average indicator
Custom Indicators Used:
Order Management characteristics:
Other Features: