//+------------------------------------------------------------------+ //| zscore.mq4 | //| mtf fx tsd ki modulatum | //+------------------------------------------------------------------+ // C-MA(C,60)/ Stddev(C,60) normalizes price over a period60 #property copyright "Mod" #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 BlueViolet #property indicator_color2 DeepSkyBlue //#property indicator_level1 0 #property indicator_level1 2 #property indicator_level2 1 #property indicator_level3 -1 #property indicator_level4 -2 #property indicator_levelcolor DarkSlateGray //---- input parameters extern int TimeFrame = 0; extern int MA1_Period = 20; extern int MA2_Period = 38; extern string note_MA_Method_Mode = "SMA0 EMA1 SMMA2 LWMA3"; extern int MA1_Method = 0; extern int MA2_Method = 0; extern string note_Price = "C0,O1, 2H3L,4Md 5Tp 6WghC: Md(HL/2)4,Tp(HLC/3)5,Wgh(HLCC/4)6"; extern int MA1_Price = 0; extern int MA2_Price = 0; extern bool DrawMa1Histo = true; extern int barsToCount = 2000; extern string TimeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN|0-CurrentTF"; //---- buffers double zscore1[]; double zscore2[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators IndicatorBuffers(2); SetIndexBuffer(1,zscore1); SetIndexBuffer(0,zscore2); if (DrawMa1Histo) SetIndexStyle(0,DRAW_HISTOGRAM); else SetIndexStyle(0,DRAW_LINE); SetIndexStyle(1,DRAW_LINE); //---- IndicatorShortName("zscore ["+TimeFrame+"]"+MA1_Period+"|"+MA2_Period+""); if (TimeFrame<Period())TimeFrame=Period(); return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { datetime TimeArray[]; int i,limit,y=0,counted_bars=IndicatorCounted(); ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame); limit= Bars-counted_bars; limit= MathMax(limit,TimeFrame/Period()); limit= MathMin(limit,barsToCount); //---- for(i=0,y=0;i<limit;i++) { if (Time[i]<TimeArray[y]) y++; zscore1[i] = (iClose(NULL,TimeFrame,y)-iMA(NULL,TimeFrame,MA1_Period,0,MA1_Method,MA1_Price,y))/iStdDev(NULL,TimeFrame,MA1_Period,0,MA1_Method,MA1_Price,y); zscore2[i] = (iClose(NULL,TimeFrame,y)-iMA(NULL,TimeFrame,MA2_Period,0,MA2_Method,MA2_Price,y))/iStdDev(NULL,TimeFrame,MA2_Period,0,MA2_Method,MA2_Price,y); } //---- return(0); } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Series array that contains open time of each bar
Series array that contains close prices for each bar
Indicator Curves created:
Implements a curve of type DRAW_HISTOGRAM
Implements a curve of type DRAW_LINE
Indicators Used:
Moving average indicator
Standard Deviation indicator
Custom Indicators Used:
Order Management characteristics:
Other Features: