有您的持续关注
我们会做得更好

MT4货币对相对强弱指示指标



相对强弱指数指标的另类扩展(可以画线),MQL4源码如下:

//+------------------------------------------------------------------+
//|                                               新相对强弱指标.mq4 |
//|                                     Copyright 2014, QQ:125808047 |
//+------------------------------------------------------------------+
#property copyright "www.125808047.com"
#property link      "http://www.125808047.com/"

#property indicator_chart_window

extern bool CalcPannel_Enabled = TRUE;
extern bool CandleTime_Enabled = TRUE;
extern bool PriceMeter_Enabled = TRUE;
extern bool Pannel_On_Right = TRUE;
extern color Label_Color = SkyBlue;
extern color Value_Color1 = Orange;
extern color Value_Color2 = GreenYellow;
extern color CandleTime_Color = DimGray;
bool gi_108;
int gia_112[18];
int gia_116[18];
int gia_120[18];
int gia_124[8];
int gia_128[8];
int gia_132[9] = {4, 10, 25, 40, 50, 60, 75, 90, 97};
string gsa_136[8] = {"NZD", "CAD", "CHF", "AUD", "JPY", "USD", "GBP", "EUR"};
string gsa_140[18] = {"EURUSD", "GBPUSD", "AUDUSD", "USDJPY", "USDCHF", "USDCAD", "EURJPY",
 "EURGBP", "EURCHF", "EURAUD", "GBPJPY", "GBPCHF", "CADJPY", "EURCAD", "AUDCAD", "AUDJPY", "AUDNZD", "NZDUSD"};
int gia_144[10] = {10495, 20735, 30975, 41215, 48895, 46280, 51350, 56420, 61490, 65280};

int init() {
   gi_108 = TRUE;
   return (0);
}

int deinit() {
   //ObjectsDeleteAll();
   return (0);
}

int start() {
   CalcPannel();
   PriceMeter();
   if (gi_108) gi_108 = FALSE;
   return (0);
}

void SideLabel(string a_name_0, int a_x_8, int a_y_12, int a_corner_16 = 0) {
   if (ObjectFind(a_name_0) != 0) {
      ObjectCreate(a_name_0, OBJ_LABEL, 0, 0, 0);
      if (Pannel_On_Right) a_corner_16++;
      ObjectSet(a_name_0, OBJPROP_CORNER, a_corner_16);
      ObjectSet(a_name_0, OBJPROP_XDISTANCE, a_x_8);
      ObjectSet(a_name_0, OBJPROP_YDISTANCE, a_y_12);
   }
}

double DayRange(bool ai_0 = TRUE) {
   double ld_4 = iHigh(NULL, PERIOD_D1, 1) - iLow(NULL, PERIOD_D1, 1);
   double ld_12 = ld_4 + iHigh(NULL, PERIOD_D1, 2) - iLow(NULL, PERIOD_D1, 2);
   ld_12 += iHigh(NULL, PERIOD_D1, 3) - iLow(NULL, PERIOD_D1, 3);
   ld_12 += iHigh(NULL, PERIOD_D1, 4) - iLow(NULL, PERIOD_D1, 4);
   ld_12 += iHigh(NULL, PERIOD_D1, 5) - iLow(NULL, PERIOD_D1, 5);
   double ld_20 = ld_12 + iHigh(NULL, PERIOD_D1, 6) - iLow(NULL, PERIOD_D1, 6);
   ld_20 += iHigh(NULL, PERIOD_D1, 7) - iLow(NULL, PERIOD_D1, 7);
   ld_20 += iHigh(NULL, PERIOD_D1, 8) - iLow(NULL, PERIOD_D1, 8);
   ld_20 += iHigh(NULL, PERIOD_D1, 9) - iLow(NULL, PERIOD_D1, 9);
   ld_20 += iHigh(NULL, PERIOD_D1, 10) - iLow(NULL, PERIOD_D1, 10);
   double ld_28 = ld_20 + iHigh(NULL, PERIOD_D1, 11) - iLow(NULL, PERIOD_D1, 11);
   ld_28 += iHigh(NULL, PERIOD_D1, 12) - iLow(NULL, PERIOD_D1, 12);
   ld_28 += iHigh(NULL, PERIOD_D1, 13) - iLow(NULL, PERIOD_D1, 13);
   ld_28 += iHigh(NULL, PERIOD_D1, 14) - iLow(NULL, PERIOD_D1, 14);
   ld_28 += iHigh(NULL, PERIOD_D1, 15) - iLow(NULL, PERIOD_D1, 15);
   ld_28 += iHigh(NULL, PERIOD_D1, 16) - iLow(NULL, PERIOD_D1, 16);
   ld_28 += iHigh(NULL, PERIOD_D1, 17) - iLow(NULL, PERIOD_D1, 17);
   ld_28 += iHigh(NULL, PERIOD_D1, 18) - iLow(NULL, PERIOD_D1, 18);
   ld_28 += iHigh(NULL, PERIOD_D1, 19) - iLow(NULL, PERIOD_D1, 19);
   ld_28 += iHigh(NULL, PERIOD_D1, 20) - iLow(NULL, PERIOD_D1, 20);
   ld_12 = 0.2 * ld_12;
   ld_20 /= 10.0;
   ld_28 = 0.05 * ld_28;
   if (ai_0) return ((ld_4 + ld_12 + ld_20 + ld_28) / 4.0 / Point);
   return ((ld_4 + ld_12 + ld_20 + ld_28) / 8.0);
}

void CalcPannel() {
   int li_0;
   int li_4;
   string ls_8;
   if (CalcPannel_Enabled != FALSE) {
      if (gi_108) {
         SideLabel("labOpen", 73, 15);
         SideLabel("valOpen", 17, 15);
         SideLabel("labMaxP", 73, 30);
         SideLabel("valMaxP", 17, 30);
         SideLabel("labMinP", 73, 45);
         SideLabel("valMinP", 17, 45);
         SideLabel("labPoint", 73, 60);
         SideLabel("valPoint", 17, 60);
         SideLabel("labAV", 73, 75);
         SideLabel("valAV", 17, 75);
         SideLabel("labDV", 73, 90);
         SideLabel("valDV", 17, 90);
         SideLabel("labOffset", 73, 105);
         SideLabel("valOffset", 17, 105);
         SideLabel("valPrice", 17, 127);
         if (CandleTime_Enabled == TRUE) SideLabel("valCTime", 17, 147);
         ObjectSetText("labOpen", "开盘价", 9, "Arial", Label_Color);
         ObjectSetText("labMaxP", "最高价", 9, "Arial", Label_Color);
         ObjectSetText("labMinP", "最低价", 9, "Arial", Label_Color);
         ObjectSetText("labPoint", "交易点差", 9, "Arial", Label_Color);
         ObjectSetText("labAV", "日均波幅", 9, "Arial", Label_Color);
         ObjectSetText("labDV", "当日波幅", 9, "Arial", Label_Color);
         ObjectSetText("labOffset", "开盘涨跌", 9, "Arial", Label_Color);
      }
      ObjectSetText("valOpen", DoubleToStr(iOpen(NULL, PERIOD_D1, 0), Digits), 9, "Arial Black", Value_Color1);
      ObjectSetText("valMaxP", DoubleToStr(iHigh(NULL, PERIOD_D1, 0), Digits), 9, "Arial Black", Value_Color1);
      ObjectSetText("valMinP", DoubleToStr(iLow(NULL, PERIOD_D1, 0), Digits), 9, "Arial Black", Value_Color1);
      ObjectSetText("valPoint", DoubleToStr((Ask - Bid) / Point, 0), 9, "Arial Black", Value_Color2);
      ObjectSetText("valAV", DoubleToStr(DayRange(), 0), 9, "Arial Black", Value_Color2);
      ObjectSetText("valDV", DoubleToStr((iHigh(NULL, PERIOD_D1, 0) - iLow(NULL, PERIOD_D1, 0)) / Point, 0), 9, 
"Arial Black", Value_Color2);
      ObjectSetText("valOffset", DoubleToStr((iClose(NULL, PERIOD_D1, 0) - iOpen(NULL, PERIOD_D1, 0)) / Point, 0), 9, "Arial Black", Value_Color2);
      ObjectSetText("valPrice", DoubleToStr(Bid, Digits), 14, "Verdana", Value_Color1);
      if (CandleTime_Enabled == TRUE) {
         li_0 = Time[0] + 60 * Period() - TimeCurrent();
         li_4 = li_0 % 60;
         li_0 = (li_0 - li_4) / 60;
         if (li_0 >= 0) {
            ls_8 = li_4;
            if (StringLen(ls_8) == 1) ls_8 = "0" + ls_8;
            ObjectSetText("valCTime", li_0 + ":" + ls_8, 14, "Verdana", CandleTime_Color);
         }
      }
   }
}

