//+------------------------------------------------------------------+ //| #MTF_StepMA_sashken.mq4 | //| E-mail: sashken@mail.ru | //+------------------------------------------------------------------+ #property link "E-mail: sashken@mail.ru" #property indicator_chart_window #property indicator_buffers 5 #property indicator_color1 Aqua #property indicator_color2 Gold #property indicator_color3 Red #property indicator_color4 Lime #property indicator_color5 Magenta //---- input parameters extern int TimeFrame=0; extern int MA=5; // ma period extern int MAmode=MODE_EMA; // ma mode extern int MAprice=PRICE_CLOSE; // ma price extern double StepSizeFast=0.0012; // points extern double StepSizeSlow=0.0015; // points extern double StepSize=2.0; // 2.0 extern int TotalBar=5000; //extern int HighLow=0; //---- indicator buffers double Line1Buffer[]; double Line2Buffer[]; double Line3Buffer[]; double Line4Buffer[]; double Line5Buffer[]; //---- input parameters /************************************************************************* PERIOD_M1 1 PERIOD_M5 5 PERIOD_M15 15 PERIOD_M30 30 PERIOD_H1 60 PERIOD_H4 240 PERIOD_D1 1440 PERIOD_W1 10080 PERIOD_MN1 43200 You must use the numeric value of the timeframe that you want to use when you set the TimeFrame' value with the indicator inputs. --------------------------------------- PRICE_CLOSE 0 Close price. PRICE_OPEN 1 Open price. PRICE_HIGH 2 High price. PRICE_LOW 3 Low price. PRICE_MEDIAN 4 Median price, (high+low)/2. PRICE_TYPICAL 5 Typical price, (high+low+close)/3. PRICE_WEIGHTED 6 Weighted close price, (high+low+close+close)/4. You must use the numeric value of the Applied Price that you want to use when you set the 'applied_price' value with the indicator inputs. **************************************************************************/ //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicator line string short_name; //---- indicator line SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1); SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2); SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,2); SetIndexStyle(3,DRAW_ARROW,STYLE_SOLID,2); SetIndexStyle(4,DRAW_ARROW,STYLE_SOLID,2); SetIndexEmptyValue(3,0); SetIndexArrow(3,233); SetIndexEmptyValue(4,0); SetIndexArrow(4,234); SetIndexBuffer(0,Line1Buffer); SetIndexBuffer(1,Line2Buffer); SetIndexBuffer(2,Line3Buffer); SetIndexBuffer(3,Line4Buffer); SetIndexBuffer(4,Line5Buffer); IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)); //---- name for DataWindow and indicator subwindow label short_name="StepMA_sashken(Period:"+MA+", Fast:"+StepSizeFast+", Slow:"+StepSizeSlow+")"; IndicatorShortName(short_name); SetIndexLabel(0,"MA"); SetIndexLabel(1,"StepMA fast"); SetIndexLabel(2,"StepMA slow"); SetIndexLabel(3,"UP signal"); SetIndexLabel(4,"DOWN signal"); //---- SetIndexDrawBegin(0,1); SetIndexDrawBegin(1,1); SetIndexDrawBegin(2,1); //---- name for DataWindow and indicator subwindow label } //---- return(0); //+------------------------------------------------------------------+ //| MTF MA | //+------------------------------------------------------------------+ int start() { datetime TimeArray[]; int i,limit,shift,y=0,counted_bars=IndicatorCounted(); // Plot defined time frame on to current time frame ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame); limit=Bars-counted_bars+TimeFrame/Period(); for(i=0,y=0;i<limit;i++) { if (Time[i]<TimeArray[y]) y++; /*********************************************************** Add your main indicator loop below. You can reference an existing indicator with its iName or iCustom. Rule 1: Add extern inputs above for all neccesary values Rule 2: Use 'TimeFrame' for the indicator time frame Rule 3: Use 'y' for your indicator's shift value **********************************************************/ Line1Buffer[i] = iCustom(NULL,TimeFrame,"StepMA_sashken_v2",MA,MAmode,MAprice,StepSizeFast,StepSizeSlow,StepSize,TotalBar,0,y); Line2Buffer[i] = iCustom(NULL,TimeFrame,"StepMA_sashken_v2",MA,MAmode,MAprice,StepSizeFast,StepSizeSlow,StepSize,TotalBar,1,y); Line3Buffer[i] = iCustom(NULL,TimeFrame,"StepMA_sashken_v2",MA,MAmode,MAprice,StepSizeFast,StepSizeSlow,StepSize,TotalBar,2,y); Line4Buffer[i] = iCustom(NULL,TimeFrame,"StepMA_sashken_v2",MA,MAmode,MAprice,StepSizeFast,StepSizeSlow,StepSize,TotalBar,3,y); Line5Buffer[i] = iCustom(NULL,TimeFrame,"StepMA_sashken_v2",MA,MAmode,MAprice,StepSizeFast,StepSizeSlow,StepSize,TotalBar,4,y); } //* for(shift=limit;shift>=0;shift--) // { // if (Line2Buffer[shift+1]>Line3Buffer[shift+1] && Line2Buffer[shift+2]<=Line3Buffer[shift+2]) // { // Line4Buffer[shift] = Line3Buffer[shift+1]-StepSizeFast; // } // if (Line2Buffer[shift+1]<Line3Buffer[shift+1] && Line2Buffer[shift+2]>=Line3Buffer[shift+2]) // { // Line5Buffer[shift] = Line3Buffer[shift+1]+StepSizeFast; // } // // }// // return(0); } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Series array that contains open time of each bar
Indicator Curves created:
Implements a curve of type DRAW_LINE
Implements a curve of type DRAW_ARROW
Indicators Used:
Custom Indicators Used:
StepMA_sashken_v2
Order Management characteristics:
Other Features: