求修改下这个指标!

楼主  收藏   举报   帖子创建时间:  2019-05-05 05:08 回复:0 关注量:279

#property copyright "GOLDEN"
#property link      "zx815@126.com"

#property indicator_chart_window

extern bool showPriceLabel = TRUE;
double g_ihigh_80;
double g_ilow_88;
double g_iopen_96;
double g_iclose_104;
double gd_112;
double gd_120;
double gd_128;
double gd_136;
double gd_144;
double gd_152;
double gd_160;
double gd_168;
double gd_176;
double gd_184;
double gd_192;

int init() {
   return (0);
}

int deinit() {
   ObjectsDeleteAll(0, OBJ_TREND);
   ObjectsDeleteAll(0, OBJ_TEXT);
   return (0);
}

int start() {
   g_ihigh_80 = iHigh(NULL, PERIOD_D1, 1);
   g_ilow_88 = iLow(NULL, PERIOD_D1, 1);
   g_iopen_96 = iOpen(NULL, PERIOD_D1, 1);
   g_iclose_104 = iClose(NULL, PERIOD_D1, 1);
   gd_112 = NormalizeDouble((g_ihigh_80 + g_ilow_88 + g_iclose_104) / 3.0, Digits);
   gd_120 = NormalizeDouble(gd_112 + 20.0 * Point, Digits);
   gd_128 = NormalizeDouble(gd_112 + 40.0 * Point, Digits);
   gd_160 = NormalizeDouble(gd_112 - 20.0 * Point, Digits);
   gd_168 = NormalizeDouble(gd_112 - 40.0 * Point, Digits);
   gd_152 = NormalizeDouble(2.0 * gd_112 + (g_ihigh_80 - 2.0 * g_ilow_88) + 5.0 * Point, Digits);
   gd_192 = NormalizeDouble(2.0 * gd_112 - (2.0 * g_ihigh_80 - g_ilow_88) - 5.0 * Point, Digits);
   gd_144 = NormalizeDouble(gd_112 + (g_ihigh_80 - g_ilow_88) + 5.0 * Point, Digits);
   gd_184 = NormalizeDouble(gd_112 - (g_ihigh_80 - g_ilow_88) - 5.0 * Point, Digits);
   gd_136 = NormalizeDouble(gd_120 + gd_112 - g_ilow_88 - 5.0 * Point, Digits);
   gd_176 = NormalizeDouble(gd_160 + gd_112 - g_ihigh_80 + 5.0 * Point, Digits);
   int l_datetime_0 = iTime(NULL, PERIOD_D1, 0);
   int l_datetime_4 = iTime(NULL, PERIOD_D1, 1);
   int l_datetime_8 = iTime(NULL, 0, 0);
   creatTrendLineObj2("[Golden MA] Line YH", l_datetime_4, g_ihigh_80, l_datetime_8, g_ihigh_80, Orange, 1, STYLE_DOT);
   createTextObj("[Golden MA] Text YH", l_datetime_4, g_ihigh_80, StringConcatenate("[Yesterday High]: ", g_ihigh_80));
   creatTrendLineObj2("[Golden MA] Line YL", l_datetime_4, g_ilow_88, l_datetime_8, g_ilow_88, Orange, 1, STYLE_DOT);
   createTextObj("[Golden MA] Text YL", l_datetime_4, g_ilow_88, StringConcatenate("[Yesterday Low]: ", g_ilow_88));
   creatTrendLineObj2("[Golden MA] Line YS", l_datetime_4, 0, l_datetime_4, 1, DarkGray, 1, STYLE_DOT);
   creatTrendLineObj2("[Golden MA] Line YE", l_datetime_0, 0, l_datetime_0, 1, DarkGray, 1, STYLE_DOT);
   creatTrendLineObj("[Golden MA] Line M", l_datetime_0, gd_112, l_datetime_8, Gray, 5);
   creatTrendLineObj("[Golden MA] Line H1", l_datetime_0, gd_120, l_datetime_8, DarkBlue, 5);
   creatTrendLineObj("[Golden MA] Line H2", l_datetime_0, gd_128, l_datetime_8, DarkBlue, 5);
   creatTrendLineObj("[Golden MA] Line H3", l_datetime_0, gd_136, l_datetime_8, DarkBlue, 5);
   creatTrendLineObj("[Golden MA] Line H4", l_datetime_0, gd_144, l_datetime_8, DarkBlue, 5);
   creatTrendLineObj("[Golden MA] Line H5", l_datetime_0, gd_152, l_datetime_8, DarkBlue, 5);
   creatTrendLineObj("[Golden MA] Line L1", l_datetime_0, gd_160, l_datetime_8, Maroon, 5);
   creatTrendLineObj("[Golden MA] Line L2", l_datetime_0, gd_168, l_datetime_8, Maroon, 5);
   creatTrendLineObj("[Golden MA] Line L3", l_datetime_0, gd_176, l_datetime_8, Maroon, 5);
   creatTrendLineObj("[Golden MA] Line L4", l_datetime_0, gd_184, l_datetime_8, Maroon, 5);
   creatTrendLineObj("[Golden MA] Line L5", l_datetime_0, gd_192, l_datetime_8, Maroon, 5);
   if (showPriceLabel) {
      createTextObj("[Golden MA] Text M", l_datetime_0, gd_112, StringConcatenate("[Middle Area]: ", gd_112));
      createTextObj("[Golden MA] Text H1", l_datetime_0, gd_120, StringConcatenate("[Buy Area] Start: ", gd_120));
      createTextObj("[Golden MA] Text H2", l_datetime_0, gd_128, StringConcatenate("[Buy Area] End: ", gd_128));
      createTextObj("[Golden MA] Text H3", l_datetime_0, gd_136, StringConcatenate("[Reversal High]: ", gd_136));
      createTextObj("[Golden MA] Text H4", l_datetime_0, gd_144, StringConcatenate("[WARNING! OVERBOUGHT]: ", gd_144));
      createTextObj("[Golden MA] Text H5", l_datetime_0, gd_152, StringConcatenate("[DANGER! STOP BUY HERE!]: ", gd_152));
      createTextObj("[Golden MA] Text L1", l_datetime_0, gd_160, StringConcatenate("[Sell Area] Start: ", gd_160));
      createTextObj("[Golden MA] Text L2", l_datetime_0, gd_168, StringConcatenate("[Sell Area] End: ", gd_168));
      createTextObj("[Golden MA] Text L3", l_datetime_0, gd_176, StringConcatenate("[Reversal Low]: ", gd_176));
      createTextObj("[Golden MA] Text L4", l_datetime_0, gd_184, StringConcatenate("[WARNING! OVERSOLD]: ", gd_184));
      createTextObj("[Golden MA] Text L5", l_datetime_0, gd_192, StringConcatenate("[DANGER! STOP SELL HERE!]: ", gd_192));
   }
   for (int li_12 = 1; li_12 < 20; li_12++) {
      creatTrendLineObj(StringConcatenate("[Golden MA] Line HH", li_12), l_datetime_0, gd_120 + li_12 * Point, l_datetime_8, DarkBlue, 1);
      creatTrendLineObj(StringConcatenate("[Golden MA] Line LL", li_12), l_datetime_0, gd_168 + li_12 * Point, l_datetime_8, Maroon, 1);
      creatTrendLineObj(StringConcatenate("[Golden MA] Line MH", li_12), l_datetime_0, gd_112 + li_12 * Point, l_datetime_8, Gray, 1);
      creatTrendLineObj(StringConcatenate("[Golden MA] Line ML", li_12), l_datetime_0, gd_112 - li_12 * Point, l_datetime_8, Gray, 1);
   }
   return (0);
}

