Hey Guys, can anyone please help me with the param
eters for the SendNotification function? I just added an external Boolean option for push notifications and also added a few lines of codes for that purpose alongside the Alerts. When I compile the code, I get "SendNotification - wrong parameters count. I have commented out the line that give error plus the additional boolean option. I will really be grateful for any assistance to get the notifications option done.
SendNotification(message, Symbol(), " , ", Period(), " minutes chart"); // I get the error message on this line. Not sure what to use.
I think that you will find that the compiler interprets the commas as separate paramenters.
You can use commas in a Print() but not in SendNotification().
Use + instead of , or prepare the text previously
message+=Symbol()+" , "+(string) Period()+ " minutes chart");
I think that you will find that the compiler interprets the commas as separate paramenters.
You can use commas in a Print() but not in SendNotification().
Use + instead of , or prepare the text previously
Thanks a lot Keith it did work. No errors now on the code. I will keep practicing on more codes to try and improve my knowledge on coding.
You're welcome.
As an aside, I think that it is better to actually print the time-frame instead of using Period().
ENUM_TIMEFRAMES tf=(ENUM_TIMEFRAMES)Period(); string tf_string=EnumToString(tf); message+=Symbol()+" , "+tf_string;
or you can insert it straight into the message in one step
message+=Symbol()+" , "+EnumToString((ENUM_TIMEFRAMES)Period());
You're welcome.
As an aside, I think that it is better to actually print the time-frame instead of using Period().
or you can insert it straight into the message in one step
It is actually better to write self-documenting code by writing a function.
Need some help with some MT5 code - MT5 - Expert Advisors and Automated Trading - MQL5 programming forum (2018)
You're welcome.
As an aside, I think that it is better to actually print the time-frame instead of using Period().
or you can insert it straight into the message in one step
Hey Keith I did manage to change the change the line to have the period() function and it works perfectly. I faced a similar problem when editing the SendNotification() function on a small MA Crossover indicator. I tried to replace commas with + but I get errors on the code. I can't figure out what am doing wrong. Please bare with me as am still far from good at programming.
//+------------------------------------------------------------------+ //| EMA-Crossover_Signal.mq4 | //| Copyright © 2005, Jason Robinson (jnrtrading) | //| http://www.jnrtading.co.uk | //+------------------------------------------------------------------+ /* +------------------------------------------------------------------+ | Allows you to enter two ema periods and it will then show you at | | Which point they crossed over. It is more useful on the shorter | | periods that get obscured by the bars / candlesticks and when | | the zoom level is out. Also allows you then to remove the emas | | from the chart. (emas are initially set at 5 and 6) | +------------------------------------------------------------------+ */ #property copyright "Copyright © 2005, Jason Robinson (jnrtrading)" #property link "http://www.jnrtrading.co.uk" #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 DarkGreen #property indicator_color2 FireBrick double CrossUp[]; double CrossDown[]; extern int FasterEMA = 9; extern int SlowerEMA = 20; extern bool SoundON=true; extern bool Notify = true; double alertTag; double control=2147483647; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0, DRAW_ARROW, EMPTY,1); SetIndexArrow(0, 233); SetIndexBuffer(0, CrossUp); SetIndexStyle(1, DRAW_ARROW, EMPTY,1); 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; double fasterEMAnow, slowerEMAnow, fasterEMAprevious, slowerEMAprevious, fasterEMAafter, slowerEMAafter; 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 = 0; i <= limit; i++) { counter=i; Range=0; AvgRange=0; for (counter=i ;counter<=i+9;counter++) { AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]); } Range=AvgRange/10; fasterEMAnow = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, i); fasterEMAprevious = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, i+1); fasterEMAafter = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, i-1); slowerEMAnow = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, i); slowerEMAprevious = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, i+1); slowerEMAafter = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, i-1); if ((fasterEMAnow > slowerEMAnow) && (fasterEMAprevious < slowerEMAprevious) && (fasterEMAafter > slowerEMAafter)) { CrossUp[i] = Low[i] - Range*0.5; } else if ((fasterEMAnow < slowerEMAnow) && (fasterEMAprevious > slowerEMAprevious) && (fasterEMAafter < slowerEMAafter)) { CrossDown[i] = High[i] + Range*0.5; } if (SoundON==true && i==1 && CrossUp[i] > CrossDown[i] && alertTag!=Time[0]){ Alert("EMA Cross Trend going Down on ",Symbol()," ",Period()); alertTag = Time[0]; } if (SoundON==true && i==1 && CrossUp[i] < CrossDown[i] && alertTag!=Time[0]){ Alert("EMA Cross Trend going Up on ",Symbol()," ",Period()); alertTag = Time[0]; } if (Notify==true && i==1 && CrossUp[i] > CrossDown[i] && alertTag!=Time[0]){ SendNotification("EMA Cross Trend going Down on ",Symbol()," ",Period()); //wrong parameters alertTag = Time[0]; } if (Notify==true && i==1 && CrossUp[i] < CrossDown[i] && alertTag!=Time[0]){ SendNotification("EMA Cross Trend going Up on ",Symbol()," ",Period()); //wrong parameters alertTag = Time[0]; //SendNotification(message+=Symbol()+" , "+(string) Period()+ " minutes chart"); // Tried to use the above example from last time but am still getting errors. } } return(0); }
Hey Keith I did manage to change the change the line to have the period() function and it works perfectly. I faced a similar problem when editing the SendNotification() function on a small MA Crossover indicator. I tried to replace commas with + but I get errors on the code. I can't figure out what am doing wrong. Please bare with me as am still far from good at programming.
//SendNotification(message+=Symbol()+" , "+(string) Period()+ " minutes chart"); // Tried to use the above example from last time but am still getting errors.
I don't see that you have declared the variable message anywhere in your code
SendNotification("EMA Cross Trend going Up on "+Symbol()+" , "+(string) Period()+ " minutes chart");
Should work.
I don't see that you have declared the variable message anywhere in your code
Should work.
Hey Keith, just got back to editing the SendNotification line but unfortunately no notification is being sent to phone despite no errors on the code when compling. I even used the enumerate option without errors but no notification is being sent. There is something am missing, please help me out once again.
//+------------------------------------------------------------------+ //| EMA-Crossover_Signal.mq4 | //| Copyright © 2005, Jason Robinson (jnrtrading) | //| http://www.jnrtading.co.uk | //+------------------------------------------------------------------+ /* +------------------------------------------------------------------+ | Allows you to enter two ema periods and it will then show you at | | Which point they crossed over. It is more useful on the shorter | | periods that get obscured by the bars / candlesticks and when | | the zoom level is out. Also allows you then to remove the emas | | from the chart. (emas are initially set at 5 and 6) | +------------------------------------------------------------------+ */ #property copyright "Copyright © 2005, Jason Robinson (jnrtrading)" #property link "http://www.jnrtrading.co.uk" #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 DarkGreen #property indicator_color2 FireBrick double CrossUp[]; double CrossDown[]; extern int FasterEMA = 9; extern int SlowerEMA = 20; extern bool SoundON=true; extern bool Notify = true; double alertTag; double control=2147483647; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0, DRAW_ARROW, EMPTY,1); SetIndexArrow(0, 233); SetIndexBuffer(0, CrossUp); SetIndexStyle(1, DRAW_ARROW, EMPTY,1); 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; double fasterEMAnow, slowerEMAnow, fasterEMAprevious, slowerEMAprevious, fasterEMAafter, slowerEMAafter; 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 = 0; i <= limit; i++) { counter=i; Range=0; AvgRange=0; for (counter=i ;counter<=i+9;counter++) { AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]); } Range=AvgRange/10; fasterEMAnow = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, i); fasterEMAprevious = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, i+1); fasterEMAafter = iMA(NULL, 0, FasterEMA, 0, MODE_EMA, PRICE_CLOSE, i-1); slowerEMAnow = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, i); slowerEMAprevious = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, i+1); slowerEMAafter = iMA(NULL, 0, SlowerEMA, 0, MODE_EMA, PRICE_CLOSE, i-1); if ((fasterEMAnow > slowerEMAnow) && (fasterEMAprevious < slowerEMAprevious) && (fasterEMAafter > slowerEMAafter)) { CrossUp[i] = Low[i] - Range*0.5; } else if ((fasterEMAnow < slowerEMAnow) && (fasterEMAprevious > slowerEMAprevious) && (fasterEMAafter < slowerEMAafter)) { CrossDown[i] = High[i] + Range*0.5; } if (SoundON==true && i==1 && CrossUp[i] > CrossDown[i] && alertTag!=Time[0]){ Alert("EMA Cross Trend going Down on ",Symbol()," "+EnumToString((ENUM_TIMEFRAMES)Period())); alertTag = Time[0]; } if (SoundON==true && i==1 && CrossUp[i] < CrossDown[i] && alertTag!=Time[0]){ Alert("EMA Cross Trend going Up on ",Symbol()," "+EnumToString((ENUM_TIMEFRAMES)Period())); alertTag = Time[0]; } if (Notify==true && i==1 && CrossUp[i] > CrossDown[i] && alertTag!=Time[0]){ SendNotification("EMA Cross Trend going Down on "+Symbol()+" , "+EnumToString((ENUM_TIMEFRAMES)Period())); }//Not getting any notifications if (Notify==true && i==1 && CrossUp[i] < CrossDown[i] && alertTag!=Time[0]){ SendNotification("EMA Cross Trend going Up on "+Symbol()+", "+EnumToString((ENUM_TIMEFRAMES)Period())); } // Not getting any notifications } return(0); }
Hey Keith, just got back to editing the SendNotification line but unfortunately no notification is being sent to phone despite no errors on the code when compling. I even used the enumerate option without errors but no notification is being sent. There is something am missing, please help me out once again.
Go through your code and think about what is happening with the variable alertTag.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
eters for the SendNotification function? I just added an external Boolean option for push notifications and also added a few lines of codes for that purpose alongside the Alerts. When I compile the code, I get "SendNotification - wrong parameters count. I have commented out the line that give error plus the additional boolean option. I will really be grateful for any assistance to get the notifications option done.