Comment out the two tests:
// if (i==1 && flagval1==0 && j==i && j==1) // if (i==1 && flagval2==0 && j==i && j==1)
Khalid Aldarawy:
Hello, I would like to have this signal sends me an alert everytime there is a buy or sell signal because at the moment, it sends a signal once, if more than 1 buy signal has been triggered it only sends the notification on the 1st time only, a sell signal needs to be triggered 1st before the app can send another buy signal "on a different occasion". Can anyone help edit this code to send a push notification on every buy or sell signal regardless of how many consequence times of buy or sell signal are triggered?
Thanks!
Ok. very Simple
//---- #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 LawnGreen #property indicator_color2 Red #property indicator_width1 1 #property indicator_width2 1 //---- extern bool PushON=true; extern bool SoundON=true; extern bool EmailON=false; //---- input parameters extern int KPeriod=5; extern int DPeriod=3; extern int Slowing=3; extern int MA_Method=0; // SMA 0, EMA 1, SMMA 2, LWMA 3 extern int PriceField=0; // Low/High 0, Close/Close 1 extern int OverBoughtLevel =80; extern int OverSoldLevel =20; extern bool show_KD_cross=false; extern bool show_K_OBOScross=true; extern bool show_D_OBOScross=false; extern string note_Price="PriceField: Low/High = 0, Close/Close = 1"; extern string _MA_Method="SMA0 EMA1 SMMA2 LWMA3"; extern string msg=""; double CrossUp[]; double CrossDown[]; int flagval1=0; int flagval2=0; datetime prevtime; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0, DRAW_ARROW, EMPTY); SetIndexArrow(0, 233); SetIndexBuffer(0, CrossUp); SetIndexStyle(1, DRAW_ARROW, EMPTY); SetIndexArrow(1, 234); SetIndexBuffer(1, CrossDown); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int limit, i, counter; int j=1; double tmp=0; double fastMAnow, slowMAnow, fastMAprevious, slowMAprevious; double Range, AvgRange; int counted_bars=IndicatorCounted(); //---- check for possible errors if(counted_bars<0) return(-1); //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; for(i=1; i<=limit; i++) { counter=i; Range=0; AvgRange=0; for(counter=i ;counter<=i+9;counter++) { // AvgRange=AvgRange+MathAbs(iStochastic(NULL, 0, KPeriod, DPeriod, Slowing,MA_Method, PriceField, MODE_MAIN, i)-iStochastic(NULL, 0, KPeriod, DPeriod, Slowing,MA_Method, PriceField, MODE_MAIN, i+1)); AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]); } Range=AvgRange/10; fastMAnow=iStochastic(NULL, 0, KPeriod, DPeriod, Slowing,MA_Method, PriceField, MODE_MAIN, i); fastMAprevious=iStochastic(NULL, 0, KPeriod, DPeriod, Slowing,MA_Method, PriceField, MODE_MAIN, i+1); slowMAnow=iStochastic(NULL, 0, KPeriod, DPeriod, Slowing,MA_Method, PriceField, MODE_SIGNAL, i); slowMAprevious=iStochastic(NULL, 0, KPeriod, DPeriod, Slowing,MA_Method, PriceField, MODE_SIGNAL, i+1); CrossUp[i]=EMPTY_VALUE; CrossDown[i]=EMPTY_VALUE; if (((show_KD_cross)&&(fastMAnow > slowMAnow) && (fastMAprevious < slowMAprevious))|| ((show_K_OBOScross)&&(fastMAnow > OverSoldLevel) && (fastMAprevious < OverSoldLevel))|| ((show_D_OBOScross)&&(slowMAnow > OverSoldLevel) && (slowMAprevious < OverSoldLevel)) ) { //if (i==1 && flagval1==0) /*/ if (i==1 && flagval1==0 && j==i && j==1) { flagval1=1; flagval2=0; j=i; msg=StringConcatenate("BUY signal at Ask=",Ask,"\n Bid=",Bid,"\n Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period()); if (PushON) SendNotification(msg); if (SoundON) Alert("BUY signal at Ask=",Ask,"\n Bid=",Bid,"\n Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period()); if (EmailON) SendMail("BUY signal alert","BUY signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period()); } */ CrossUp[i]=Low[i] - Range*0.5; // CrossUp[i] = AvgRange; CrossDown[i]=EMPTY_VALUE; } else if (((show_KD_cross)&&(fastMAnow < slowMAnow) && (fastMAprevious > slowMAprevious))|| ((show_K_OBOScross)&&(fastMAnow < OverBoughtLevel) && (fastMAprevious > OverBoughtLevel))|| ((show_D_OBOScross)&&(slowMAnow < OverBoughtLevel) && (slowMAprevious > OverBoughtLevel)) ) { //if (i==1 && flagval2==0) /* if (i==1 && flagval2==0 && j==i && j==1) { flagval2=1; flagval1=0; j=i; msg=StringConcatenate("SELL signal at Ask=",Ask,"\n Bid=",Bid,"\n Date=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period()); if (PushON) SendNotification(msg); if (SoundON) Alert("SELL signal at Ask=",Ask,"\n Bid=",Bid,"\n Date=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period()); if (EmailON) SendMail("SELL signal alert","SELL signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period()); } */ CrossDown[i]=High[i] + Range*0.5; // CrossDown[i] = AvgRange; CrossUp[i]=EMPTY_VALUE; } } // Print(CrossDown[i]," ",CrossUp[i]); // Sell 2022.04.16 02:08:34.763 2021.10.26 16:00:00 KhalidindV01 EURUSD,H1: 1.1625 2147483647 // BUY 2022.04.16 02:09:14.613 2021.10.26 22:00:00 KhalidindV01 EURUSD,H1: 2147483647 1.1589 //----, if(iTime(Symbol(),0,0) == prevtime) return(0); prevtime = iTime(Symbol(),0,0); // BUY Alert if (CrossUp[1]!=2147483647 && CrossUp[1]>0) { msg=StringConcatenate("BUY signal at Ask=",Ask,"\n Bid=",Bid,"\n Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period()); if (PushON) SendNotification(msg); if (SoundON) Alert("BUY signal at Ask=",Ask,"\n Bid=",Bid,"\n Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period()); if (EmailON) SendMail("BUY signal alert","BUY signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period()); } // SELL // KhalidindV01 EURUSD,H1: 1.1625 2147483647 if (CrossDown[1]!=2147483647 && CrossDown[1]>0) { msg=StringConcatenate("SELL signal at Ask=",Ask,"\n Bid=",Bid,"\n Date=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period()); if (PushON) SendNotification(msg); if (SoundON) Alert("SELL signal at Ask=",Ask,"\n Bid=",Bid,"\n Date=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period()); if (EmailON) SendMail("SELL signal alert","SELL signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period()); } return(0); } //+------------------------------------------------------------------+
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello, I would like to have this signal sends me an alert everytime there is a buy or sell signal because at the moment, it sends a signal once, if more than 1 buy signal has been triggered it only sends the notification on the 1st time only, a sell signal needs to be triggered 1st before the app can send another buy signal "on a different occasion". Can anyone help edit this code to send a push notification on every buy or sell signal regardless of how many consequence times of buy or sell signal are triggered?
Thanks!