标签:
杂谈 |
查看原文:http://www.125808047.com/?p=2121
iHigh_iLow指标在图表中计算当前货币日线的振幅,包括今日昨日价格最高点最低点和日内波动幅度及指定日期平均波动幅度,同时显示今日开盘收盘等信息。
iHigh_iLow指标图表效果如下:http://www.125808047.com/fgp/wp-content/uploads/2016/03/2016032204-300x89.jpg
iHigh_iLow指标源码如下:
//+------------------------------------------------------------------+ //| iHigh_iLow.mq4 | //| Copyright 2016, QQ:125808047 | //+------------------------------------------------------------------+ #property copyright "www.125808047.com" #property link "http://www.125808047.com/" #property indicator_chart_window //#include <stdlib.mqh> #import "stdlib.ex4" string ErrorDescription(int a0); #import extern bool Corner_Right_Top = TRUE; extern bool 详细资料_Enabled = TRUE; extern bool K线时间_Enabled = TRUE; int gi_unused_88 = 15453831; bool gi_92; int gia_unused_96[18]; int gia_unused_100[18]; int gia_unused_104[18]; int gia_unused_108[8]; int gia_unused_112[8]; int gia_116[9] = {4, 10, 25, 40, 50, 60, 75, 90, 97}; int gia_120[10] = {10495, 20735, 30975, 41215, 48895, 46280, 51350, 56420, 61490, 65280}; extern bool 昨天价值_Enabled = TRUE; bool gi_128 = FALSE; bool gi_unused_132 = FALSE; extern int Corner_lower_right = 3; extern int 移动上下 = 10; extern int 移动左右 = 15; extern int iFrame = 1440; extern int 昨天价值_Shift = 100; extern color 开盘最高最低_color1 = SkyBlue; extern color 开盘最高最低_color2 = Orange; extern color 开盘涨跌_color1 = Lime; extern color 开盘涨跌_color2 = Red; extern color 统计_color1 = WhiteSmoke; extern color 统计_color2 = Yellow; extern color 平均_color1 = Orange; extern color 平均_color2 = Lime; extern color 点差_color1 = SkyBlue; extern color 点差_color2 = Gold; extern color 价格显示_color1 = LawnGreen; extern color 价格显示_color2 = Red; extern color K线时间_color = Yellow; extern color cPivot = Yellow; extern color cRS1 = Green; extern color cRS2 = Green; extern color cRS3 = Red; int gi_224; string gsa_228[] = {"GBPJPY"}; string gsa_232[] = {"EURUSD", "GBPUSD", "AUDUSD", "USDJPY", "USDCHF", "USDCAD", "EURJPY", "EURGBP", "EURCHF", "EURAUD", "GBPJPY", "GBPCHF", "CADJPY", "EURCAD", "AUDCAD", "AUDJPY", "AUDNZD", "NZDUSD"}; string gsa_236[] = {"USD", "EUR", "GBP", "CHF", "CAD", "AUD", "JPY", "NZD"}; int gia_240[] = {115, 100, 85, 70, 55, 40, 25, 10}; int gi_244; int gi_248; double gda_252[]; double gda_256[]; double gda_260[]; double gda_264[]; double gda_268[]; double gda_272[]; double gda_276[]; double gda_280[]; double gda_284[]; int init() { gi_244 = ArrayRange(gsa_232, 0); gi_248 = ArrayRange(gsa_236, 0); int li_0 = ArrayRange(gia_240, 0); if (gi_248 != li_0) Print("The size of array aMajor is not equals to aMajorPos"); ArrayResize(gda_252, gi_248); ArrayResize(gda_256, gi_244); ArrayResize(gda_260, gi_244); ArrayResize(gda_264, gi_244); ArrayResize(gda_268, gi_244); ArrayResize(gda_272, gi_244); ArrayResize(gda_276, gi_244); ArrayResize(gda_280, gi_244); ArrayResize(gda_284, gi_244); gi_92 = TRUE; return (0); } int deinit() { ObjectDelete("P LINE"); ObjectDelete("R1 LINE"); ObjectDelete("R2 LINE"); ObjectDelete("R3 LINE"); ObjectDelete("S1 LINE"); ObjectDelete("S2 LINE"); ObjectDelete("S3 LINE"); ObjectDelete("PIVOTTEXT"); ObjectDelete("R1TEXT"); ObjectDelete("R1TEXT"); ObjectDelete("R3TEXT"); ObjectDelete("S1TEXT"); ObjectDelete("S2TEXT"); ObjectDelete("S3TEXT"); ObjectsDeleteAll(0, OBJ_LABEL); Print("shutdown error - ", ErrorDescription(GetLastError())); ObjectsDeleteAll(0, OBJ_TEXT); return (0); } int start() { int digits_4; color color_16; color color_20; int li_unused_24; double ima_184; if (gi_92) gi_92 = FALSE; int ind_counted_28 = IndicatorCounted(); int timeframe_32 = 0; double ld_36 = 0; double ld_44 = 0; double ld_52 = 0; double ld_60 = 0; double ld_68 = 0; double ld_76 = 0; double ld_84 = 0; double ld_92 = 0; double ld_100 = 0; double ld_108 = 0; double ld_116 = 0; double iopen_124 = iOpen(NULL, PERIOD_D1, 0); double iclose_132 = iClose(NULL, PERIOD_D1, 0); double ld_140 = (Ask - Bid) / Point; double ihigh_148 = iHigh(NULL, PERIOD_D1, 0); double ilow_156 = iLow(NULL, PERIOD_D1, 0); if (gi_128) { ld_36 = High[1]; ld_44 = Low[1]; ld_52 = Close[1]; ld_60 = Open[0]; } else { switch (iFrame) { case 1: timeframe_32 = 1; break; case 5: timeframe_32 = 5; break; case 15: timeframe_32 = 15; break; case 30: timeframe_32 = 30; break; case 60: timeframe_32 = 60; break; case 240: timeframe_32 = 240; break; case 1440: timeframe_32 = 1440; break; case 10080: timeframe_32 = 10080; break; case 43200: timeframe_32 = 43200; break; default: timeframe_32 = 1440; } ld_36 = iHigh(NULL, timeframe_32, 1); ld_44 = iLow(NULL, timeframe_32, 1); ld_52 = iClose(NULL, timeframe_32, 1); ld_60 = iOpen(NULL, timeframe_32, 0); } ld_68 = (ld_36 + ld_44 + ld_52) / 3.0; ld_100 = 2.0 * ld_68 - ld_44; ld_76 = 2.0 * ld_68 - ld_36; ld_108 = ld_68 + (ld_100 - ld_76); ld_84 = ld_68 - (ld_100 - ld_76); ld_116 = ld_36 + 2.0 * (ld_68 - ld_44); ld_92 = ld_44 - 2.0 * (ld_36 - ld_68); int li_168 = Time[0] + 60 * Period() - TimeCurrent(); double ld_172 = li_168 / 60.0; int li_180 = li_168 % 60; li_168 = (li_168 - li_168 % 60) / 60; ObjectDelete("time"); if (K线时间_Enabled == TRUE) { if (ObjectFind("time") != 0) { ObjectCreate("time", OBJ_TEXT, 0, Time[0], Close[0] + 0.0005); ObjectSetText("time", " <--" + li_168 + ":" + li_180, 11, "Verdana", K线时间_color); } else ObjectMove("time", 0, Time[0], Close[0] + 0.0005); } if (StringFind(Symbol(), "JPY", 0) != -1) { digits_4 = 100; digits_4 = Digits; } else { digits_4 = 10000; digits_4 = Digits; } double ima_192 = iMA(Symbol(), 0, 1, 0, MODE_EMA, PRICE_CLOSE, 0); if (ima_192 >= ima_184) color_20 = 价格显示_color1; if (ima_192 < ima_184) color_20 = 价格显示_color2; ima_184 = ima_192; string dbl2str_200 = DoubleToStr(ima_192, Digits); ObjectCreate("Signalprice", OBJ_LABEL, 0, 0, 0); ObjectSetText("Signalprice", "" + dbl2str_200 + "", 18, "Arial Black", color_20); ObjectSet("Signalprice", OBJPROP_CORNER, Corner_Right_Top); ObjectSet("Signalprice", OBJPROP_XDISTANCE, 移动左右 + 1); ObjectSet("Signalprice", OBJPROP_YDISTANCE, 移动上下 + 173); int li_208 = 0; int li_212 = 0; int li_216 = 0; int li_220 = 0; int li_unused_224 = 0; int li_228 = 0; bool li_232 = FALSE; int li_236 = 0; li_208 = (iHigh(NULL, PERIOD_D1, 1) - iLow(NULL, PERIOD_D1, 1)) / Point; for (li_236 = 1; li_236 <= 5; li_236++) li_212 = li_212 + (iHigh(NULL, PERIOD_D1, li_236) - iLow(NULL, PERIOD_D1, li_236)) / Point; for (li_236 = 1; li_236 <= 10; li_236++) li_216 = li_216 + (iHigh(NULL, PERIOD_D1, li_236) - iLow(NULL, PERIOD_D1, li_236)) / Point; for (li_236 = 1; li_236 <= 20; li_236++) li_220 = li_220 + (iHigh(NULL, PERIOD_D1, li_236) - iLow(NULL, PERIOD_D1, li_236)) / Point; li_212 /= 5; li_216 /= 10; li_220 /= 20; li_232 = li_208; li_228 = (li_208 + li_212 + li_216 + li_220) / 4; string ls_unused_240 = ""; string ls_unused_248 = ""; string dbl2str_256 = ""; string dbl2str_264 = ""; string dbl2str_272 = ""; string dbl2str_280 = ""; string dbl2str_288 = ""; string ls_unused_296 = ""; string ls_unused_304 = ""; string ls_312 = ""; dbl2str_264 = DoubleToStr((iclose_132 - iopen_124) / Point, 0); dbl2str_256 = DoubleToStr(ld_140, 0); dbl2str_280 = DoubleToStr(li_228, 0); //dbl2str_272 = DoubleToStr(li_232, -4); ls_312 = (iHigh(NULL, PERIOD_D1, 1) - iLow(NULL, PERIOD_D1, 1)) / Point; dbl2str_272 = DoubleToStr(ls_312, 0); dbl2str_288 = DoubleToStr((ihigh_148 - ilow_156) / Point, 0); if (iclose_132 >= iopen_124) { ls_unused_296 = "-"; color_16 = 开盘涨跌_color1; } if (iclose_132 < iopen_124) { ls_unused_296 = "-"; color_16 = 开盘涨跌_color2; } if (dbl2str_280 > ls_312) { ls_unused_304 = "-"; li_unused_24 = 65280; } if (dbl2str_280 < ls_312) { ls_unused_304 = "-"; li_unused_24 = 17919; } gi_224 = iTime(NULL, PERIOD_H4, 0) - 60 * Period(); if (昨天价值_Enabled == TRUE) { ObjectCreate("昨高 Label", OBJ_LABEL, 0, 0, 0); ObjectSetText("昨高 Label", "/ 昨高", 9, "Verdana", 开盘最高最低_color1); ObjectSet("昨高 Label", OBJPROP_XDISTANCE, 昨天价值_Shift + 150); ObjectSet("昨高 Label", OBJPROP_YDISTANCE, 2); ObjectCreate("昨高 Value", OBJ_LABEL, 0, 0, 0); ObjectSetText("昨高 Value", " " + DoubleToStr(ld_36, digits_4), 9, "Verdana", Red); ObjectSet("昨高 Value", OBJPROP_XDISTANCE, 昨天价值_Shift + 185); ObjectSet("昨高 Value", OBJPROP_YDISTANCE, 2); ObjectCreate("昨低 Label", OBJ_LABEL, 0, 0, 0); ObjectSetText("昨低 Label", "/ 昨低", 9, "Verdana", 开盘最高最低_color1); ObjectSet("昨低 Label", OBJPROP_XDISTANCE, 昨天价值_Shift + 250); ObjectSet("昨低 Label", OBJPROP_YDISTANCE, 2); ObjectCreate("昨低 Value", OBJ_LABEL, 0, 0, 0); ObjectSetText("昨低 Value", " " + DoubleToStr(ld_44, digits_4), 9, "Verdana", Red); ObjectSet("昨低 Value", OBJPROP_XDISTANCE, 昨天价值_Shift + 280); ObjectSet("昨低 Value", OBJPROP_YDISTANCE, 2); ObjectCreate("收盘 Label", OBJ_LABEL, 0, 0, 0); ObjectSetText("收盘 Label", "/ 收盘", 9, "Verdana", 开盘最高最低_color1); ObjectSet("收盘 Label", OBJPROP_XDISTANCE, 昨天价值_Shift + 345); ObjectSet("收盘 Label", OBJPROP_YDISTANCE, 2); ObjectCreate("收盘 Value", OBJ_LABEL, 0, 0, 0); ObjectSetText("收盘 Value", " " + DoubleToStr(ld_52, digits_4), 9, "Verdana", Red); ObjectSet("收盘 Value", OBJPROP_XDISTANCE, 昨天价值_Shift + 375); ObjectSet("收盘 Value", OBJPROP_YDISTANCE, 2); } if (详细资料_Enabled == TRUE) { ObjectCreate("开盘 Label", OBJ_LABEL, 0, 0, 0); ObjectSetText("开盘 Label", "开盘", 9, "Verdana", 开盘最高最低_color1); ObjectSet("开盘 Label", OBJPROP_CORNER, Corner_Right_Top); ObjectSet("开盘 Label", OBJPROP_XDISTANCE, 移动左右 + 62); ObjectSet("开盘 Label", OBJPROP_YDISTANCE, 移动上下 + 2); ObjectCreate("开盘 Value", OBJ_LABEL, 0, 0, 0); ObjectSetText("开盘 Value", " " + DoubleToStr(ld_60, digits_4), 9, "Verdana Bold", 开盘最高最低_color2); ObjectSet("开盘 Value", OBJPROP_CORNER, Corner_Right_Top); ObjectSet("开盘 Value", OBJPROP_XDISTANCE, 移动左右 + 2); ObjectSet("开盘 Value", OBJPROP_YDISTANCE, 移动上下 + 2); ObjectCreate("最高 Label", OBJ_LABEL, 0, 0, 0); ObjectSetText("最高 Label", "最高", 9, "Verdana", 开盘最高最低_color1); ObjectSet("最高 Label", OBJPROP_CORNER, Corner_Right_Top); ObjectSet("最高 Label", OBJPROP_XDISTANCE, 移动左右 + 62); ObjectSet("最高 Label", OBJPROP_YDISTANCE, 移动上下 + 17); ObjectCreate("最高 Value", OBJ_LABEL, 0, 0, 0); ObjectSetText("最高 Value", " " + DoubleToStr(ihigh_148, digits_4), 9, "Verdana Bold", 开盘最高最低_color2); ObjectSet("最高 Value", OBJPROP_CORNER, Corner_Right_Top); ObjectSet("最高 Value", OBJPROP_XDISTANCE, 移动左右 + 2); ObjectSet("最高 Value", OBJPROP_YDISTANCE, 移动上下 + 17); ObjectCreate("最低 Label", OBJ_LABEL, 0, 0, 0); ObjectSetText("最低 Label", "最低", 9, "Verdana", 开盘最高最低_color1); ObjectSet("最低 Label", OBJPROP_CORNER, Corner_Right_Top); ObjectSet("最低 Label", OBJPROP_XDISTANCE, 移动左右 + 62); ObjectSet("最低 Label", OBJPROP_YDISTANCE, 移动上下 + 32); ObjectCreate("最低 Value", OBJ_LABEL, 0, 0, 0); ObjectSetText("最低 Value", " " + DoubleToStr(ilow_156, digits_4), 9, "Verdana Bold", 开盘最高最低_color2); ObjectSet("最低 Value", OBJPROP_CORNER, Corner_Right_Top); ObjectSet("最低 Value", OBJPROP_XDISTANCE, 移动左右 + 2); ObjectSet("最低 Value", OBJPROP_YDISTANCE, 移动上下 + 32); ObjectCreate("open", OBJ_LABEL, 0, 0, 0); ObjectSetText("open", "开盘涨跌", 9, "Verdana", color_16); ObjectSet("open", OBJPROP_CORNER, Corner_Right_Top); ObjectSet("open", OBJPROP_XDISTANCE, 移动左右 + 39); ObjectSet("open", OBJPROP_YDISTANCE, 移动上下 + 49); ObjectCreate("open1", OBJ_LABEL, 0, 0, 0); ObjectSetText("open1", "" + dbl2str_264 + "", 9, "Verdana Bold", color_16); ObjectSet("open1", OBJPROP_CORNER, Corner_Right_Top); ObjectSet("open1", OBJPROP_XDISTANCE, 移动左右 + 2); ObjectSet("open1", OBJPROP_YDISTANCE, 移动上下 + 49); ObjectCreate("today1", OBJ_LABEL, 0, 0, 0); ObjectSetText("today1", "今高低", 9, "Verdana", 统计_color1); ObjectSet("today1", OBJPROP_CORNER, Corner_Right_Top); ObjectSet("today1", OBJPROP_XDISTANCE, 移动左右 + 50); ObjectSet("today1", OBJPROP_YDISTANCE, 移动上下 + 66); ObjectCreate("today2", OBJ_LABEL, 0, 0, 0); ObjectSetText("today2", "" + dbl2str_288 + "", 9, "Verdana", 统计_color2); ObjectSet("today2", OBJPROP_CORNER, Corner_Right_Top); ObjectSet("today2", OBJPROP_XDISTANCE, 移动左右 + 2); ObjectSet("today2", OBJPROP_YDISTANCE, 移动上下 + 66); ObjectCreate("yesterday1", OBJ_LABEL, 0, 0, 0); ObjectSetText("yesterday1", "昨高低", 9, "Verdana", 统计_color1); ObjectSet("yesterday1", OBJPROP_CORNER, Corner_Right_Top); ObjectSet("yesterday1", OBJPROP_XDISTANCE, 移动左右 + 50); ObjectSet("yesterday1", OBJPROP_YDISTANCE, 移动上下 + 81); ObjectCreate("yesterday2", OBJ_LABEL, 0, 0, 0); ObjectSetText("yesterday2", "" + dbl2str_272 + "", 9, "Verdana", 统计_color2); ObjectSet("yesterday2", OBJPROP_CORNER, Corner_Right_Top); ObjectSet("yesterday2", OBJPROP_XDISTANCE, 移动左右 + 2); ObjectSet("yesterday2", OBJPROP_YDISTANCE, 移动上下 + 81); ObjectCreate("5_day", OBJ_LABEL, 0, 0, 0); ObjectSetText("5_day", "5 天", 9, "Verdana", 统计_color1); ObjectSet("5_day", OBJPROP_CORNER, Corner_Right_Top); ObjectSet("5_day", OBJPROP_XDISTANCE, 移动左右 + 50); ObjectSet("5_day", OBJPROP_YDISTANCE, 移动上下 + 96); ObjectCreate("5_day1", OBJ_LABEL, 0, 0, 0); ObjectSetText("5_day1", DoubleToStr(li_212, 0), 9, "Verdana", 统计_color2); ObjectSet("5_day1", OBJPROP_CORNER, Corner_Right_Top); ObjectSet("5_day1", OBJPROP_XDISTANCE, 移动左右 + 2); ObjectSet("5_day1", OBJPROP_YDISTANCE, 移动上下 + 96); ObjectCreate("10_day", OBJ_LABEL, 0, 0, 0); ObjectSetText("10_day", "10 天", 9, "Verdana", 统计_color1); ObjectSet("10_day", OBJPROP_CORNER, Corner_Right_Top); ObjectSet("10_day", OBJPROP_XDISTANCE, 移动左右 + 50); ObjectSet("10_day", OBJPROP_YDISTANCE, 移动上下 + 111); ObjectCreate("10_day1", OBJ_LABEL, 0, 0, 0); ObjectSetText("10_day1", DoubleToStr(li_216, 0), 9, "Verdana", 统计_color2); ObjectSet("10_day1", OBJPROP_CORNER, Corner_Right_Top); ObjectSet("10_day1", OBJPROP_XDISTANCE, 移动左右 + 2); ObjectSet("10_day1", OBJPROP_YDISTANCE, 移动上下 + 111); ObjectCreate("20_day", OBJ_LABEL, 0, 0, 0); ObjectSetText("20_day", "20 天", 9, "Verdana", 统计_color1); ObjectSet("20_day", OBJPROP_CORNER, Corner_Right_Top); ObjectSet("20_day", OBJPROP_XDISTANCE, 移动左右 + 50); ObjectSet("20_day", OBJPROP_YDISTANCE, 移动上下 + 126); ObjectCreate("20_day1", OBJ_LABEL, 0, 0, 0); ObjectSetText("20_day1", DoubleToStr(li_220, 0), 9, "Verdana", 统计_color2); ObjectSet("20_day1", OBJPROP_CORNER, Corner_Right_Top); ObjectSet("20_day1", OBJPROP_XDISTANCE, 移动左右 + 2); ObjectSet("20_day1", OBJPROP_YDISTANCE, 移动上下 + 126); ObjectCreate("average", OBJ_LABEL, 0, 0, 0); ObjectSetText("average", "平 均", 9, "Verdana", 平均_color1); ObjectSet("average", OBJPROP_CORNER, Corner_Right_Top); ObjectSet("average", OBJPROP_XDISTANCE, 移动左右 + 50); ObjectSet("average", OBJPROP_YDISTANCE, 移动上下 + 142); ObjectCreate("average1", OBJ_LABEL, 0, 0, 0); ObjectSetText("average1", "" + dbl2str_280 + "", 9, "Verdana Bold", 平均_color2); ObjectSet("average1", OBJPROP_CORNER, Corner_Right_Top); ObjectSet("average1", OBJPROP_XDISTANCE, 移动左右 + 2); ObjectSet("average1", OBJPROP_YDISTANCE, 移动上下 + 142); ObjectCreate("MMLEVELS1", OBJ_LABEL, 0, 0, 0); ObjectSetText("MMLEVELS1", "点差", 9, "Arial", 点差_color1); ObjectSet("MMLEVELS1", OBJPROP_CORNER, Corner_Right_Top); ObjectSet("MMLEVELS1", OBJPROP_XDISTANCE, 移动左右 + 62); ObjectSet("MMLEVELS1", OBJPROP_YDISTANCE, 移动上下 + 157); ObjectCreate("MMLEVELS2", OBJ_LABEL, 0, 0, 0); ObjectSetText("MMLEVELS2", "" + dbl2str_256 + "", 12, "Arial Bold", 点差_color2); ObjectSet("MMLEVELS2", OBJPROP_CORNER, Corner_Right_Top); ObjectSet("MMLEVELS2", OBJPROP_XDISTANCE, 移动左右 + 2); ObjectSet("MMLEVELS2", OBJPROP_YDISTANCE, 移动上下 + 157); ObjectCreate("line1", OBJ_LABEL, 0, 0, 0); ObjectSetText("line1", "-----------------", 8, "Verdana", PeachPuff); ObjectSet("line1", OBJPROP_CORNER, Corner_Right_Top); ObjectSet("line1", OBJPROP_XDISTANCE, 移动左右 + 2); ObjectSet("line1", OBJPROP_YDISTANCE, 移动上下 + 42); ObjectCreate("line2", OBJ_LABEL, 0, 0, 0); ObjectSetText("line2", "-----------------", 8, "Verdana", PeachPuff); ObjectSet("line2", OBJPROP_CORNER, Corner_Right_Top); ObjectSet("line2", OBJPROP_XDISTANCE, 移动左右 + 2); ObjectSet("line2", OBJPROP_YDISTANCE, 移动上下 + 58); ObjectCreate("line3", OBJ_LABEL, 0, 0, 0); ObjectSetText("line3", "-----------------", 8, "Verdana", MediumTurquoise); ObjectSet("line3", OBJPROP_CORNER, Corner_Right_Top); ObjectSet("line3", OBJPROP_XDISTANCE, 移动左右 + 2); ObjectSet("line3", OBJPROP_YDISTANCE, 移动上下 + 135); ObjectCreate("line4", OBJ_LABEL, 0, 0, 0); ObjectSetText("line4", "-----------------", 8, "Verdana", MediumTurquoise); ObjectSet("line4", OBJPROP_CORNER, Corner_Right_Top); ObjectSet("line4", OBJPROP_XDISTANCE, 移动左右 + 2); ObjectSet("line4", OBJPROP_YDISTANCE, 移动上下 + 150); } return (0); }
[download id="44"]