求助老师帮我改到主图MT4用 谢谢

 
//+------------------------------------------------------------------+
//|                                                      ProjectName |
//|                                      Copyright 2012, CompanyName |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+
#property copyright "
#property link"http://babelfish.taobao.com/"

#property indicator_separate_window
#property indicator_buffers 14
#property indicator_color1 clrRed
#property indicator_color2 clrWhite
#property indicator_color3 clrBlack
#property indicator_color4 clrBlack

#property indicator_color5 clrYellow
#property indicator_color6 clrRed
#property indicator_color7 clrWhite
#property indicator_color8 clrCyan
#property indicator_color9 clrRed
#property indicator_color10 clrRed
#property indicator_color11 clrWhite
#property indicator_color12 clrCyan
#property indicator_color13 clrWhite
#property indicator_color14 clrYellow
#property indicator_minimum 0
#property indicator_maximum 100

#property indicator_width1 5
#property indicator_width2 5
#property indicator_width3 5
#property indicator_width4 5
#property indicator_width5 5
#property indicator_width6 5
#property indicator_width7 5
#property indicator_width8 5
#property indicator_width9 5
#property indicator_width10 5
#property indicator_width11 5
#property indicator_width12 5
#property indicator_width13 0
#property indicator_width14 0
//--- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
double ExtMapBuffer6[];
double ExtMapBuffer7[];
double ExtMapBuffer8[];
double ExtMapBuffer9[];
double ExtMapBuffer10[];
double ExtMapBuffer11[];
double ExtMapBuffer12[];
double VARA[];
double VARB[];
double VARCX1[];
double VARC[];
double QS[];
double VARD[];
double VARE[];
double VAR6[];
double VAR8[];
double VARAA[];
double BX1[];
double B[];
double B1[];
double V1[];
double V2[];
double VA[];
double FBX1[];
double FB[];
double ZLXX1[];
double ZLX[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   IndicatorBuffers(32);
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexStyle(2,DRAW_HISTOGRAM);
   SetIndexStyle(3,DRAW_HISTOGRAM);
   SetIndexStyle(4,DRAW_NONE);
   SetIndexStyle(5,DRAW_NONE);
   SetIndexStyle(6,DRAW_LINE);
   SetIndexStyle(7,DRAW_LINE);
   SetIndexStyle(8,DRAW_LINE);
   SetIndexStyle(9,DRAW_LINE);
   SetIndexStyle(10,DRAW_LINE);
   SetIndexStyle(11,DRAW_LINE);

   SetIndexStyle(12,DRAW_LINE);
   SetIndexStyle(13,DRAW_LINE);

   SetIndexBuffer(0,ExtMapBuffer9);
   SetIndexBuffer(1,ExtMapBuffer10);
   SetIndexBuffer(2,ExtMapBuffer11);
   SetIndexBuffer(3,ExtMapBuffer12);
   SetIndexBuffer(4,ExtMapBuffer1);
   SetIndexBuffer(5,ExtMapBuffer2);
   SetIndexBuffer(6,ExtMapBuffer3);
   SetIndexBuffer(7,ExtMapBuffer4);
   SetIndexBuffer(8,ExtMapBuffer5);
   SetIndexBuffer(9,ExtMapBuffer6);
   SetIndexBuffer(10,ExtMapBuffer7);
   SetIndexBuffer(11,ExtMapBuffer8);
   SetIndexBuffer(12,QS);
   SetIndexBuffer(13,ZLX);
   SetIndexBuffer(14,VARCX1);
   SetIndexBuffer(15,VARC);
   SetIndexBuffer(16,VARA);
   SetIndexBuffer(17,VARD);
   SetIndexBuffer(18,VARE);
   SetIndexBuffer(19,VAR6);
   SetIndexBuffer(20,VAR8);
   SetIndexBuffer(21,VARAA);
   SetIndexBuffer(22,BX1);
   SetIndexBuffer(23,B);
   SetIndexBuffer(24,B1);
   SetIndexBuffer(25,V1);
   SetIndexBuffer(26,V2);
   SetIndexBuffer(27,VA);
   SetIndexBuffer(28,FBX1);
   SetIndexBuffer(29,FB);
   SetIndexBuffer(30,ZLXX1);
   SetIndexBuffer(31,VARB);

   IndicatorShortName("20150522 TB 一把手粉红-指标1");
   IndicatorDigits(Digits+1);

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//----
   for(int i=ObjectsTotal();i>=0;i--)
     {
      if(StringFind(ObjectName(i),"20150522",0)==0)
        {
         ObjectDelete(ObjectName(i));
         i=ObjectsTotal();
        }
     }
//----
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function|
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
   if(WindowFind("20150522 TB 一把手粉红-指标1")!=-1)
      int 窗口=WindowFind("20150522 TB 一把手粉红-指标1");

   int counted=MathMax(IndicatorCounted(),0);
   if(counted<0)return(-1);
   if(counted>0)counted--;
   int i=Bars-counted;
   for(int m=i;m>=0;m--)VARA[m]=Low[iLowest(Symbol(),0,MODE_LOW,35,m)];
   for(m=i;m>=0;m--)VARB[m]=High[iHighest(Symbol(),0,MODE_HIGH,30,m)];
   for(m=i;m>=0;m--)VARCX1[m]=(VARB[m]-VARA[m])!=0?((Close[m]-VARA[m])/(VARB[m]-VARA[m])*4):EMPTY_VALUE;
   for(m=i;m>=0;m--)VARC[m]=iMAOnArray(VARCX1,0,4,0,MODE_EMA,m)*25;
   for(m=i;m>=0;m--)QS[m]=VARC[m];

   for(m=i;m>=0;m--)
     {
      ObjectDelete("20150522-1"+TimeToStr(Time[m],TIME_DATE|TIME_MINUTES)+1);
      ObjectDelete("20150522-2"+TimeToStr(Time[m],TIME_DATE|TIME_MINUTES)+2);

      ExtMapBuffer1[m]=EMPTY_VALUE;
      ExtMapBuffer2[m]=EMPTY_VALUE;
      if(High[iHighest(Symbol(),0,MODE_HIGH,14,m)]-Low[iLowest(Symbol(),0,MODE_LOW,14,m)]!=0)
         if(VARC[m]<10 && 100*(High[iHighest(Symbol(),0,MODE_HIGH,14,m)]-Close[m])/(High[iHighest(Symbol(),0,MODE_HIGH,14,m)]-Low[iLowest(Symbol(),0,MODE_LOW,14,m)])>97)
           {
            ExtMapBuffer1[m]=0;
            ExtMapBuffer2[m]=25;
            画线段("20150522-1",窗口,0,25,Time[m],Time[m],clrYellow,1,3);
           }

      if(VARC[m]>90)
        {
         ExtMapBuffer1[m]=100;
         ExtMapBuffer2[m]=85;
         画线段("20150522-2",窗口,85,100,Time[m],Time[m],Red,1,3);
        }
     }

   for(m=i;m>=0;m--)VARD[m]=87.5;
   for(m=i;m>=0;m--)VARE[m]=VARC[ArrayMaximum(VARC,4,m)]-VARC[ArrayMinimum(VARC,4,m)]!=0?(VARC[m]-VARC[ArrayMinimum(VARC,4,m)])/(VARC[ArrayMaximum(VARC,4,m)]-VARC[ArrayMinimum(VARC,4,m)])*4*25:EMPTY_VALUE;


   for(m=i;m>=0;m--)VAR6[m]=(2*Close[m]+High[m]+Low[m])/4;
   for(m=i;m>=0;m--)VAR8[m]=Low[iLowest(Symbol(),0,MODE_LOW,30,m)];
   for(m=i;m>=0;m--)VARAA[m]=High[iHighest(Symbol(),0,MODE_HIGH,30,m)];

   for(m=i;m>=0;m--)BX1[m]=VARAA[m]-VAR8[m]!=0?(VAR6[m]-VAR8[m])/(VARAA[m]-VAR8[m])*100:EMPTY_VALUE;

   for(m=i;m>=0;m--)B[m]=iMAOnArray(BX1,0,8,0,MODE_EMA,m);
   for(m=i;m>=0;m--)B1[m]=iMAOnArray(B,0,5,0,MODE_EMA,m);

   for(m=i;m>=0;m--)
     {
      ExtMapBuffer3[m]=EMPTY_VALUE;
      ExtMapBuffer4[m]=EMPTY_VALUE;
      ExtMapBuffer5[m]=EMPTY_VALUE;
      ExtMapBuffer6[m]=EMPTY_VALUE;
      ExtMapBuffer7[m]=EMPTY_VALUE;
      ExtMapBuffer8[m]=EMPTY_VALUE;
      ExtMapBuffer9[m]=EMPTY_VALUE;
      ExtMapBuffer10[m]=EMPTY_VALUE;
      if(B[m]>0 && B[m]-B1[m]>=0)
        {
         ExtMapBuffer3[m]=80;
         ExtMapBuffer3[m+1]=80;
        }
      if(B[m]>0 && B[m]-B1[m]<0)
        {
         ExtMapBuffer4[m]=80;
         ExtMapBuffer4[m+1]=80;
        }
      if(B[m]>0 && B[m]-B1[m]>=0)
        {
         ExtMapBuffer5[m]=50;
         ExtMapBuffer5[m+1]=50;
        }
      if(B[m]>0 && B[m]-B1[m]<0)
        {
         ExtMapBuffer6[m]=50;
         ExtMapBuffer6[m+1]=50;
        }
      if(B[m]>0 && B[m]-B1[m]>=0)
        {
         ExtMapBuffer7[m]=20;
         ExtMapBuffer7[m+1]=20;
        }
      if(B[m]>0 && B[m]-B1[m]<0)
        {
         ExtMapBuffer8[m]=20;
         ExtMapBuffer8[m+1]=20;
        }
      if(B[m]-B1[m]>0)
        {
         ExtMapBuffer9[m]=B[m];
         ExtMapBuffer10[m]=B1[m];
        }
      if(B[m]-B1[m]<0)
        {
         ExtMapBuffer9[m]=B[m];
         ExtMapBuffer10[m]=B1[m];
        }

      ExtMapBuffer11[m]=MathMin(B[m],B1[m]);
     }

   for(m=i;m>=0;m--)V1[m]=(2*Close[m]+High[m]+Low[m])/4;
   for(m=i;m>=0;m--)V2[m]=Low[iLowest(Symbol(),0,MODE_LOW,21,m)];
   for(m=i;m>=0;m--)VA[m]=High[iHighest(Symbol(),0,MODE_HIGH,34,m)];
   for(m=i;m>=0;m--)FBX1[m]=VA[m]-V2[m]!=0?(V1[m]-V2[m])/(VA[m]-V2[m])*100:EMPTY_VALUE;
   for(m=i;m>=0;m--)FB[m]=iMAOnArray(FBX1,0,13,0,MODE_EMA,m);
   for(m=i;m>=0;m--)ZLXX1[m]=0.382*FB[m+2]+0.618*FB[m];
   for(m=i;m>=0;m--)ZLX[m]=iMAOnArray(ZLXX1,0,12,0,MODE_EMA,m);

   for(m=i;m>=0;m--)
     {
      ObjectDelete("20150522-3"+Time[m]);
      ObjectDelete("20150522-4"+Time[m]);
      ObjectDelete("20150522-5"+Time[m]);
      if(QS[m]>=VARD[m])
         if(QS[m+1]<VARD[m+1])
            if(VARE[m]==100)
               laber0("20150522-3"+Time[m],"买",clrYellow,Time[m],56,8,ANCHOR_LEFT_UPPER,窗口);

      if(VARD[m]>=QS[m])
         if(VARD[m+1]<QS[m+1])
               laber0("20150522-4"+Time[m],"空",clrYellow,Time[m],87,8,ANCHOR_LEFT_UPPER,窗口);

      if(QS[m]>=VARE[m])
         if(QS[m+1]<VARE[m+1])
            if(QS[m]>87)
               laber0("20150522-5"+Time[m],"平仓",clrYellow,Time[m],87,8,ANCHOR_LEFT_UPPER,窗口);
     }

   return(rates_total);
  }
