진짜 저자: Eng. Waddah Attar
Waddah_Attar_Trend 지표는 알림, 이메일 및 푸시 알림 기능을 제공합니다.
알림, 이메일 메시지 및 푸시 알림 기능을 구현하기 위해 지표 코드에 다음과 같은 변경 사항이 적용되었습니다:
- 새로운 입력 매개변수 추가:
//---- 알림을 위한 입력 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 &ColorArray[],// 색상 인덱스 버퍼
int ColorIndex,// 신호 생성을 위한 색상 인덱스
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(ColorArray);
int index,index1;
if(SeriesTest)
{
index=int(NumberofBar);
index1=index+1;
}
else
{
index=Rates_total-int(NumberofBar)-1;
index1=index-1;
}
if(ColorArray[index1]!=ColorIndex && ColorArray[index]==ColorIndex) 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+=_Point*Spread[index];
string sAsk=DoubleToString(Ask,_Digits);
string sBid=DoubleToString(Bid,_Digits);
string sPeriod=GetStringTimeframe(ChartPeriod());
if(SoundON) Alert("매수 신호 Ask=",Ask," Bid=",Bid," currtime=",text," Symbol=",Symbol()," Period=",sPeriod);
if(EMailON) SendMail(SignalSirname+": 매수 신호 알림","매수 신호가 Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);
if(PushON) SendNotification(SignalSirname+": 매수 신호가 Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);
}
//---
}
//+------------------------------------------------------------------+
//| 매도 신호 함수 |
//+------------------------------------------------------------------+
void SellSignal(string SignalSirname,// 이메일 및 푸시 메시지의 지표 이름
double &ColorArray[], // 색상 인덱스 버퍼
int ColorIndex,// 신호 생성을 위한 색상 인덱스
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(ColorArray);
int index,index1;
if(SeriesTest)
{
index=int(NumberofBar);
index1=index+1;
}
else
{
index=Rates_total-int(NumberofBar)-1;
index1=index-1;
}
if(ColorArray[index1]!=ColorIndex && ColorArray[index]==ColorIndex) 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+=_Point*Spread[index];
string sAsk=DoubleToString(Ask,_Digits);
string sBid=DoubleToString(Bid,_Digits);
string sPeriod=GetStringTimeframe(ChartPeriod());
if(SoundON) Alert("매도 신호 Ask=",Ask," Bid=",Bid," currtime=",text," Symbol=",Symbol()," Period=",sPeriod);
if(EMailON) SendMail(SignalSirname+": 매도 신호 알림","매도 신호가 Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);
if(PushON) SendNotification(SignalSirname+": 매도 신호가 Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod);
}
//---
}
//+------------------------------------------------------------------+
//| 시간 프레임을 문자열로 가져오기 |
//+------------------------------------------------------------------+
string GetStringTimeframe(ENUM_TIMEFRAMES timeframe)
{
//----
return(StringSubstr(EnumToString(timeframe),7,-1));
//----
} - 지표 계산 사이클 후 BuySignal() 및 SellSignal() 함수에 대한 호출을 추가했습니다.//---
BuySignal("Waddah_Attar_Trend_Alert",ColorIndBuffer,0,rates_total,prev_calculated,close,spread);
SellSignal("Waddah_Attar_Trend_Alert",ColorIndBuffer,1,rates_total,prev_calculated,close,spread);
//---
여기서 ColorIndBuffer는 선 색상을 인덱스로 저장하는 색상 인덱스 버퍼의 이름이며, 0과 1은 색상 인덱스 버퍼의 색상 번호입니다.
BuySignal() 및 SellSignal() 함수 호출은 지표 코드의 OnCalculate() 블록에서 한 번만 사용됩니다.
이 지표는 SmoothAlgorithms.mqh 라이브러리 클래스를 사용합니다 (이 파일은 <terminal_data_folder>\MQL5\Include에 복사하세요). 클래스 사용법은 "추가 버퍼 없이 중간 계산을 위한 가격 시계열 평균화" 기사에서 자세히 설명되어 있습니다.

그림 1. Waddah_Attar_Trend_Alert 지표 차트
그림 2. Waddah_Attar_Trend_Alert 지표. 알림 생성
