|
- //+------------------------------------------------------------------+
- //| MA_Shade.mq4 |
- //| quant001 |
- //| www.geekquant.com |
- //+------------------------------------------------------------------+
- #property copyright "www.geekquant.com"
- #property link "www.geekquant.com"
- #property indicator_chart_window
- #property indicator_buffers 2
- #property indicator_color1 DarkGreen
- #property indicator_color2 FireBrick
- #property indicator_width1 3
- #property indicator_width2 3
- extern int MA1_Period=25;
- extern int MA2_Period=100;
- extern string MA_Method_Help="0-SMA, 1-EMA, 2-SMMA, 3-LWMA";
- extern int MA_Method=1;
- double MA1, MA2;
- double MA1_Buffer[], MA2_Buffer[];
- //+------------------------------------------------------------------+
- //| Custom indicator initialization function |
- //+------------------------------------------------------------------+
- int init()
- {
- SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_DOT);
- SetIndexBuffer(0,MA1_Buffer);
-
- SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_DOT);
- SetIndexBuffer(1,MA2_Buffer);
- //---- indicators
- //----
- return(0);
- }
- //+------------------------------------------------------------------+
- //| Custom indicator deinitialization function |
- //+------------------------------------------------------------------+
- int deinit()
- {
- //----
-
- //----
- return(0);
- }
- //+------------------------------------------------------------------+
- //| Custom indicator iteration function |
- //+------------------------------------------------------------------+
- int start()
- {
- int counted_bars=IndicatorCounted();
-
- int limit=Bars-counted_bars;
- if(counted_bars>0) limit++;
-
- for(int i=1; i<limit; i++)
- {
- MA1=iMA(NULL,0,MA1_Period,0,MA_Method,PRICE_CLOSE,i);
- MA2=iMA(NULL,0,MA2_Period,0,MA_Method,PRICE_CLOSE,i);
-
- MA1_Buffer[i]=MA1;
- MA2_Buffer[i]=MA2;
- }
- //----
-
- //----
- return(0);
- }
- //+------------------------------------------------------------------+
复制代码
|
|