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

RJTX_Matches_Smoothed_Alert: ตัวช่วยในการเทรดที่คุณไม่ควรพลาด

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

ผู้เขียน: Rafael Jimenez Tocino

RJTX_Matches_Smoothed เป็นเครื่องมือที่จะช่วยให้คุณได้รับการแจ้งเตือนผ่านอีเมลและการแจ้งเตือนบนมือถือ เพื่อให้คุณไม่พลาดทุกสัญญาณในการเทรด

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

  1. เพิ่มตัวแปรใหม่ในอินพุตของอินดิเคเตอร์:
    input uint NumberofBar=1;                 // จำนวนบาร์ที่ใช้ในการเปิดสัญญาณ
    input bool SoundON=true;           // เปิดใช้งานเสียงแจ้งเตือน
    input uint NumberofAlerts=2;       // จำนวนการแจ้งเตือน
    input bool EMailON=false;          // เปิดใช้งานการส่งสัญญาณทางอีเมล
    input bool PushON=false;           // เปิดใช้งานการส่งสัญญาณไปยังอุปกรณ์มือถือ
    


  2. เพิ่มฟังก์ชันใหม่สามตัวที่ท้ายของอินดิเคเตอร์: BuySignal(), SellSignal(), และ GetStringTimeframe()
    //+------------------------------------------------------------------+
    //| ฟังก์ชันสัญญาณซื้อ                                            |
    //+------------------------------------------------------------------+
    void BuySignal(string SignalSirname,      // ชื่อของตัวอินดิเคเตอร์สำหรับข้อความอีเมลและการแจ้งเตือน
                   double &BuyArrow[],        // buffer ของอินดิเคเตอร์สำหรับสัญญาณซื้อ
                   const int Rates_total,     // จำนวนบาร์ปัจจุบัน
                   const int Prev_calculated, // จำนวนบาร์ในราคาที่แล้ว
                   const double &Close[],     // ราคาปิด
                   const int &Spread[])       // spread
      {
    //---
       static uint counter=0;
       if(Rates_total!=Prev_calculated) counter=0;
    
       bool BuySignal=false;
       bool SeriesTest=ArrayGetAsSeries(BuyArrow);
       int index,index1;
       if(SeriesTest)
        {
         index=int(NumberofBar);
         index1=index+1;
        }
       else
         {
          index=Rates_total-int(NumberofBar)-1;
          index1=index-1;
         }
       if(!BuyArrow[index1] && BuyArrow[index]) 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]*_Point;
          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[],       // buffer ของอินดิเคเตอร์สำหรับสัญญาณขาย
                    const int Rates_total,     // จำนวนบาร์ปัจจุบัน
                    const int Prev_calculated, // จำนวนบาร์ในราคาที่แล้ว
                    const double &Close[],     // ราคาปิด
                    const int &Spread[])       // spread
      {
    //---
       static uint counter=0;
       if(Rates_total!=Prev_calculated) counter=0;
    
       bool SellSignal=false;
       bool SeriesTest=ArrayGetAsSeries(SellArrow);
       int index,index1;
       if(SeriesTest)
        {
         index=int(NumberofBar);
         index1=index+1;
        }
       else
         {
          index=Rates_total-int(NumberofBar)-1;
          index1=index-1;
         }
       if(!SellArrow[index1] && SellArrow[index]) 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]*_Point;
          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("RJTX_Matches_Smoothed_Alert",BuyBuffer,rates_total,prev_calculated,close,spread);
       SellSignal("RJTX_Matches_Smoothed_Alert",SellBuffer,rates_total,prev_calculated,close,spread);
    //---
    


Buffer ของ BuyBuffer และ SellBuffer จะถูกใช้ในการเก็บสัญญาณซื้อและขาย โดยต้องเพิ่มค่า 0 หรือ EMPTY_VALUE ลงใน buffer ของอินดิเคเตอร์เป็นค่าเปล่า

การเรียกใช้งานฟังก์ชัน BuySignal() และ SellSignal() จะต้องมีเพียงหนึ่งครั้งในโค้ดของอินดิเคเตอร์ในบล็อก OnCalculate()

ตัวอินดิเคเตอร์นี้ใช้คลาสจากไลบรารี SmoothAlgorithms.mqh (ซึ่งต้องคัดลอกไปยังโฟลเดอร์ <terminal_data_directory>\MQL5\Include) การใช้คลาสนี้ได้ถูกอธิบายอย่างละเอียดในบทความ Averaging Price Series for Intermediate Calculations Without Using Additional Buffers

ตัวอินดิเคเตอร์นี้ถูกพัฒนาขึ้นใน MQL4 และเผยแพร่ใน Code Base เมื่อวันที่ 23 ธันวาคม 2015


Fig.1. Indicator RJTX_Matches_Smoothed_Alert on the chart

Fig.1. อินดิเคเตอร์ RJTX_Matches_Smoothed_Alert บนกราฟ


Fig. 2. Indicator RJTX_Matches_Smoothed_Alert. Alerting

Fig. 2. อินดิเคเตอร์ RJTX_Matches_Smoothed_Alert. การแจ้งเตือน

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

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