Level Indicator: ตัวช่วยในการเทรดบน MetaTrader 5

Mike 2022.01.20 22:55 27 0 0
ไฟล์แนบ

สำหรับนักเทรดที่ใช้ MetaTrader 5 การใช้ Level Indicator เป็นอีกหนึ่งเครื่องมือที่จะช่วยให้คุณได้รับสัญญาณการซื้อขายที่แม่นยำมากขึ้น โดยเมื่อระดับ trigLv ที่กำหนดในตั้งค่าถูกข้ามผ่านในช่วง deviation โปรแกรมจะส่งการแจ้งเตือนไปยังอุปกรณ์มือถือของคุณหากเปิดใช้งานพารามิเตอร์ notification และยังจะมีการเล่นเสียงเตือนหากเปิดใช้งานพารามิเตอร์ alert ด้วย

ระดับ trigLv และขอบเขต deviation จะแสดงด้วยเส้นแนวนอนที่คุณสามารถปรับแต่งสไตล์ สี และความหนาได้ตามที่ต้องการในตั้งค่าของอินดิเคเตอร์ ทำให้คุณสามารถเพิ่มอินดิเคเตอร์หลายชุดที่มีระดับต่างๆ ลงในกราฟและรับสัญญาณจากการตัดกันของเส้นได้

ระดับ trigLv จะถูกใช้งานเพียงครั้งเดียวต่อบาร์ และจะมีการทำงานใหม่ได้ก็ต่อเมื่อเปิดบาร์ถัดไปเท่านั้น ซึ่งจะช่วยลดการแจ้งเตือนที่ถี่เกินไปในแต่ละจังหวะ

Level Indicator

//+------------------------------------------------------------------+//| Level Indicator.mq5 |//| Copyright 2022, © Cyberdev |//| https://www.mql5.com/en/users/cyberdev/seller |//+------------------------------------------------------------------+#property copyright"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("Level Indicator. Level ", lv.Price(0), " is inactive!");
  if (trigLv == 0.0)
    Alert("Level Indicator. Set parameter \"trigLv\" to the desired value!");
  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("Level Indicator. Level ", NormalizeDouble(lv.Price(0), (int)SymbolInfoInteger(NULL, SYMBOL_DIGITS)), " triggered!");
      if (notification)
        SendNotification("Level Indicator. Level " + (string)NormalizeDouble(lv.Price(0), (int)SymbolInfoInteger(NULL, SYMBOL_DIGITS)) + " triggered!");
    }
    triggered = true;
  }
  else
    triggered = false;
  
  return rates_total;
}

//+------------------------------------------------------------------+
รายการ
ความคิดเห็น 0