void PriceMeter() {
   int li_4;
   double l_point_8;
   double ld_16;
   double ld_24;
   double ld_32;
   double l_low_40;
   string l_symbol_48;
   if (PriceMeter_Enabled != FALSE) {
      if (gi_108) {
         for (int l_index_0 = 0; l_index_0 < 18; l_index_0++) {
            l_symbol_48 = gsa_140[l_index_0];
            l_point_8 = MarketInfo(l_symbol_48, MODE_POINT);
            if (l_point_8 == 0.0) {
               gia_112[l_index_0] = 0;
               gia_116[l_index_0] = 0;
               gia_120[l_index_0] = 0;
            } else gia_120[l_index_0] = 1;
         }
         gia_124[7] = gia_120[0] + gia_120[6] + gia_120[7] + gia_120[8] + gia_120[9];
         gia_124[6] = gia_120[1] + gia_120[10] + gia_120[11] + gia_120[7];
         gia_124[5] = gia_120[3] + gia_120[4] + gia_120[5] + gia_120[0] + gia_120[1] + gia_120[2] + gia_120[17];
         gia_124[4] = gia_120[3] + gia_120[6] + gia_120[10] + gia_120[12] + gia_120[15];
         gia_124[3] = gia_120[2] + gia_120[9] + gia_120[14] + gia_120[15] + gia_120[16];
         gia_124[2] = gia_120[4] + gia_120[8] + gia_120[11];
         gia_124[1] = gia_120[5] + gia_120[14] + gia_120[13] + gia_120[12];
         gia_124[0] = gia_120[16] + gia_120[17];
         li_4 = 12;
         for (l_index_0 = 0; l_index_0 < 8; l_index_0++) { if (gia_124[l_index_0] > 0) {
               l_symbol_48 = "lab" + gsa_136[l_index_0];
               SideLabel(l_symbol_48, 73, li_4, 2);
               ObjectSetText(l_symbol_48, gsa_136[l_index_0], 9, "Arial", Label_Color);
               li_4 += 15;
            }
         }
      }
      for (l_index_0 = 0; l_index_0 < 18; l_index_0++) {
         if (gia_120[l_index_0] != 0) {
            l_symbol_48 = gsa_140[l_index_0];
            l_point_8 = MarketInfo(l_symbol_48, MODE_POINT);
            ld_32 = MarketInfo(l_symbol_48, MODE_HIGH);
            l_low_40 = MarketInfo(l_symbol_48, MODE_LOW);
            ld_16 = MathMax((ld_32 - l_low_40) / l_point_8, 1);
            ld_32 = MarketInfo(l_symbol_48, MODE_BID);
            ld_24 = (ld_32 - l_low_40) / ld_16 / l_point_8;
            gia_112[l_index_0] = iLookup(100.0 * ld_24);
            gia_116[l_index_0] = 9 - gia_112[l_index_0];
         }
      }
      gia_128[5] = gia_112[3] + gia_112[4] + gia_112[5] + gia_116[0] + gia_116[1] + gia_116[2] + gia_116[17];
      gia_128[7] = gia_112[0] + gia_112[6] + gia_112[7] + gia_112[8] + gia_112[9];
      gia_128[6] = gia_112[1] + gia_112[10] + gia_112[11] + gia_116[7];
      gia_128[2] = gia_116[4] + gia_116[8] + gia_116[11];
      gia_128[1] = gia_116[5] + gia_116[14] + gia_116[13] + gia_112[12];
      gia_128[3] = gia_112[2] + gia_116[9] + gia_112[14] + gia_112[15] + gia_112[16];
      gia_128[4] = gia_116[3] + gia_116[6] + gia_116[10] + gia_116[12] + gia_116[15];
      gia_128[0] = gia_116[16] + gia_112[17];
      li_4 = 12;
      for (l_index_0 = 0; l_index_0 < 8; l_index_0++) { if (gia_124[l_index_0] > 0) {
            ld_32 = gia_128[l_index_0];
            ld_32 /= gia_124[l_index_0];
            PairBlock(gsa_136[l_index_0], ld_32, li_4);
            li_4 += 15;
         }
      }
   }
}

