- //+------------------------------------------------------------------+
- //| 指标举例.mq4 |
- //| Copyright ?2007, 520FX Corp. |
- //| http://www.520fx.com |
- //+------------------------------------------------------------------+
- #property copyright "Copyright ?2007, 520FX Corp."
- #property link "http://www.520fx.com"
- #property indicator_chart_window
- #property indicator_buffers 2
- #property indicator_color1 White
- #property indicator_color2 Yellow
- extern int Ma=12;
- extern int Ma1=36;
- double MaLine[],Ma1Line[];
- //+------------------------------------------------------------------+
- //| Custom indicator initialization function |
- //+------------------------------------------------------------------+
- int init()
- {
- //---- indicators
- IndicatorBuffers(2);
- SetIndexStyle(0,DRAW_LINE);
- SetIndexStyle(1,DRAW_LINE);
- SetIndexBuffer(0,MaLine);
- SetIndexBuffer(1,Ma1Line);
- //----
- return(0);
- }
- //+------------------------------------------------------------------+
- //| Custom indicator deinitialization function |
- //+------------------------------------------------------------------+
- int deinit()
- {
- //----
- //----
- return(0);
- }
- //+------------------------------------------------------------------+
- //| Custom indicator iteration function |
- //+------------------------------------------------------------------+
- int start()
- {
- int limit;
- int counted_bars=IndicatorCounted();
- if(counted_bars0) counted_bars--;
- limit=Bars-counted_bars;
- for (int i=limit-1;i>=0;i--)
- {
- MaLine=iMA(NULL,0,Ma,0,MODE_SMA,PRICE_CLOSE,i);
- Ma1Line=iMA(NULL,0,Ma1,0,MODE_SMA,PRICE_CLOSE,i);
- }
- //----
- return(0);
- }//+------------------------------------------------------------------+
复制代码 |