void creatTrendLineObj(string a_name_0, int a_datetime_8, double a_price_12, int a_datetime_20, color a_color_24, int a_width_28) {
   ObjectDelete(a_name_0);
   ObjectCreate(a_name_0, OBJ_TREND, 0, a_datetime_8, a_price_12, a_datetime_20, a_price_12);
   ObjectSet(a_name_0, OBJPROP_BACK, TRUE);
   ObjectSet(a_name_0, OBJPROP_COLOR, a_color_24);
   ObjectSet(a_name_0, OBJPROP_WIDTH, a_width_28);
}

void creatTrendLineObj2(string a_name_0, int a_datetime_8, double a_price_12, int a_datetime_20, double a_price_24, color a_color_32, int a_width_36, int a_style_40) {
   ObjectDelete(a_name_0);
   ObjectCreate(a_name_0, OBJ_TREND, 0, a_datetime_8, a_price_12, a_datetime_20, a_price_24);
   ObjectSet(a_name_0, OBJPROP_BACK, TRUE);
   ObjectSet(a_name_0, OBJPROP_COLOR, a_color_32);
   ObjectSet(a_name_0, OBJPROP_WIDTH, a_width_36);
   ObjectSet(a_name_0, OBJPROP_STYLE, a_style_40);
}

void createTextObj(string a_name_0, int a_datetime_8, double a_price_12, string a_text_20) {
   ObjectDelete(a_name_0);
   ObjectCreate(a_name_0, OBJ_TEXT, 0, a_datetime_8, a_price_12);
   ObjectSetText(a_name_0, a_text_20, 8, "Arial", White);
}

修改为5位数报价平台,修改成周线的周期,就是现在的计算方法是每天改为周,从周一开始一直显示一周的压力支撑,原指标是每天都不同


打赏