메타트레이더 5를 위한 RJTX_Matches_Smoothed_Alert 인디케이터 소개

Mike 2018.12.28 22:09 45 0 0
첨부파일

작성자: 라파엘 히메네즈 토치노

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[],        // 매수 신호가 담긴 인디케이터 버퍼
                   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,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 신호 
     Ask=",Ask,"
     Bid=",Bid,"
     currtime=",text,"
     Symbol=",Symbol()," Period=",sPeriod);
          if(EMailON) SendMail(SignalSirname+": BUY 신호 알림","BUY 신호 at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);
          if(PushON) SendNotification(SignalSirname+": BUY 신호 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,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 신호 
     Ask=",Ask,"
     Bid=",Bid,"
     currtime=",text,"
     Symbol=",Symbol()," Period=",sPeriod);
          if(EMailON) SendMail(SignalSirname+": SELL 신호 알림","SELL 신호 at Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);
          if(PushON) SendNotification(SignalSirname+": SELL 신호 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() 함수를 호출하는 코드가 추가되었습니다:
    //---     
       BuySignal("RJTX_Matches_Smoothed_Alert",BuyBuffer,rates_total,prev_calculated,close,spread);
       SellSignal("RJTX_Matches_Smoothed_Alert",SellBuffer,rates_total,prev_calculated,close,spread);
    //---
    


여기서 BuyBuffer와 SellBuffer는 매수 및 매도 신호를 저장하는 인디케이터 버퍼의 이름입니다. 빈 값으로는 0 또는 EMPTY_VALUE를 버퍼에 추가해야 합니다.

각 BuySignal() 및 SellSignal() 함수는 인디케이터 코드의 OnCalculate() 블록에서 한 번씩 호출되는 것이 예상됩니다.

이 인디케이터는 SmoothAlgorithms.mqh 라이브러리 클래스를 사용하며, 이를 <terminal_data_directory>\MQL5\Include 폴더에 복사해야 합니다. 이 클래스의 사용에 대해서는 중간 계산을 위한 가격 시리즈 평균화 기사를 참고하세요.

이 인디케이터는 처음에 MQL4로 구현되어 2015년 12월 23일에 코드 베이스에 게시되었습니다.


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