- #property indicator_chart_window
- #property indicator_buffers 3
- #property indicator_color1 Red
- #property indicator_color2 Blue
- #property indicator_color3 Silver
- extern int 基周期= 10;
- extern int 显棒数= 10000;
- double 红跌线[];
- double 蓝涨线[];
- double 银中线[];
- //------------初始化-------——+
- void init()
- {
- SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);
- SetIndexBuffer(0, 红跌线);
- SetIndexLabel(0, "????í?? ??àíè?à");
- SetIndexDrawBegin(0, 0);
- SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 2);
- SetIndexBuffer(1, 蓝涨线);
- SetIndexLabel(1, "?è?í?? ??àíè?à");
- SetIndexDrawBegin(1, 0);
- SetIndexStyle(2, DRAW_LINE, STYLE_DOT, 1);
- SetIndexBuffer(2, 银中线);
- SetIndexLabel(2, "???èàíà");
- SetIndexDrawBegin(2, 0);
- IndicatorShortName("?è?à ò??í?à (?ò?? ????) ("+基周期+")");
- }
- //-----------反初始化------——+
- void deinit()
- {
- Comment("");
- }
- //-----------主函数--------——+
- void start()
- {
- int 周期步幅= 1;
- if(基周期>1)
- 周期步幅= 基周期;
- int 方向= 0;
- double 极高均, 极低均, x1, x2, x3, x4, x5, x6;
- for(int i=显棒数-1; i>=0; i--){
- x1= iMA(NULL,0,1*周期步幅,0,MODE_SMA,PRICE_CLOSE,i);
- x2= iMA(NULL,0,2*周期步幅,0,MODE_SMA,PRICE_CLOSE,i);
- x3= iMA(NULL,0,3*周期步幅,0,MODE_SMA,PRICE_CLOSE,i);
- x4= iMA(NULL,0,4*周期步幅,0,MODE_SMA,PRICE_CLOSE,i);
- x5= iMA(NULL,0,5*周期步幅,0,MODE_SMA,PRICE_CLOSE,i);
- x6= iMA(NULL,0,6*周期步幅,0,MODE_SMA,PRICE_CLOSE,i);
- //--选择极端条件均线值(按递增周期顺序)
- 极高均= x1;
- 极低均= x1;
- if(极高均<x2) 极高均= x2;
- if(极高均<x3) 极高均= x3;
- if(极高均<x4) 极高均= x4;
- if(极高均<x5) 极高均= x5;
- if(极高均<x6) 极高均= x6;
- if(极低均>x2) 极低均= x2;
- if(极低均>x3) 极低均= x3;
- if(极低均>x4) 极低均= x4;
- if(极低均>x5) 极低均= x5;
- if(极低均>x6) 极低均= x6;
- //--确定方向
- if(High[i]>极高均)
- 方向= 1;
- if(Low [i]<极低均)
- 方向=-1;
- if(High[i]>极高均 && Low[i]<极低均)
- 方向=0;
- //--赋值
- 红跌线[i]= EMPTY_VALUE;
- 蓝涨线[i]= EMPTY_VALUE;
- if(方向<0)
- 红跌线[i]= 极高均;
- if(方向>0)
- 蓝涨线[i]= 极低均;
- 银中线[i]= (极高均+极低均)/2;
- }
- if(红跌线[0]!=EMPTY_VALUE)
- Comment("SELL; ?ò?? ????: "+DoubleToStr(红跌线[0],Digits));
- if(蓝涨线[0]!=EMPTY_VALUE)
- Comment("BUY; ?ò?? ????: "+DoubleToStr(蓝涨线[0],Digits));
- }
- //-------------------——+
复制代码
|