레벨 인디케이터는 MetaTrader 5에서 효과적으로 활용할 수 있는 유용한 도구입니다. 이 인디케이터는 설정된 trigLv 레벨을 기준으로 작동하며, 해당 레벨이 deviation 범위 내에서 교차할 경우, 모바일 기기로 푸시 알림을 보냅니다. 이 기능은 notification 파라미터가 활성화되어 있을 때 작동하며, alert 파라미터가 활성화되면 경고음을 발생시킵니다.
레벨 인디케이터의 trigLv 및 deviation 한계는 수평선으로 강조 표시되며, 이 선의 스타일, 색상, 두께는 인디케이터 설정에서 조정 가능합니다. 이를 통해 차트에 여러 개의 인디케이터를 추가하고 다양한 레벨에서 신호를 받을 수 있습니다.
주목할 점은 설정된 trigLv 레벨이 한 바에서 단 한번만 작동한다는 것입니다. 다음 바가 열릴 때까지 재작동은 불가능하므로, 각 틱에서 너무 잦은 신호를 막을 수 있습니다.

//+------------------------------------------------------------------+//| 레벨 인디케이터.mq5 |//| 저작권 2022, © Cyberdev |//| https://www.mql5.com/en/users/cyberdev/seller |//+------------------------------------------------------------------+#property copyright"저작권 2022, © Cyberdev"#property link "https://www.mql5.com/en/users/cyberdev/seller"#property version "1.00"#property indicator_chart_window#property indicator_plots0#include <ChartObjects\ChartObjectsLines.mqh> inputbool alert = true; // 경고 사용inputbool notification = true; // 푸시 알림 사용inputdouble trigLv = 0.0; // 작동 레벨inputint deviation = 30; // trigLv와의 편차(포인트)inputint lineWidth = 1; // 선 두께inputENUM_LINE_STYLE lineStyle = STYLE_SOLID; // 선 스타일inputcolor lineColor = clrMediumSpringGreen; // 선 색상inputcolor inactivityColor = clrLightGray; // 비활성 색상 CChartObjectHLine lv, dvH, dvL; bool equal(double _v1, double _v2, double _epsilon) { returnfabs(_v1 - _v2) <= fabs(_epsilon); } //+------------------------------------------------------------------+//| 커스텀 인디케이터 초기화 함수 |//+------------------------------------------------------------------+intOnInit() { string name; double dv; color color_; name = "alert.lv-"; dv = deviation * SymbolInfoDouble(NULL, SYMBOL_POINT); color_ = (alert || notification) ? lineColor : inactivityColor; for (int n = 0; n <= INT_MAX && !IsStopped(); n++) { if (ObjectFind(0, name + (string)n) != 0) { if (!lv.Create(0, name + (string)n, 0, trigLv)) returnINIT_FAILED; lv.Width(lineWidth); lv.Style(lineStyle); lv.Color(color_); dvH.Create(0, "alert.dvH-" + (string)n, 0, trigLv + dv); dvH.Width(1); dvH.Style(STYLE_DOT); dvH.Color(color_); dvL.Create(0, "alert.dvL-" + (string)n, 0, trigLv - dv); dvL.Width(1); dvL.Style(STYLE_DOT); dvL.Color(color_); break; } } if (!alert && !notification) Print("레벨 인디케이터. 레벨 ", lv.Price(0), "이(가) 비활성 상태입니다!"); if (trigLv == 0.0) Alert("레벨 인디케이터. 파라미터 'trigLv'를 원하는 값으로 설정하세요!"); return(INIT_SUCCEEDED); } voidOnDeinit(constint reason) { //lv.Delete(); //dvH.Delete(); //dvL.Delete(); } intOnCalculate(constint rates_total, constint prev_calculated, constdatetime &time[], constdouble &open[], constdouble &high[], constdouble &low[], constdouble &close[], constlong &tick_volume[], constlong &volume[], constint &spread[] ) { staticbool triggered = false; staticdatetime time_ = 0; if (!alert && !notification) return rates_total; if (equal(lv.Price(0), close[rates_total - 1], deviation * SymbolInfoDouble(NULL, SYMBOL_POINT))) { if (time_ != time[rates_total - 1]) time_ = time[rates_total - 1]; else return rates_total; if (!triggered) { if (alert) Alert("레벨 인디케이터. 레벨 ", NormalizeDouble(lv.Price(0), (int)SymbolInfoInteger(NULL, SYMBOL_DIGITS)), "이(가) 작동했습니다!"); if (notification) SendNotification("레벨 인디케이터. 레벨 " + (string)NormalizeDouble(lv.Price(0), (int)SymbolInfoInteger(NULL, SYMBOL_DIGITS)) + "이(가) 작동했습니다!"); } triggered = true; } else triggered = false; return rates_total; } //+------------------------------------------------------------------+

댓글 0