|
分享 个可以同一图上看不同周期K线的指标
AAAK线叠加 (1).zip
(1006 Bytes, 下载次数: 114)
代码:
- #property indicator_chart_window
- #property indicator_buffers 4
- #property indicator_color1 MidnightBlue
- #property indicator_color2 MidnightBlue
- #property indicator_color3 SteelBlue
- #property indicator_color4 SaddleBrown
- int ExtCountedBars=0;
- double to[],tc[],th[],tl[],bili;
- extern int TimeFrame=1440;
- extern int duizun = 20;
- extern int barslimit=1500;
- //extern string SYMBOL="AUDUSD";
- //+------------------------------------------------------------------+
- //| Custom indicator initialization function |
- //+------------------------------------------------------------------+
- int init()
- {
- IndicatorBuffers(5);
- SetIndexStyle(2,DRAW_HISTOGRAM,0,5);
- SetIndexBuffer(2,to);
- SetIndexStyle(3,DRAW_HISTOGRAM,0,5);
- SetIndexBuffer(3,tc);
- SetIndexStyle(0,DRAW_HISTOGRAM,0,5);
- SetIndexBuffer(0,th);
- SetIndexStyle(1,DRAW_HISTOGRAM,0,5);
- SetIndexBuffer(1,tl);
- switch(TimeFrame)
- {
- case 1 : string TimeFrameStr="Period_M1"; break;
- case 5 : TimeFrameStr="Period_M5"; break;
- case 15 : TimeFrameStr="Period_M15"; break;
- case 30 : TimeFrameStr="Period_M30"; break;
- case 60 : TimeFrameStr="Period_H1"; break;
- case 240 : TimeFrameStr="Period_H4"; break;
- case 1440 : TimeFrameStr="Period_D1"; break;
- case 10080 : TimeFrameStr="Period_W1"; break;
- case 43200 : TimeFrameStr="Period_MN1"; break;
- default : TimeFrameStr="Current Timeframe";
- }
- //----
- return(0);
- }
- //+------------------------------------------------------------------+
- //+------------------------------------------------------------------+
- int deinit()
- {
- //----
- return(0);
- }
- //+------------------------------------------------------------------+
- //| Custom indicator iteration function |
- //+------------------------------------------------------------------+
- int start()
- {
- datetime TimeArray[];
- ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame);
-
- /// int y=0;
- if(Bars<=10) return(0);
- ExtCountedBars=IndicatorCounted();
- //---- check for possible errors
- if (ExtCountedBars<0) return(-1);
- //---- last counted bar will be recounted
- if (ExtCountedBars>0) ExtCountedBars--;
- // int i=500;
-
- bili=Open[duizun]/iMA(NULL,TimeFrame,1,0,MODE_SMA,1,duizun);
- // while(i>=0)
- // {
-
- int i,y;
-
-
-
- for(i=0,y=0;i<barslimit;i++)
- {
- if (Time[i]<TimeArray[y]) y++;
-
- to[i]=0;
- tc[i]=0;
- th[i]=0;
- tl[i]=0;
-
- /*
- to[i]=iOpen(SYMBOL,TimeFrame,y)*bili;
- tc[i]=iClose(SYMBOL,TimeFrame,y)*bili;
- th[i]=iHigh(SYMBOL,TimeFrame,y)*bili;
- tl[i]=iLow(SYMBOL,TimeFrame,y)*bili;
-
- */
- to[i]=iOpen(NULL,TimeFrame,y);
- tc[i]=iClose(NULL,TimeFrame,y);
- th[i]=iHigh(NULL,TimeFrame,y);
- tl[i]=iLow(NULL,TimeFrame,y);
-
- }
- return(0);
- }
- //+------------------------------------------------------------------+
复制代码 |
|