int iLookup(double ad_0) {
   for (int l_index_8 = 0; l_index_8 < 9; l_index_8++)
      if (ad_0 < gia_132[l_index_8]) break;
   return (l_index_8);
}

void PairDelete(string as_0) {
   string l_name_8;
   for (int li_16 = 1; li_16 <= 30; li_16++) {
      l_name_8 = as_0 + li_16;
      if (ObjectFind(l_name_8) < 0) break; ObjectDelete(l_name_8); } } void PairBlock(string as_0, double ad_8, 
int ai_16) { int li_20; string l_name_32; PairDelete(as_0); if (ad_8 >= 9.0) li_20 = 9;
   else {
      if (ad_8 >= 8.0) li_20 = 8;
      else {
         if (ad_8 >= 7.0) li_20 = 7;
         else {
            if (ad_8 >= 6.0) li_20 = 6;
            else {
               if (ad_8 >= 5.0) li_20 = 5;
               else {
                  if (ad_8 >= 4.0) li_20 = 4;
                  else {
                     if (ad_8 >= 3.0) li_20 = 3;
                     else {
                        if (ad_8 >= 2.0) li_20 = 2;
                        else {
                           if (ad_8 >= 1.0) li_20 = 1;
                           else li_20 = 0;
                        }
                     }
                  }
               }
            }
         }
      }
   }
   int li_24 = 58;
   ai_16 += 3;
   for (int l_index_40 = 0; l_index_40 < li_20; l_index_40++) { l_name_32 = as_0 + ((3 * l_index_40 + 1)); 
SideLabel(l_name_32, li_24, ai_16, 2); ObjectSetText(l_name_32, "|", 6, "Arial Black", gia_144[l_index_40]); 
l_name_32 = as_0 + ((3 * l_index_40 + 2)); SideLabel(l_name_32, li_24 - 1, ai_16, 2); ObjectSetText(l_name_32,
 "|", 6, "Arial Black", gia_144[l_index_40]); l_name_32 = as_0 + ((3 * l_index_40 + 3)); SideLabel(l_name_32, 
li_24 - 2, ai_16, 2); ObjectSetText(l_name_32, "|", 6, "Arial Black",
 gia_144[l_index_40]); li_24 -= 5; } l_name_32 = as_0 + ((3 * li_20 + 1)); SideLabel(l_name_32,
 li_24, ai_16, 2); ObjectSetText(l_name_32, "|", 6, "Arial Black", gia_144[li_20]);
 l_name_32 = as_0 + ((3 * li_20 + 2)); SideLabel(l_name_32, li_24 - 1, ai_16, 2); 
ObjectSetText(l_name_32, "|", 6, "Arial Black", gia_144[li_20]); ad_8 -= li_20; if (ad_8 >= 0.5) {
      l_name_32 = as_0 + ((3 * li_20 + 3));
      SideLabel(l_name_32, li_24 - 2, ai_16, 2);
      ObjectSetText(l_name_32, "|", 6, "Arial Black", gia_144[li_20]);
   }
}

如您喜欢此文章请点下面分享按钮↴峰汇在线 » MT4货币对相对强弱指示指标
上一篇:
下一篇:
分享到:更多 ()