当前位置:首页 > 学习资料 > EA那些事 > 正文

外汇EA指标:宝塔线指标

2019-11-19 11:32:07

指标描述: 宝塔线,红色做多,白色做空,根据箭头方向做单。指标源码: property indicator_chart_window property indicator_buff

指标描述:

       宝塔线,红色做多,白色做空,根据箭头方向做单。

指标源码:

  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
#property indicator_chart_window#property indicator_buffers 6#property indicator_color1 Red#property indicator_color2 White#property indicator_color3 Red#property indicator_color4 White#property indicator_color5 Blue#property indicator_color6 Blue
extern bool AlertFlag = TRUE;
double ExtMapBuffer1[];double ExtMapBuffer2[];double ExtMapBuffer3[];double ExtMapBuffer4[];double max1;double max2;double max3;double min1;double min2;double min3;double max4;int ii = 0;int iii = 0;

double d[];double dd[];
//----int ExtCountedBars=0; int init()  {  IndicatorBuffers(6);//---- indicators   SetIndexStyle(0,DRAW_HISTOGRAM, 0,3, Red);   SetIndexBuffer(0, ExtMapBuffer1);   SetIndexStyle(1,DRAW_HISTOGRAM, 0,3, White);   SetIndexBuffer(1, ExtMapBuffer2);   SetIndexStyle(2,DRAW_HISTOGRAM, 0,3, Red);   SetIndexBuffer(2, ExtMapBuffer3);   SetIndexStyle(3,DRAW_HISTOGRAM, 0, 3, White);   SetIndexBuffer(3, ExtMapBuffer4);   SetIndexStyle(4, DRAW_ARROW,0,3,Blue);   SetIndexArrow(4, 228);   SetIndexBuffer(4, d);      SetIndexStyle(5, DRAW_ARROW,0,3,Blue);   SetIndexArrow(5, 230);   SetIndexBuffer(5, dd);      //----   SetIndexDrawBegin(0,10);   SetIndexDrawBegin(1,10);   SetIndexDrawBegin(2,10);   SetIndexDrawBegin(3,10);  //---- indicator buffers mapping   SetIndexBuffer(0,ExtMapBuffer1);   SetIndexBuffer(1,ExtMapBuffer2);   SetIndexBuffer(2,ExtMapBuffer3);   SetIndexBuffer(3,ExtMapBuffer4);      iSetLable("信息栏1","指标制作人;ea那些事,期待你的联系探讨。",80,30,40,"Ver-dana",Olive);     return(0);  } int deinit()  {    return(0);  } int start()  {   bool  prese;   double mid1 ,mid2,redmax,  redmin,greenmax,greenmin;   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 p=Bars-ExtCountedBars-1;   if(Close[p+1]>=Close[p+2]){ redmax=Close[p+1];redmin=Close[p+2];prese=1;      }   else {   greenmin=Close[p+1];greenmax=Close[p+2];prese=0;      }      while(p>=0)     {        if(prese==0){  if (Close[p]<greenmax )                                              {     mid2=greenmin;                                                     greenmax=MathMax( mid2,Close[p]);                                                     greenmin=MathMin( mid2,Close[p]);                                                    ExtMapBuffer1[p]=greenmin;                                                   ExtMapBuffer2[p]=greenmax;                                                                                                       prese=0  ;                                                                                                                                                                                                }                                            else{   ExtMapBuffer1[p]=greenmin;                                                 ExtMapBuffer2[p]=greenmax;                                                        redmax=Close[p];                                                 redmin=greenmax;                                                   ExtMapBuffer3[p]=redmax;                                                 ExtMapBuffer4[p]=redmin;                                                                                                   prese=1  ;                                                                                                 }                }               else{  if( Close[p]<redmin ){      ExtMapBuffer1[p]=redmax;                                                  ExtMapBuffer2[p]=redmin;                                                                                                    greenmin=Close[p];                                                  greenmax=redmin;                                                  ExtMapBuffer3[p]=greenmin;                                                  ExtMapBuffer4[p]=greenmax;                                                                                                     prese=0  ;                                                                                                 }                                       else{    mid1=redmax;                                                  redmax=MathMax(mid1,Close[p]);                                                   redmin=MathMin(mid1,Close[p]);                                                  ExtMapBuffer1[p]=redmax;                                                  ExtMapBuffer2[p]=redmin;                                                                                                    prese=1  ;                                                   }                                                                 }                                                   min1=MathMin(ExtMapBuffer1[p],ExtMapBuffer2[p]);                                                   max1=MathMax(ExtMapBuffer1[p],ExtMapBuffer2[p]);                                                   max2=MathMax(ExtMapBuffer1[p+1],ExtMapBuffer2[p+1]);                                                   min2=MathMin(ExtMapBuffer1[p+1],ExtMapBuffer2[p+1]);                                                   max3=MathMax(MathMax(ExtMapBuffer1[p+2],ExtMapBuffer2[p+2]),MathMax(ExtMapBuffer3[p+2],ExtMapBuffer3[p+2]));                                                   min3=MathMin(MathMin(ExtMapBuffer1[p+2],ExtMapBuffer2[p+2]),MathMin(ExtMapBuffer3[p+2],ExtMapBuffer4[p+2]));                                                   max4=MathMax(ExtMapBuffer1[p+2],ExtMapBuffer2[p+2]);        if((max1==max2&&max1==max3&&max2==max3)||(max1==max2&&max1==max4&&max2==max4))     {     dd[p]=High[p]+3*Point;     if (AlertFlag)          {            if( ii == FALSE)            {                             Alert(Symbol() + " " + Period() + " 空头"  "!" );               ii = TRUE;               iii = FALSE;            }         }     }                                                if(min1==min2&&min1==min3&&min2==min3)     {     d[p]=Low[p]-3*Point;     if (AlertFlag)          {            if( ii == FALSE)            {                             Alert(Symbol() + " " + Period() + " 多头"  "!" );               ii = TRUE;               iii = FALSE;            }         }     }                                                             p--;               }
//----   return(0);  }void iSetLable(string LableName,string LableDoc,int LableX,int LableY,int DcoSize,string DocStyle,color DocColor){  ObjectCreate(LableName,OBJ_LABEL,0,0,0); ObjectSetText(LableName,LableDoc,40,DocStyle,DocColor); ObjectSet(LableName,OBJPROP_XDISTANCE,LableX); ObjectSet(LableName,OBJPROP_YDISTANCE,LableY);}

效果图:

上一篇: ea系列之:突破ea(一次一单)

下一篇: EA指标:交易量指标

声明本站分享的文章旨在促进信息交流,不以盈利为目的,本文观点与本站立场无关,不承担任何责任。部分内容文章及图片来自互联网或自媒体,版权归属于原作者,不保证该信息(包括但不限于文字、图片、图表及数据)的准确性、真实性、完整性、有效性、及时性、原创性等,如无意侵犯媒体或个人知识产权,请来电或致函告之,本站将在第一时间处理。未经证实的信息仅供参考,不做任何投资和交易根据,据此操作风险自担。本站拥有对此声明的最终解释权。