//+------------------------------------------------------------------+

void laber0(string name,string txt,color 颜色,datetime 时间,double 价位,int 字体大小,int 定位,int 窗口)
  {
   ObjectDelete(name);
   ObjectCreate(name,OBJ_TEXT,窗口,时间,价位);
   ObjectSetText(name,txt,字体大小,"Times New Roman",颜色);
   ObjectSetInteger(0,name,OBJPROP_ANCHOR,定位);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void 画线段(string 名称,int 窗口,double 第一价格,double 第二价格,datetime 第一时间,datetime 第二时间,color 颜色,int 编码,int 粗细)
  {
   if(窗口==-1)
      return(0);
   ObjectDelete(名称+TimeToStr(第一时间,TIME_DATE|TIME_MINUTES)+编码);
   ObjectCreate(名称+TimeToStr(第一时间,TIME_DATE|TIME_MINUTES)+编码,OBJ_TREND,窗口,第一时间,第一价格,第二时间,第二价格);
   ObjectSet(名称+TimeToStr(第一时间,TIME_DATE|TIME_MINUTES)+编码,OBJPROP_COLOR,颜色);
   ObjectSet(名称+TimeToStr(第一时间,TIME_DATE|TIME_MINUTES)+编码,OBJPROP_RAY,0);
   ObjectSet(名称+TimeToStr(第一时间,TIME_DATE|TIME_MINUTES)+编码,OBJPROP_WIDTH,粗细);
  }
//+------------------------------------------------------------------+

 

Forum on trading, automated trading systems and testing trading strategies

When you post code please use the CODE button (Alt-S)!

Use the CODE button


原因: