//+------------------------------------------------------------------+ //| w35260_ws_MA_or_SDL.mq4 | //| IgorS | //| igor.senych@gmail.com | //+------------------------------------------------------------------+ #property copyright "IgorS" #property link "igor.senych@gmail.com" #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 Green #property indicator_color2 Red //---- input parameters extern int w_period1 = 89; extern int w_price1 = 0; extern int w_mode1 = 3; extern int w_period2 = 144; extern int w_price2 = 0; extern int w_mode2 = 3; extern bool MA = false; extern int ma_period = 55; extern int ma_price = 0; extern int ma_mode = 3; extern int sl_period = 144; extern int sl_price = 0; extern int sl_mode = 0; extern int dev = 1; double val1 = 0, val2 = 0, MA_prv = 0, MA_cur = 0; //---- buffers double ExtMapBuffer0[]; double ExtMapBuffer1[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_LINE,EMPTY,2); SetIndexBuffer(0,ExtMapBuffer0); SetIndexStyle(1,DRAW_LINE,EMPTY,2); SetIndexBuffer(1,ExtMapBuffer1); //---- return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int limit; int counted_bars=IndicatorCounted(); //---- check for possible errors if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; for(int i=0; i<limit; i++) { val1 = iCustom(Symbol(),0,"w35260_Colored",w_period1,w_mode1,w_price1,w_period2,w_mode2,w_price2,2,0,i); val2 = iCustom(Symbol(),0,"w35260_Colored",w_period1,w_mode1,w_price1,w_period2,w_mode2,w_price2,2,0,i+1); if(MA == true) { MA_cur = iMA(NULL,0,ma_period,0,ma_mode,ma_price,i)*(1+val1/dev); MA_prv = iMA(NULL,0,ma_period,0,ma_mode,ma_price,i+1)*(1+val2/dev); } else { MA_cur = iCustom(Symbol(),0,"Slope_Direction_Line",sl_period,sl_mode,sl_price,2,i)*(1+val1/dev); MA_prv = iCustom(Symbol(),0,"Slope_Direction_Line",sl_period,sl_mode,sl_price,2,i+1)*(1+val2/dev); } ExtMapBuffer0[i]=MA_cur; ExtMapBuffer1[i]=MA_cur; if(MA_cur<MA_prv) { ExtMapBuffer0[i]=EMPTY_VALUE; } if(MA_cur>MA_prv) { ExtMapBuffer1[i]=EMPTY_VALUE; } } //---- 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:
Slope_Direction_Line
w35260_Colored
Order Management characteristics:
Other Features: