//+------------------------------------------------------------------+ //| Squize_MA_M_mtf Squize_MA.mq4 | //| mtf:ForexTSD.com 2007 Kalenzo | //| mladen's formula ki bartlomiej.gorski@gmail.com | //+------------------------------------------------------------------+ #property copyright "Kalenzo" #property link "bartlomiej.gorski@gmail.com" #property indicator_buffers 4 #property indicator_color1 Blue #property indicator_color2 Red #property indicator_color3 Violet #property indicator_color4 DarkViolet #property indicator_width1 2 #property indicator_width2 2 #property indicator_width3 1 #property indicator_width4 2 double upma[]; double dnma[]; double SqLup[]; double SqLdn[]; extern int MaDifrential = 5; extern int Ma1Period = 5; extern int Ma1Type = MODE_EMA; extern int Ma1Price = PRICE_CLOSE; extern int Ma2Period = 21; extern int Ma2Type = MODE_EMA; extern int Ma2Price = PRICE_CLOSE; extern int TimeFrame = 0; extern string note_TimeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN|0-CurrentTF"; extern string IndicatorCorrectName = "MA_SquizeMAm_mtf"; extern string note_Ind_Name = "If indicator`s Name changed - enter a New Name"; #property indicator_chart_window //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexBuffer(0,upma); SetIndexBuffer(1,dnma); SetIndexStyle(0,DRAW_LINE); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(2,SqLup); SetIndexStyle(2,DRAW_LINE); SetIndexBuffer(3,SqLdn); SetIndexStyle(3,DRAW_LINE); //---- if (TimeFrame < Period()) TimeFrame = Period(); return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars1=IndicatorCounted(); int limit1,i1; if(counted_bars1 < 0) return(-1); limit1 = Bars-counted_bars1; if (TimeFrame != Period()) { limit1 = MathMax(limit1,TimeFrame/Period()); datetime TimeArray[]; ArrayCopySeries(TimeArray ,MODE_TIME ,NULL,TimeFrame); for(i1=0,int y=0; i1<limit1; i1++) { if(Time[i1]<TimeArray[y]) y++; upma [i1] = iCustom(NULL,TimeFrame,IndicatorCorrectName,0,y); dnma [i1] = iCustom(NULL,TimeFrame,IndicatorCorrectName,1,y); SqLup [i1] =iCustom(NULL,TimeFrame,IndicatorCorrectName,2,y); SqLdn [i1] =iCustom(NULL,TimeFrame,IndicatorCorrectName,3,y); } return(0); } int limit; int counted_bars=IndicatorCounted(); if(counted_bars<0) counted_bars=0; if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; //---- for(int i = 0 ;i <= limit ;i++) { double ma1 = iMA(Symbol(),0,Ma1Period,0,Ma1Type,Ma1Price,i); double ma2 = iMA(Symbol(),0,Ma2Period,0,Ma2Type,Ma2Price,i); double madif = MathAbs(ma1-ma2); if(madif/Point > MaDifrential) { upma[i] = ma1; dnma[i] = ma2; } else { if(ma1>ma2) { upma[i] = ma1 - (madif/2); dnma[i] = ma1 - (madif/2); SqLup [i] = ma1+ MaDifrential*Point ; SqLdn [i] = ma1 - MaDifrential*Point; } else { upma[i] = ma2 - (madif/2); dnma[i] = ma2 - (madif/2); SqLup [i] = ma2 + MaDifrential*Point; SqLdn [i] = ma2 - MaDifrential*Point; } } } 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
Indicators Used:
Moving average indicator
Custom Indicators Used:
IndicatorCorrectName
Order Management characteristics:
Other Features: