加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

彩虹交易系统所有指标

(2015-06-01 18:12:05)
标签:

股票

外汇交易系统

分类: 外汇交易系统
模板文件需要的进群共享下载。附图只有两个指标,主图是均线组合。
http://s7/mw690/001DXNpCgy6SJ8EksxEb6&690





MBFX Timing.mq4
//--------------------------------------------

#property copyright "MBFX Timing"
#property link      "finger"

#property indicator_separate_window
#property indicator_minimum 0.0
#property indicator_maximum 100.0
#property indicator_buffers 3
#property indicator_color1 Yellow
#property indicator_color2 Red
#property indicator_color3 Lime
#property indicator_width1 2
#property indicator_level1 70.0
#property indicator_width2 2
#property indicator_level2 30.0
#property indicator_width3 2
#property indicator_level3 50.0

extern int Len = 7;
extern double Filter = 0.0;
double g_ibuf_88[];
double g_ibuf_92[];
double g_ibuf_96[];

int init() {
   IndicatorShortName("MBFX Timing Indicator");
   SetIndexStyle(0, DRAW_LINE);
   SetIndexBuffer(0, g_ibuf_88);
   SetIndexStyle(1, DRAW_LINE);
   SetIndexBuffer(1, g_ibuf_92);
   SetIndexStyle(2, DRAW_LINE);
   SetIndexBuffer(2, g_ibuf_96);
   return (0);
}

int deinit() {
   return (0);
}

int start() {
   double ld_0;
   double ld_8;
   double ld_16;
   double ld_24;
   double ld_32;
   double ld_40;
   double ld_48;
   double ld_56;
   double ld_64;
   double ld_72;
   double ld_80;
   double ld_88;
   double ld_96;
   double ld_104;
   double ld_112;
   double ld_120;
   double ld_128;
   double ld_136;
   double ld_144;
   double ld_152;
   double ld_160;
   double ld_168;
   double ld_176;
   double ld_184;
   double ld_192;
   double ld_200;
   double ld_208;
   double ld_216 = Bars - Len - 1;
   for (int li_224 = ld_216; li_224 >= 0; li_224--) {
      if (ld_8 == 0.0) {
         ld_8 = 1.0;
         ld_16 = 0.0;
         if (Len - 1 >= 5) ld_0 = Len - 1.0;
         else ld_0 = 5.0;
         ld_80 = 100.0 * ((High[li_224] + Low[li_224] + Close[li_224]) / 3.0);
         ld_96 = 3.0 / (Len + 2.0);
         ld_104 = 1.0 - ld_96;
      } else {
         if (ld_0 <= ld_8) ld_8 = ld_0 + 1.0;
         else ld_8 += 1.0;
         ld_88 = ld_80;
         ld_80 = 100.0 * ((High[li_224] + Low[li_224] + Close[li_224]) / 3.0);
         ld_32 = ld_80 - ld_88;
         ld_112 = ld_104 * ld_112 + ld_96 * ld_32;
         ld_120 = ld_96 * ld_112 + ld_104 * ld_120;
         ld_40 = 1.5 * ld_112 - ld_120 / 2.0;
         ld_128 = ld_104 * ld_128 + ld_96 * ld_40;
         ld_208 = ld_96 * ld_128 + ld_104 * ld_208;
         ld_48 = 1.5 * ld_128 - ld_208 / 2.0;
         ld_136 = ld_104 * ld_136 + ld_96 * ld_48;
         ld_152 = ld_96 * ld_136 + ld_104 * ld_152;
         ld_56 = 1.5 * ld_136 - ld_152 / 2.0;
         ld_160 = ld_104 * ld_160 + ld_96 * MathAbs(ld_32);
         ld_168 = ld_96 * ld_160 + ld_104 * ld_168;
         ld_64 = 1.5 * ld_160 - ld_168 / 2.0;
         ld_176 = ld_104 * ld_176 + ld_96 * ld_64;
         ld_184 = ld_96 * ld_176 + ld_104 * ld_184;
         ld_144 = 1.5 * ld_176 - ld_184 / 2.0;
         ld_192 = ld_104 * ld_192 + ld_96 * ld_144;
         ld_200 = ld_96 * ld_192 + ld_104 * ld_200;
         ld_72 = 1.5 * ld_192 - ld_200 / 2.0;
         if (ld_0 >= ld_8 && ld_80 != ld_88) ld_16 = 1.0;
         if (ld_0 == ld_8 && ld_16 == 0.0) ld_8 = 0.0;
      }
      if (ld_0 < ld_8 && ld_72 > 0.0000000001) {
         ld_24 = 50.0 * (ld_56 / ld_72 + 1.0);
         if (ld_24 > 100.0) ld_24 = 100.0;
         if (ld_24 < 0.0) ld_24 = 0.0;
      } else ld_24 = 50.0;
      g_ibuf_88[li_224] = ld_24;
      g_ibuf_92[li_224] = ld_24;
      g_ibuf_96[li_224] = ld_24;
      if (g_ibuf_88[li_224] > g_ibuf_88[li_224 + 1] - Filter) g_ibuf_96[li_224] = EMPTY_VALUE;
      else {
         if (g_ibuf_88[li_224] < g_ibuf_88[li_224 + 1] + Filter) g_ibuf_92[li_224] = EMPTY_VALUE;
         else {
            if (g_ibuf_88[li_224] == g_ibuf_88[li_224 + 1] + Filter) {
               g_ibuf_92[li_224] = EMPTY_VALUE;
               g_ibuf_96[li_224] = EMPTY_VALUE;
            }
         }
      }
   }
   return (0);
}
//-----------------------------------------
CycleIdentifier.mq4
//--------------------------
//+------------------------------------------------------------------+
//|                                              CycleIdentifier.mq4 |
// 
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""

