ASCtrend 세마포어 신호 지표는 알림, 이메일 및 푸시 알림 기능을 제공합니다.
이 지표의 코드에서 알림, 이메일 메시지 및 푸시 알림을 구현하기 위해 다음과 같은 변경 사항이 적용되었습니다:
- 새로운 입력 매개변수를 추가했습니다:
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[]) // 스프레드 { //--- 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)); //---- }
- OnCalculate() 블록의 지표 계산 주기 후에 BuySignal() 및 SellSignal() 함수를 호출하는 코드를 추가했습니다://---
BuySignal("ASCtrend",BuyBuffer,rates_total,prev_calculated,close,spread);
SellSignal("ASCtrend",SellBuffer,rates_total,prev_calculated,close,spread);
//---
여기서 BuyBuffer와 SellBuffer는 매수 및 매도 신호를 저장하는 지표 버퍼의 이름입니다. 지표 버퍼에는 0 또는 EMPTY_VALUE가 설정되어야 합니다.
OnCalculate() 블록에서 BuySignal() 및 SellSignal() 함수의 호출은 하나만 사용해야 합니다.

Fig.1. ASCtrendAlert 지표 차트에서

Fig.2. BykovTrendAlert 지표. 알림 생성
댓글 0