안녕하세요, 트레이더 여러분! 오늘은 여러분께 PPO_SignAlert라는 지표를 소개해 드리려고 합니다. 이 지표는 가격 변화의 상대적인 매끄러운 비율을 기반으로 한 세마포어 신호 지표입니다. 알림 기능이 포함되어 있어, 이메일 및 모바일 기기로 푸시 알림을 받을 수 있습니다.
지표 코드에 다음과 같은 변경 사항이 추가되어 알림, 이메일 메시지 및 푸시 알림 기능이 구현되었습니다:
- 새로운 입력 매개변수 추가:
input uint NumberofBar=1;//신호를 위한 바 수 input bool SoundON=true;//알림 활성화 input uint NumberofAlerts=2;//알림 수 input bool EMailON=false;//신호 이메일 전송 활성화 input bool PushON=false;//모바일 기기로 신호 전송 활성화
- 지표 코드 끝에 세 가지 새로운 함수 추가: BuySignal(), SellSignal(), GetStringTimeframe()
//+------------------------------------------------------------------+ //| 매수 신호 함수 | //+------------------------------------------------------------------+ void BuySignal(string SignalSirname,// 이메일 및 푸시 메시지를 위한 지표 이름 텍스트 double &BuyArrow[],// 매수 신호를 저장하는 지표 버퍼 const int Rates_total,// 현재 바 수 const int Prev_calculated,// 이전 틱의 바 수 const double &Close[],// 종가 const int &Spread[])// 스프레드 { u//--- 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 신호 Ask=",Ask," Bid=",Bid," 현재시간=",text," 심볼=",Symbol()," 기간=",sPeriod); if(EMailON) SendMail(SignalSirname+": BUY 신호 알림","BUY 신호 at Ask="+sAsk+", Bid="+sBid+", 날짜="+text+" 심볼="+Symbol()+" 기간="+sPeriod); if(PushON) SendNotification(SignalSirname+": BUY 신호 at Ask="+sAsk+", Bid="+sBid+", 날짜="+text+" 심볼="+Symbol()+" 기간="+sPeriod); } u//--- } //+------------------------------------------------------------------+ //| 매도 신호 함수 | //+------------------------------------------------------------------+ void SellSignal(string SignalSirname,// 이메일 및 푸시 메시지를 위한 지표 이름 텍스트 double &SellArrow[],// 매도 신호를 저장하는 지표 버퍼 const int Rates_total,// 현재 바 수 const int Prev_calculated,// 이전 틱의 바 수 const double &Close[],// 종가 const int &Spread[])// 스프레드 { u//--- 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 신호 Ask=",Ask," Bid=",Bid," 현재시간=",text," 심볼=",Symbol()," 기간=",sPeriod); if(EMailON) SendMail(SignalSirname+": SELL 신호 알림","SELL 신호 at Ask="+sAsk+", Bid="+sBid+", 날짜="+text+" 심볼="+Symbol()+" 기간="+sPeriod); if(PushON) SendNotification(SignalSirname+": SELL 신호 at Ask="+sAsk+", Bid="+sBid+", 날짜="+text+" 심볼="+Symbol()+" 기간="+sPeriod); } u//--- } //+------------------------------------------------------------------+ //| 시간대를 문자열로 가져오기 | //+------------------------------------------------------------------+ string GetStringTimeframe(ENUM_TIMEFRAMES timeframe) { //---- return(StringSubstr(EnumToString(timeframe),7,-1)); //---- }
- 지표 계산 주기 후 BuySignal() 및 SellSignal() 함수 호출 추가:
u//--- BuySignal("PPO_Sign",BuyBuffer,rates_total,prev_calculated,close,spread); SellSignal("PPO_Sign",SellBuffer,rates_total,prev_calculated,close,spread); u//---
여기서 BuyBuffer와 SellBuffer는 매수 및 매도 신호를 저장하는 지표 버퍼의 이름입니다. 지표 버퍼 내의 빈 값은 0 또는 EMPTY_VALUE로 설정해야 합니다.
매수 신호와 매도 신호 함수는 지표 코드의 OnCalculate() 블록에서 한 번만 호출된다고 가정합니다.
이 지표는 SmoothAlgorithms.mqh 라이브러리 클래스를 사용합니다. 이 파일은 <terminal_data_folder>\MQL5\Include 폴더에 복사해야 합니다. 이 클래스의 사용법은 "추가 버퍼 없이 중간 계산을 위한 가격 시리즈 평균화"라는 글에서 자세히 설명되어 있습니다.
처음 이 지표는 MQL4로 작성되었고, 2008년 3월 8일 코드 베이스에 처음 게시되었습니다.

Fig.1. PPO_SignAlert 지표 차트

Fig.2. PPO_SignAlert 지표 알림 생성