#property indicator_separate_window
#property indicator_buffers 6
#property indicator_color1 DarkGray

#property indicator_color2 Red
#property indicator_color3 Lime
#property indicator_color4 Red
#property indicator_color5 Lime

#property indicator_minimum -1.2
#property indicator_maximum 1.2

extern int       PriceActionFilter=1;
extern int       Length=3;
extern int       MajorCycleStrength=4;
extern bool      UseCycleFilter=false;
extern int       UseFilterSMAorRSI=1;
extern int       FilterStrengthSMA=12;
extern int       FilterStrengthRSI=21;

double LineBuffer[];
double MajorCycleBuy[];
double MajorCycleSell[];
double MinorCycleBuy[];
double MinorCycleSell[];
double ZL1[];

double CyclePrice = 0.0, Strength =0.0, SweepA = 0.0, SweepB = 0.0;
int Switch = 0, Switch2 = 0,    SwitchA = 0, SwitchB = 0, SwitchC = 0, SwitchD = 0, SwitchE = 0, SwitchAA = 0, SwitchBB = 0;
double Price1BuyA = 0.0, Price2BuyA = 0.0;
int Price1BuyB = 1.0, Price2BuyB = 1.0;
double Price1SellA = 0.0, Price2SellA = 0.0;
int Price1SellB = 0.0, Price2SellB = 0.0;
bool ActiveSwitch = True, BuySwitchA = FALSE, BuySwitchB = FALSE, SellSwitchA = FALSE, SellSwitchB = FALSE;
int BuySellFac = 01;
bool Condition1, Condition2, Condition3, Condition6;

int init()  {
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
   SetIndexBuffer(0,LineBuffer);
  
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,3);
   SetIndexBuffer(1,MajorCycleBuy);
  
   SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,3);
   SetIndexBuffer(2,MajorCycleSell);
  
   SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_SOLID,1);
   SetIndexBuffer(3,MinorCycleBuy);
  
   SetIndexStyle(4,DRAW_HISTOGRAM,STYLE_SOLID,1);
   SetIndexBuffer(4,MinorCycleSell);
  
   SetIndexStyle(5,DRAW_NONE);
   SetIndexBuffer(5,ZL1);
  
   SetIndexEmptyValue(1,0.0);
   SetIndexEmptyValue(2,0.0);
   SetIndexEmptyValue(3,0.0);
   SetIndexEmptyValue(4,0.0);
   SetIndexEmptyValue(5,0.0); 
   return(0);
}

int deinit() {return(0);}

int start() {
   int counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
  // if(counted_bars>0) counted_bars--;
  // int position=Bars-1;
   int position=Bars-counted_bars;
   if (position<0) position=0;

   int rnglength = 250;
   double range = 0.0, srange = 0.0;
   for (int pos = position; pos >=0; pos--)
   {
      srange = 0.0;
      int j = 0;
      for (int i=0;i
      {
         j++;
         int posr = pos + i;
         if (posr >= Bars)
            break;
           
         srange = srange + (High[posr] - Low[posr]);
      }
      range = srange / j * Length;
      int BarNumber = Bars-pos; //??????????
      if (BarNumber < 0)
            BarNumber = 0;
 
      CyclePrice = iMA(NULL, 0, PriceActionFilter, 0, MODE_SMMA, PRICE_CLOSE, pos);
     
      if (UseFilterSMAorRSI == 1)
            ZL1[pos] = ZeroLag(CyclePrice,FilterStrengthSMA, pos);
      if (UseFilterSMAorRSI == 2)
            ZL1[pos] = ZeroLag( iRSI(NULL, 0, 14, CyclePrice, FilterStrengthRSI ), FilterStrengthRSI, pos);

      if (ZL1[pos] > ZL1[pos+1])
          SwitchC = 1;
      if (ZL1[pos] < ZL1[pos+1])
          SwitchC = 2;
         
      if (BarNumber <= 1)
      {
         if (Strength == 0)
               SweepA  = range;
             else
               SweepA = Strength;
         Price1BuyA  = CyclePrice;
         Price1SellA  = CyclePrice;
      }
     
     
     
      if (BarNumber > 1)
      {
         if (Switch > -1)
         {
            if (CyclePrice < Price1BuyA)
            {
              
                  if (UseCycleFilter && (SwitchC == 2) && BuySwitchA )
                  {
                       MinorCycleBuy[pos + BarNumber - Price1BuyB] = 0; //MinorBuySell
                       LineBuffer[pos + BarNumber - Price1BuyB ] = 0; //line
                    }
             
                    if (!UseCycleFilter && BuySwitchA)
                    {
                       MinorCycleBuy[pos +BarNumber - Price1BuyB] = 0;
                       LineBuffer[pos +BarNumber - Price1BuyB] = 0;
                    }
                    Price1BuyA = CyclePrice;
                  Price1BuyB = BarNumber;
                  BuySwitchA = TRUE;
            }
            else if (CyclePrice > Price1BuyA)
            {
 
                     SwitchA = BarNumber - Price1BuyB;
        
                    if (!UseCycleFilter)
                    {
                       MinorCycleBuy[pos +SwitchA] = -1;//MinorBuySell - DarkGreen
                       LineBuffer[pos +SwitchA] = -1;//line
                    }
             
                    if (UseCycleFilter && SwitchC  == 1)
                    {
                       MinorCycleBuy[pos +SwitchA] = -1;  //MinorBuySell
                       LineBuffer[pos +SwitchA] = -1; //line
                       SwitchD = 1;
                    }
                    else
                    {
                       SwitchD = 0;
                     }
              
                  BuySwitchA = TRUE;
       
                    double cyclePrice1 = iMA(NULL, 0, PriceActionFilter, 0, MODE_SMMA, PRICE_CLOSE, pos + SwitchA);
                  if (ActiveSwitch)
                 
                        Condition1 = CyclePrice - cyclePrice1 >= SweepA;
                  }
                  else
                  {
                        Condition1 = CyclePrice >= cyclePrice1 * (1 + SweepA / 1000);
                  }
                  if (Condition1 && SwitchA >= BuySellFac)
                  {
                        Switch =  - 1;
                        Price1SellA = CyclePrice;
                        Price1SellB = BarNumber;
                        SellSwitchA = FALSE;
                        BuySwitchA = FALSE;
                           
            }
         }
         if(Switch < 1)
         {
            if (CyclePrice > Price1SellA)
            {
               if (UseCycleFilter && SwitchC == 1 && SellSwitchA )
               {
                     MinorCycleSell[pos +BarNumber - Price1SellB] = 0; //MinorBuySell
                     LineBuffer[pos +BarNumber - Price1SellB ] = 0; //line
                  }
                  if (!UseCycleFilter && SellSwitchA )
                  {
                   MinorCycleSell[pos +BarNumber - Price1SellB] = 0;//MinorBuySell
                   LineBuffer[pos +BarNumber - Price1SellB] = 0;//line
               }
               Price1SellA = CyclePrice;
               Price1SellB = BarNumber;
               SellSwitchA = TRUE;  
               }
               else if (CyclePrice < Price1SellA)
               {
                  SwitchA = BarNumber - Price1SellB;
               if (!UseCycleFilter)
               {
                  MinorCycleSell[pos +SwitchA] = 1; // MinorBuySell darkRed
                  LineBuffer[pos +SwitchA] = 1; //"CycleLine"
                  }
                  if (UseCycleFilter && (SwitchC == 2))
                  {
                     MinorCycleSell[pos +SwitchA] = 1;//MinorBuySell darkRed
                     LineBuffer[pos +SwitchA] = 1;//CycleLine
                     SwitchD  = 2;
                  }
                  else
                     SwitchD  = 0;

               SellSwitchA = TRUE;
                  double cyclePrice2 = iMA(NULL, 0, PriceActionFilter, 0, MODE_SMMA, PRICE_CLOSE, pos + SwitchA);
              
                  if (ActiveSwitch)
                     Condition1 = (cyclePrice2 - CyclePrice) >= SweepA;
                  else
                     Condition1 = CyclePrice <= (cyclePrice2 * (1 - SweepA / 1000));

                  if (Condition1 && SwitchA >= BuySellFac)
                  {
                      Switch = 1;
                  Price1BuyA = CyclePrice;
                  Price1BuyB = BarNumber;
                  SellSwitchA = FALSE;
                  BuySwitchA = FALSE;
               }
            }
         }
      }
     
      LineBuffer[pos] = 0;
      MinorCycleBuy[pos] = 0;
      MinorCycleSell[pos] = 0;

      if (BarNumber == 1)
      {
         if (Strength == 0)
            SweepB  = range *  MajorCycleStrength;
         else
            SweepB = Strength * MajorCycleStrength;
           
         Price2BuyA = CyclePrice;
         Price2SellA = CyclePrice;
        
           
      if (BarNumber > 1)
      {
         if (Switch2  - 1)
         {
            if (CyclePrice < Price2BuyA)
            {
               if (UseCycleFilter && SwitchC == 2 && BuySwitchB )
                   {
                      MajorCycleBuy [pos +BarNumber - Price2BuyB] = 0; //MajorBuySell,green
        //              LineBuffer[pos + BarNumber - Price2BuyB ] = 0; //line -----
               }
               if (!UseCycleFilter && BuySwitchB )
               {
                  MajorCycleBuy [pos +BarNumber - Price2BuyB] = 0;//MajorBuySell,green
      //                  LineBuffer[pos + BarNumber - Price2BuyB ] = 0; //line-----------
               }
                  Price2BuyA = CyclePrice;
               Price2BuyB = BarNumber;
               BuySwitchB = TRUE;
            }
            else if (CyclePrice > Price2BuyA)
            {
                  SwitchB = BarNumber - Price2BuyB;

               if (!UseCycleFilter)
              
                     MajorCycleBuy [pos +SwitchB] = -1; //MajorBuySell green
      //               LineBuffer[pos + SwitchB] = -1; //line--------------
               }
               if (UseCycleFilter && SwitchC  == 1)
               {
                  MajorCycleBuy [pos +SwitchB] = -1; //MajorBuySell green
     //             LineBuffer[pos + SwitchB] = -1; //line-----------------
                  SwitchE  = 1;
               }
               else
                     SwitchE  = 0;

               BuySwitchB = TRUE;
                  double cyclePrice3 = iMA(NULL, 0, PriceActionFilter, 0, MODE_SMMA, PRICE_CLOSE, pos + SwitchB);
               if (ActiveSwitch)
                  Condition6 = CyclePrice - cyclePrice3 >= SweepB;
               else
                  Condition6 = CyclePrice >= cyclePrice3 * (1 + SweepB / 1000);

                  if (Condition6 && SwitchB >= BuySellFac)
                  {
                     Switch2 =  - 1;
                     Price2SellA = CyclePrice;
                     Price2SellB = BarNumber;
                     SellSwitchB = FALSE;
                     BuySwitchB = FALSE;
               }
            }
         }

         if (Switch2  < 1)
         {
            if (CyclePrice  > Price2SellA )
            {
                  if (UseCycleFilter && SwitchC  == 1 && SellSwitchB )
                   {
                         MajorCycleSell [pos +BarNumber - Price2SellB] = 0; //"MajorBuySell",red
        //                  LineBuffer[pos + BarNumber - Price2SellB ] = 0; //line -----
                 }
                  if (!UseCycleFilter && SellSwitchB )
                   {
                       MajorCycleSell [pos +BarNumber - Price2SellB] = 0;//"MajorBuySell",red
     //              LineBuffer[pos + BarNumber - Price2SellB ] = 0; //line -----
               }
                  Price2SellA = CyclePrice;
               Price2SellB = BarNumber;
               SellSwitchB = TRUE;
               }
               else if (CyclePrice < Price2SellA)
               {
               SwitchB = BarNumber - Price2SellB ;

                  if (!UseCycleFilter)
                  {
                     MajorCycleSell[pos + SwitchB] = 1; //"MajorBuySell",red
     //               LineBuffer[pos + SwitchB ] = 1; //line -----
                  }
                 if (UseCycleFilter && SwitchC  == 2)
                 {
                      MajorCycleSell [pos + SwitchB] = 1; //"MajorBuySell",red
      //              LineBuffer[pos + SwitchB ] = 1; //line -----
                       SwitchE  = 2;
                  }
                  else
                     SwitchE  = 0;

               SellSwitchB = TRUE;
                double cyclePrice4 = iMA(NULL, 0, PriceActionFilter, 0, MODE_SMMA, PRICE_CLOSE, pos + SwitchB);
                  if (ActiveSwitch)
                  Condition6 = cyclePrice4 - CyclePrice >= SweepB;
                  else
                  Condition6 = CyclePrice <= cyclePrice4 * (1.0 - SweepB / 1000.0);

                  if (Condition6 && SwitchB >= BuySellFac)
                  {
                        Switch2 = 1;
                     Price2BuyA = CyclePrice;
                     Price2BuyB = BarNumber;
                     SellSwitchB = FALSE;
                     BuySwitchB = FALSE;
               }
            }
         }
      }
      LineBuffer[pos] = 0;
      MajorCycleSell[pos] = 0;
      MajorCycleBuy[pos] = 0;
   }
   return(0);
}

double ZeroLag(double price, int length, int pos)
 
   if (length < 3)
   {
      return(price);
   }
   double aa = MathExp(-1.414*3.14159 / length);
   double bb = 2*aa*MathCos(1.414*180 / length);
   double CB = bb;
   double CC = -aa*aa;
   double CA = 1 - CB - CC;
   double CD = CA*price + CB*ZL1[pos+1] + CC*ZL1[pos+2];
   return(CD);
}



0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有