หน้าแรก ตัวชี้วัดทางเทคนิค โพสต์

BykovTrendAlert: เครื่องมือแจ้งเตือนสำหรับ MetaTrader 5

ไฟล์แนบ
16458.zip (3.75 KB, ดาวน์โหลด 0 ครั้ง)

ผู้เขียนจริง: Ramdass - การแปลงข้อมูลเท่านั้น

เครื่องมือ BykovTrend เป็นสัญญาณเซมาฟอร์ที่มีฟีเจอร์แจ้งเตือน รวมถึงการส่งอีเมลและการแจ้งเตือนผ่านมือถือ

การเปลี่ยนแปลงในโค้ดของตัวชี้วัดนี้มีจุดประสงค์เพื่อการใช้งานแจ้งเตือน อีเมล และการส่งแจ้งเตือนผ่านมือถือ:

  1. เพิ่มพารามิเตอร์การตั้งค่าใหม่
    input uint NumberofBar=1;//จำนวนแท่งสำหรับสัญญาณ
    input bool SoundON=true; //เปิดใช้งานการแจ้งเตือน
    input uint NumberofAlerts=2;//จำนวนการแจ้งเตือน
    input bool EMailON=false; //เปิดใช้งานการส่งสัญญาณทางอีเมล
    input bool PushON=false; //เปิดใช้งานการส่งสัญญาณไปยังมือถือ
    
  2. เพิ่มฟังก์ชันใหม่ 3 ฟังก์ชัน: BuySignal(), SellSignal() และ GetStringTimeframe()
    //+------------------------------------------------------------------+
    //| ฟังก์ชันสัญญาณซื้อ                                              |
    //+------------------------------------------------------------------+
    void BuySignal(string SignalSirname,      //ข้อความชื่อของตัวชี้วัดสำหรับอีเมลและข้อความแจ้งเตือน
                   double &BuyArrow[],        //บัฟเฟอร์ข้อมูลสำหรับสัญญาณซื้อ
                   const int Rates_total,     //จำนวนแท่งปัจจุบัน
                   const int Prev_calculated, //จำนวนแท่งในแท่งก่อนหน้า
                   const double &Close[],     //ราคาปิด
                   const int &Spread[])       //สเปรด
      {
    //---
       static uint counter=0;
       if(Rates_total!=Prev_calculated) counter=0;
    
       bool BuySignal=false;
       bool SeriesTest=ArrayGetAsSeries(BuyArrow);
       int index;
       if(SeriesTest) index=int(NumberofBar);
       else index=Rates_total-int(NumberofBar)-1;
       if(NormalizeDouble(BuyArrow[index],_Digits) && BuyArrow[index]!=EMPTY_VALUE) BuySignal=true;
       if(BuySignal && counter<=NumberofAlerts)
         {
          counter++;
          MqlDateTime tm;
          TimeToStruct(TimeCurrent(),tm);
          string text=TimeToString(TimeCurrent(),TIME_DATE)+" "+string(tm.hour)+":"+string(tm.min);
          SeriesTest=ArrayGetAsSeries(Close);
          if(SeriesTest) index=int(NumberofBar);
          else index=Rates_total-int(NumberofBar)-1;
          double Ask=Close[index];
          double Bid=Close[index];
          SeriesTest=ArrayGetAsSeries(Spread);
          if(SeriesTest) index=int(NumberofBar);
          else index=Rates_total-int(NumberofBar)-1;
          Bid+=Spread[index];
          string sAsk=DoubleToString(Ask,_Digits);
          string sBid=DoubleToString(Bid,_Digits);
          string sPeriod=GetStringTimeframe(ChartPeriod());
          if(SoundON) Alert("BUY signal \n Ask=",Ask,"\n Bid=",Bid,"\n currtime=",text,"\n Symbol=",Symbol()," Period=",sPeriod);
          if(EMailON) SendMail(SignalSirname+": BUY signal alert","BUY signal at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);
          if(PushON) SendNotification(SignalSirname+": BUY signal at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);
         }
    
    //---
      }
    //+------------------------------------------------------------------+
    //| ฟังก์ชันสัญญาณขาย                                             |
    //+------------------------------------------------------------------+
    void SellSignal(string SignalSirname,      //ข้อความชื่อของตัวชี้วัดสำหรับอีเมลและข้อความแจ้งเตือน
                    double &SellArrow[],       //บัฟเฟอร์ข้อมูลสำหรับสัญญาณขาย
                    const int Rates_total,     //จำนวนแท่งปัจจุบัน
                    const int Prev_calculated, //จำนวนแท่งในแท่งก่อนหน้า
                    const double &Close[],     //ราคาปิด
                    const int &Spread[])       //สเปรด
      {
    //---
       static uint counter=0;
       if(Rates_total!=Prev_calculated) counter=0;
    
       bool SellSignal=false;
       bool SeriesTest=ArrayGetAsSeries(SellArrow);
       int index;
       if(SeriesTest) index=int(NumberofBar);
       else index=Rates_total-int(NumberofBar)-1;
       if(NormalizeDouble(SellArrow[index],_Digits) && SellArrow[index]!=EMPTY_VALUE) SellSignal=true;
       if(SellSignal && counter<=NumberofAlerts)
         {
          counter++;
          MqlDateTime tm;
          TimeToStruct(TimeCurrent(),tm);
          string text=TimeToString(TimeCurrent(),TIME_DATE)+" "+string(tm.hour)+":"+string(tm.min);
          SeriesTest=ArrayGetAsSeries(Close);
          if(SeriesTest) index=int(NumberofBar);
          else index=Rates_total-int(NumberofBar)-1;
          double Ask=Close[index];
          double Bid=Close[index];
          SeriesTest=ArrayGetAsSeries(Spread);
          if(SeriesTest) index=int(NumberofBar);
          else index=Rates_total-int(NumberofBar)-1;
          Bid+=Spread[index];
          string sAsk=DoubleToString(Ask,_Digits);
          string sBid=DoubleToString(Bid,_Digits);
          string sPeriod=GetStringTimeframe(ChartPeriod());
          if(SoundON) Alert("SELL signal \n Ask=",Ask,"\n Bid=",Bid,"\n currtime=",text,"\n Symbol=",Symbol()," Period=",sPeriod);
          if(EMailON) SendMail(SignalSirname+": SELL signal alert","SELL signal at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);
          if(PushON) SendNotification(SignalSirname+": SELL signal at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);
         }
    //---
      }
    //+------------------------------------------------------------------+
    //|  การแสดงผลช่วงเวลาเป็นสตริง                               |
    //+------------------------------------------------------------------+
    string GetStringTimeframe(ENUM_TIMEFRAMES timeframe)
      {
    //----
       return(StringSubstr(EnumToString(timeframe),7,-1));
    //----
      }
    
  3. เพิ่มการเรียกใช้ฟังก์ชัน BuySignal() และ SellSignal() หลังจากการคำนวณในบล็อก OnCalculate()
    //---     
       BuySignal("BykovTrendAlert",BuyBuffer,rates_total,prev_calculated,close,spread);
       SellSignal("BykovTrendAlert",SellBuffer,rates_total,prev_calculated,close,spread);
    //--- 
    

โดยที่ BuyBuffer และ SellBuffer คือชื่อของบัฟเฟอร์ที่ใช้สำหรับเก็บสัญญาณซื้อและขาย ค่าที่ว่างในบัฟเฟอร์จะต้องเป็นศูนย์หรือ EMPTY_VALUE

เดิมทีตัวชี้วัดนี้ถูกพัฒนาใน MQL4 และเผยแพร่ใน Code Base เมื่อวันที่ 28.09.2007

Fig1. ตัวชี้วัด BykovTrendAlert บนกราฟ

Fig1. ตัวชี้วัด BykovTrendAlert บนกราฟ


Fig.2. ตัวชี้วัด BykovTrendAlert กำลังสร้างการแจ้งเตือน

Fig.2. ตัวชี้วัด BykovTrendAlert กำลังสร้างการแจ้งเตือน

โพสต์ที่เกี่ยวข้อง

ความคิดเห็น (0)