#property copyright "Copyright ゥ 2004, MetaQuotes Software Corp." #property link "http://www.metaquotes.net/" #property indicator_separate_window #property indicator_levelcolor DimGray #property indicator_buffers 8 #property indicator_color1 Peru #property indicator_color2 Crimson #property indicator_color3 RoyalBlue #property indicator_color4 LimeGreen #property indicator_color5 Crimson #property indicator_color6 RoyalBlue #property indicator_color7 BurlyWood #property indicator_color8 Coral #property indicator_width1 1 #property indicator_level1 -80.0 #property indicator_width2 1 #property indicator_width3 1 #property indicator_level3 80.0 #include string gs_76; string gs_unused_84; extern bool ScalMode = FALSE; extern bool LongTerm = TRUE; extern bool ShortLines = TRUE; extern bool LongLines = TRUE; int gi_108 = 7; int gi_112 = 9; int gi_116 = 14; int gi_120 = 26; int gi_124 = 34; int gi_128 = 52; extern int smoothing = 0; extern int LineWidth = 1; extern bool Show_Value = FALSE; extern int CalculateBars = 500; extern bool direction = TRUE; extern bool RSI_Stars = TRUE; extern int RSI_Period = 9; extern int RSI_Style = 3; extern int RSI_Level1 = 25; extern int RSI_Level2 = 30; extern int RSI_Level3 = 70; extern int RSI_Level4 = 75; extern double RSI_Showlevel1 = -40.0; extern double RSI_Showlevel2 = -30.0; extern double RSI_Showlevel3 = 30.0; extern double RSI_Showlevel4 = 40.0; extern bool ShowLine1 = TRUE; extern bool ShowLine2 = TRUE; extern bool ShowLine3 = TRUE; extern bool ShowLine4 = TRUE; extern bool ShowLine5 = TRUE; extern bool ShowLine6 = TRUE; double g_ibuf_236[]; double g_ibuf_240[]; double g_ibuf_244[]; double g_ibuf_248[]; double g_ibuf_252[]; double g_ibuf_256[]; double gda_260[]; double gda_264[]; double gda_268[]; double gda_272[]; double gda_276[]; double gda_280[]; int gia_284[]; int gia_288[]; int gia_292[]; int gia_296[]; int gia_300[]; int gia_304[]; int gia_308[]; int gia_312[]; int gia_316[]; int gia_320[]; int gia_324[]; int gia_328[]; double g_ibuf_332[]; double g_ibuf_336[]; double gd_340; int gi_348; int libSystemStart(string as_0 = "") { string ls_8 = ""; string ls_16 = ""; bool li_ret_24 = TRUE; ls_8 = "VERSION1"; ls_16 = "Version"; libObjectLabel(as_0, ls_8); libObjectLabel(as_0, ls_8, ls_16, 7, "MSゴシック", 2, 15, Gray); ls_8 = "VERSION2"; ls_16 = "9.1.0"; libObjectLabel(as_0, ls_8); libObjectLabel(as_0, ls_8, ls_16, 8, "MSゴシック", 35, 15, Gray); int l_str2time_28 = StrToTime("2020/01/31"); string l_time2str_32 = TimeToStr(TimeLocal(), TIME_DATE); string l_time2str_40 = TimeToStr(l_str2time_28, TIME_DATE); if (l_time2str_32 > l_time2str_40) { ls_8 = "UseTimeLimitError"; ls_16 = ""; libObjectLabel(as_0, ls_8); ls_16 = "利用期限を過ぎています。" + "(期限 " + l_time2str_40 + " まで)"; libObjectLabel(as_0, ls_8, ls_16, 8, "MSゴシック", 67, 15, Orange); libMsgBox(as_0, ls_16, "メッセージ", 0); li_ret_24 = FALSE; } return (li_ret_24); } void libObjectLabel(string as_0 = "", string a_name_8 = "", string a_text_16 = "", int a_fontsize_24 = 0, string a_fontname_28 = "", int a_x_36 = 0, int a_y_40 = 0, color a_color_44 = 0) { int li_48 = 0; if (as_0 != "") li_48 = WindowFind(as_0); if (li_48 > EMPTY && WindowIsVisible(li_48) == 1) { if (a_name_8 == "") ObjectsDeleteAll(li_48, OBJ_LABEL); else { if (a_text_16 == "") ObjectDelete(a_name_8); else { ObjectCreate(a_name_8, OBJ_LABEL, li_48, 0, 0); ObjectSetText(a_name_8, a_text_16, a_fontsize_24, a_fontname_28, a_color_44); ObjectSet(a_name_8, OBJPROP_CORNER, 0); ObjectSet(a_name_8, OBJPROP_XDISTANCE, a_x_36); ObjectSet(a_name_8, OBJPROP_YDISTANCE, a_y_40); } } } } void libMsgBox(string as_0 = "", string as_8 = "", string as_16 = "", string as_unused_24 = "") { int li_32 = 0; string ls_36 = as_8; string ls_44 = as_16; bool li_52 = FALSE; if (as_0 != "") li_32 = WindowFind(as_0); li_32 = 0; int li_56 = MessageBoxA(li_32, ls_36, ls_44, li_52); } int init() { if (LongTerm == TRUE) { gi_108 = 7; gi_112 = 9; gi_116 = 14; gi_120 = 26; gi_124 = 34; gi_128 = 52; } else { gi_108 = 7; gi_112 = 9; gi_116 = 14; gi_120 = 20; gi_124 = 26; gi_128 = 34; } int l_timeframe_0 = Period(); switch (l_timeframe_0) { case PERIOD_M1: gs_unused_84 = "M1"; break; case PERIOD_M5: gs_unused_84 = "M5"; break; case PERIOD_M15: gs_unused_84 = "M15"; break; case PERIOD_M30: gs_unused_84 = "M30"; break; case PERIOD_H1: gs_unused_84 = "H1"; break; case PERIOD_H4: gs_unused_84 = "H4"; break; case PERIOD_D1: gs_unused_84 = "D1"; break; case PERIOD_W1: gs_unused_84 = "W1"; break; case PERIOD_MN1: gs_unused_84 = "MN1"; break; default: gs_unused_84 = ""; } gs_76 = "HEi_RCI"; IndicatorShortName(gs_76); if (libSystemStart(gs_76) == 0) return (0); SetIndexBuffer(0, g_ibuf_256); SetIndexBuffer(1, g_ibuf_252); SetIndexBuffer(2, g_ibuf_248); SetIndexBuffer(3, g_ibuf_244); SetIndexBuffer(4, g_ibuf_240); SetIndexBuffer(5, g_ibuf_236); SetIndexLabel(0, "Line " + gi_128); SetIndexLabel(1, "Line " + gi_124); SetIndexLabel(2, "Line " + gi_120); SetIndexLabel(3, "Line " + gi_116); SetIndexLabel(4, "Line " + gi_112); SetIndexLabel(5, "Line " + gi_108); if (!Show_Value) { SetIndexLabel(0, NULL); SetIndexLabel(1, NULL); SetIndexLabel(2, NULL); SetIndexLabel(3, NULL); SetIndexLabel(4, NULL); SetIndexLabel(5, NULL); } if (ScalMode == TRUE) { SetIndexStyle(0, DRAW_LINE, STYLE_DOT, LineWidth); SetIndexStyle(1, DRAW_LINE, STYLE_DOT, LineWidth); SetIndexStyle(2, DRAW_LINE, STYLE_DOT, LineWidth); SetIndexStyle(3, DRAW_LINE, STYLE_SOLID, LineWidth); SetIndexStyle(4, DRAW_LINE, STYLE_SOLID, LineWidth); SetIndexStyle(5, DRAW_LINE, STYLE_SOLID, LineWidth); } else { SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, LineWidth); SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, LineWidth); SetIndexStyle(2, DRAW_LINE, STYLE_SOLID, LineWidth); SetIndexStyle(3, DRAW_LINE, STYLE_DOT, LineWidth); SetIndexStyle(4, DRAW_LINE, STYLE_DOT, LineWidth); SetIndexStyle(5, DRAW_LINE, STYLE_DOT, LineWidth); } if (gi_348 <= 0) gi_348 = 10; if (CalculateBars < 0) CalculateBars = 0; SetIndexBuffer(6, g_ibuf_332); SetIndexBuffer(7, g_ibuf_336); if (RSI_Style == 1 || RSI_Style == 2) { SetIndexLabel(6, "RSI Heat"); SetIndexLabel(7, "RSI Max"); SetIndexStyle(6, DRAW_ARROW, STYLE_SOLID, 1, BurlyWood); SetIndexStyle(7, DRAW_ARROW, STYLE_SOLID, 1, Coral); SetIndexArrow(6, 171); SetIndexArrow(7, 171); } else { if (RSI_Style == 3) { SetIndexLabel(6, "RSI up"); SetIndexLabel(7, "RSI down"); SetIndexStyle(6, DRAW_ARROW, STYLE_SOLID, 1, Khaki); SetIndexStyle(7, DRAW_ARROW, STYLE_SOLID, 1, Khaki); SetIndexArrow(6, 200); SetIndexArrow(7, 202); } } if (!Show_Value) { SetIndexLabel(6, NULL); SetIndexLabel(7, NULL); } if (RSI_Stars == FALSE) SetIndexStyle(6, DRAW_NONE); if (RSI_Stars == FALSE) SetIndexStyle(7, DRAW_NONE); if (ShowLine1 == FALSE) SetIndexStyle(0, DRAW_NONE); if (ShowLine2 == FALSE) SetIndexStyle(1, DRAW_NONE); if (ShowLine3 == FALSE) SetIndexStyle(2, DRAW_NONE); if (ShowLine4 == FALSE) SetIndexStyle(3, DRAW_NONE); if (ShowLine5 == FALSE) SetIndexStyle(4, DRAW_NONE); if (ShowLine6 == FALSE) SetIndexStyle(5, DRAW_NONE); if (LongLines == FALSE) SetIndexStyle(0, DRAW_NONE); if (LongLines == FALSE) SetIndexStyle(1, DRAW_NONE); if (LongLines == FALSE) SetIndexStyle(2, DRAW_NONE); if (ShortLines == FALSE) SetIndexStyle(3, DRAW_NONE); if (ShortLines == FALSE) SetIndexStyle(4, DRAW_NONE); if (ShortLines == FALSE) SetIndexStyle(5, DRAW_NONE); if (CalculateBars > 0) { SetIndexDrawBegin(0, Bars - CalculateBars); SetIndexDrawBegin(1, Bars - CalculateBars); SetIndexDrawBegin(2, Bars - CalculateBars); SetIndexDrawBegin(3, Bars - CalculateBars); SetIndexDrawBegin(4, Bars - CalculateBars); SetIndexDrawBegin(5, Bars - CalculateBars); SetIndexDrawBegin(6, Bars - CalculateBars); SetIndexDrawBegin(7, Bars - CalculateBars); } ArrayResize(gda_260, gi_108); ArrayResize(gda_264, gi_112); ArrayResize(gda_268, gi_116); ArrayResize(gda_272, gi_120); ArrayResize(gda_276, gi_124); ArrayResize(gda_280, gi_128); ArrayResize(gia_284, gi_108); ArrayResize(gia_288, gi_112); ArrayResize(gia_292, gi_116); ArrayResize(gia_296, gi_120); ArrayResize(gia_300, gi_124); ArrayResize(gia_304, gi_128); ArrayResize(gia_308, gi_108); ArrayResize(gia_312, gi_112); ArrayResize(gia_316, gi_116); ArrayResize(gia_320, gi_120); ArrayResize(gia_324, gi_124); ArrayResize(gia_328, gi_128); gd_340 = MathPow(10, Digits); gi_348 = gi_108; if (gi_112 > gi_348) gi_348 = gi_112; if (gi_116 > gi_348) gi_348 = gi_116; if (gi_120 > gi_348) gi_348 = gi_120; if (gi_124 > gi_348) gi_348 = gi_124; if (gi_128 > gi_348) gi_348 = gi_128; return (0); } int start() { int li_12; double l_irsi_16; double l_irsi_24; int l_ind_counted_0 = IndicatorCounted(); if (l_ind_counted_0 == 0) { if (CalculateBars == 0) li_12 = Bars - gi_108; else li_12 = CalculateBars; } if (l_ind_counted_0 > 0) li_12 = Bars - l_ind_counted_0; for (int li_4 = li_12; li_4 >= 0; li_4--) { for (int l_index_8 = 0; l_index_8 < gi_128; l_index_8++) gia_304[l_index_8] = (Close[li_4 + l_index_8]) * gd_340; RankPrices(gia_304, 6); g_ibuf_256[li_4] = 100.0 * SpearmanRankCorrelation(gda_280, gi_128); for (l_index_8 = 0; l_index_8 < gi_124; l_index_8++) gia_300[l_index_8] = (Close[li_4 + l_index_8]) * gd_340; RankPrices(gia_300, 5); g_ibuf_252[li_4] = 100.0 * SpearmanRankCorrelation(gda_276, gi_124); for (l_index_8 = 0; l_index_8 < gi_120; l_index_8++) gia_296[l_index_8] = (Close[li_4 + l_index_8]) * gd_340; RankPrices(gia_296, 4); g_ibuf_248[li_4] = 100.0 * SpearmanRankCorrelation(gda_272, gi_120); for (l_index_8 = 0; l_index_8 < gi_116; l_index_8++) gia_292[l_index_8] = (Close[li_4 + l_index_8]) * gd_340; RankPrices(gia_292, 3); g_ibuf_244[li_4] = 100.0 * SpearmanRankCorrelation(gda_268, gi_116); for (l_index_8 = 0; l_index_8 < gi_112; l_index_8++) gia_288[l_index_8] = (Close[li_4 + l_index_8]) * gd_340; RankPrices(gia_288, 2); g_ibuf_240[li_4] = 100.0 * SpearmanRankCorrelation(gda_264, gi_112); for (l_index_8 = 0; l_index_8 < gi_108; l_index_8++) gia_284[l_index_8] = (Close[li_4 + l_index_8]) * gd_340; RankPrices(gia_284, 1); g_ibuf_236[li_4] = 100.0 * SpearmanRankCorrelation(gda_260, gi_108); } if (smoothing > 0) { for (li_4 = 0; li_4 < li_12; li_4++) { g_ibuf_236[li_4] = iMAOnArray(g_ibuf_236, Bars, smoothing, 0, MODE_LWMA, li_4); g_ibuf_240[li_4] = iMAOnArray(g_ibuf_240, Bars, smoothing, 0, MODE_LWMA, li_4); g_ibuf_244[li_4] = iMAOnArray(g_ibuf_244, Bars, smoothing, 0, MODE_LWMA, li_4); g_ibuf_248[li_4] = iMAOnArray(g_ibuf_248, Bars, smoothing, 0, MODE_LWMA, li_4); g_ibuf_252[li_4] = iMAOnArray(g_ibuf_252, Bars, smoothing, 0, MODE_LWMA, li_4); g_ibuf_256[li_4] = iMAOnArray(g_ibuf_256, Bars, smoothing, 0, MODE_LWMA, li_4); } } if (RSI_Stars == TRUE) { for (li_4 = li_12 - 1; li_4 >= 0; li_4--) { l_irsi_16 = iRSI(NULL, 0, RSI_Period, PRICE_CLOSE, li_4); l_irsi_24 = iRSI(NULL, 0, RSI_Period, PRICE_CLOSE, li_4 + 1); g_ibuf_332[li_4] = EMPTY_VALUE; if (l_irsi_16 <= RSI_Level2) { if (RSI_Style == 1) g_ibuf_336[li_4] = RSI_Showlevel1; if (RSI_Style == 2) g_ibuf_336[li_4] = g_ibuf_236[li_4]; if (RSI_Style == 3) g_ibuf_336[li_4] = RSI_Showlevel1; if (l_irsi_16 <= RSI_Level1) { g_ibuf_332[li_4] = EMPTY_VALUE; g_ibuf_336[li_4] = EMPTY_VALUE; if (RSI_Style == 1) g_ibuf_332[li_4] = RSI_Showlevel1; if (RSI_Style == 2) g_ibuf_332[li_4] = g_ibuf_236[li_4]; } if (RSI_Style == 3) g_ibuf_332[li_4] = EMPTY_VALUE; if (RSI_Style == 3) g_ibuf_336[li_4] = EMPTY_VALUE; } if (l_irsi_16 > RSI_Level2 && l_irsi_24 <= RSI_Level2) if (RSI_Style == 3) g_ibuf_332[li_4] = RSI_Showlevel2; if (l_irsi_16 >= RSI_Level3) { if (RSI_Style == 1) g_ibuf_336[li_4] = RSI_Showlevel4; if (RSI_Style == 2) g_ibuf_336[li_4] = g_ibuf_236[li_4]; if (l_irsi_16 >= RSI_Level4) { g_ibuf_332[li_4] = EMPTY_VALUE; g_ibuf_336[li_4] = EMPTY_VALUE; if (RSI_Style == 1) g_ibuf_332[li_4] = RSI_Showlevel4; if (RSI_Style == 2) g_ibuf_332[li_4] = g_ibuf_236[li_4]; } if (RSI_Style == 3) g_ibuf_332[li_4] = EMPTY_VALUE; if (RSI_Style == 3) g_ibuf_336[li_4] = EMPTY_VALUE; } if (l_irsi_16 < RSI_Level3 && l_irsi_24 >= RSI_Level4) if (RSI_Style == 3) g_ibuf_336[li_4] = RSI_Showlevel3; } } return (0); } double SpearmanRankCorrelation(double ada_0[], int ai_4) { double ld_16; for (int l_index_24 = 0; l_index_24 < ai_4; l_index_24++) ld_16 += MathPow(ada_0[l_index_24] - l_index_24 - 1.0, 2); double ld_ret_8 = 1 - 6.0 * ld_16 / (MathPow(ai_4, 3) - ai_4); return (ld_ret_8); } void RankPrices(int aia_0[], int ai_4) { int l_index_12; int li_20; int li_24; int li_28; double ld_32; double ld_40; double lda_48[]; ArrayResize(lda_48, gi_348); if (ai_4 == 1) ArrayCopy(gia_308, aia_0); if (ai_4 == 2) ArrayCopy(gia_312, aia_0); if (ai_4 == 3) ArrayCopy(gia_316, aia_0); if (ai_4 == 4) ArrayCopy(gia_320, aia_0); if (ai_4 == 5) ArrayCopy(gia_324, aia_0); if (ai_4 == 6) ArrayCopy(gia_328, aia_0); for (int l_index_8 = 0; l_index_8 < gi_348; l_index_8++) lda_48[l_index_8] = l_index_8 + 1; if (direction) { if (ai_4 == 1) ArraySort(gia_308, WHOLE_ARRAY, 0, MODE_DESCEND); if (ai_4 == 2) ArraySort(gia_312, WHOLE_ARRAY, 0, MODE_DESCEND); if (ai_4 == 3) ArraySort(gia_316, WHOLE_ARRAY, 0, MODE_DESCEND); if (ai_4 == 4) ArraySort(gia_320, WHOLE_ARRAY, 0, MODE_DESCEND); if (ai_4 == 5) ArraySort(gia_324, WHOLE_ARRAY, 0, MODE_DESCEND); if (ai_4 == 6) ArraySort(gia_328, WHOLE_ARRAY, 0, MODE_DESCEND); } else { if (ai_4 == 1) ArraySort(gia_308, WHOLE_ARRAY, 0, MODE_ASCEND); if (ai_4 == 2) ArraySort(gia_312, WHOLE_ARRAY, 0, MODE_ASCEND); if (ai_4 == 3) ArraySort(gia_316, WHOLE_ARRAY, 0, MODE_ASCEND); if (ai_4 == 4) ArraySort(gia_320, WHOLE_ARRAY, 0, MODE_ASCEND); if (ai_4 == 5) ArraySort(gia_324, WHOLE_ARRAY, 0, MODE_ASCEND); if (ai_4 == 6) ArraySort(gia_328, WHOLE_ARRAY, 0, MODE_ASCEND); } for (l_index_8 = 0; l_index_8 < gi_348 - 1; l_index_8++) { if (ai_4 == 1) { if (gia_308[l_index_8] != gia_308[l_index_8 + 1]) continue; li_20 = gia_308[l_index_8]; } else { if (ai_4 == 2) { if (gia_312[l_index_8] != gia_312[l_index_8 + 1]) continue; li_20 = gia_312[l_index_8]; } else { if (ai_4 == 3) { if (gia_316[l_index_8] != gia_316[l_index_8 + 1]) continue; li_20 = gia_316[l_index_8]; } else { if (ai_4 == 4) { if (gia_320[l_index_8] != gia_320[l_index_8 + 1]) continue; li_20 = gia_320[l_index_8]; } else { if (ai_4 == 5) { if (gia_324[l_index_8] != gia_324[l_index_8 + 1]) continue; li_20 = gia_324[l_index_8]; } } } } } if (ai_4 == 6) { if (gia_328[l_index_8] != gia_328[l_index_8 + 1]) continue; li_20 = gia_328[l_index_8]; } l_index_12 = l_index_8 + 1; li_24 = 1; ld_40 = l_index_8 + 1; while (l_index_12 < gi_348) { if (ai_4 == 1) { if (gia_308[l_index_12] != li_20) break; li_24++; ld_40 += l_index_12 + 1; l_index_12++; } else { if (ai_4 == 2) { if (gia_312[l_index_12] != li_20) break; li_24++; ld_40 += l_index_12 + 1; l_index_12++; } else { if (ai_4 == 3) { if (gia_316[l_index_12] != li_20) break; li_24++; ld_40 += l_index_12 + 1; l_index_12++; } else { if (ai_4 == 4) { if (gia_320[l_index_12] != li_20) break; li_24++; ld_40 += l_index_12 + 1; l_index_12++; } else { if (ai_4 == 5) { if (gia_324[l_index_12] != li_20) break; li_24++; ld_40 += l_index_12 + 1; l_index_12++; } else { if (ai_4 == 6) { if (gia_328[l_index_12] != li_20) break; li_24++; ld_40 += l_index_12 + 1; l_index_12++; } } } } } } } ld_32 = li_24; ld_40 /= ld_32; for (int li_16 = l_index_8; li_16 < l_index_12; li_16++) lda_48[li_16] = ld_40; l_index_8 = l_index_12; } for (l_index_8 = 0; l_index_8 < gi_348; l_index_8++) { li_28 = aia_0[l_index_8]; for (l_index_12 = 0; l_index_12 < gi_348; l_index_12++) { if (ai_4 == 1) { if (li_28 != gia_308[l_index_12]) continue; gda_260[l_index_8] = lda_48[l_index_12]; break; } if (ai_4 == 2) { if (li_28 != gia_312[l_index_12]) continue; gda_264[l_index_8] = lda_48[l_index_12]; break; } if (ai_4 == 3) { if (li_28 != gia_316[l_index_12]) continue; gda_268[l_index_8] = lda_48[l_index_12]; break; } if (ai_4 == 4) { if (li_28 != gia_320[l_index_12]) continue; gda_272[l_index_8] = lda_48[l_index_12]; break; } if (ai_4 == 5) { if (li_28 != gia_324[l_index_12]) continue; gda_276[l_index_8] = lda_48[l_index_12]; break; } if (ai_4 == 6) { if (li_28 == gia_328[l_index_12]) { gda_280[l_index_8] = lda_48[l_index_12]; break; } } } } }