General rules and best pratices of the Forum. - General - MQL5 programming forum
Messages Editor
Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Messages Editor
Sorry about that :) DONE
please can anyone help - im no coder and tried my best to modify this indicator to add Push Notifications on when the MajorCycle fires the Buy or Sell signal.... it works BUT the alerts never stops... it continues to alert on my mobile, what do i need to add or change so that it only push notification once.
Looks like when your "alertsOnCurrent" is set to true, you'll be comparing the values of bar 0 with bar 1, and since bar 0 is still being changed continuously - so the highlighted conditions will be true and false multiple times within the same bar, hence you get continuous alerts.
So either you set "alertsOnCurrent" to false, or change whichBar to be 1 or 2, rather than 0 or 1.
if (alertsOnCurrent) int whichBar = 0; else whichBar = 1; static string type1 = ""; static datetime time1 = 0; if (alertsOnMajorCycle) { if (MajorCycleBuy[whichBar] != 0 && MajorCycleBuy[whichBar+1] == 0) doAlert(type1,time1," Major Cycle Buy"); if (MajorCycleSell[whichBar] != 0 && MajorCycleSell[whichBar+1] == 0) doAlert(type1,time1," Major Cycle Sell"); } static string type2 = ""; static datetime time2 = 0; if (alertsOnMinorCycle) { if (MinorCycleBuy[whichBar] != 0 && MinorCycleBuy[whichBar+1] == 0) doAlert(type2,time2," Minor Cycle Buy"); if (MinorCycleSell[whichBar] != 0 && MinorCycleSell[whichBar+1] == 0) doAlert(type2,time2," Minor Cycle Sell"); } string Message; { if (MajorCycleBuy[whichBar] != 0 && MajorCycleBuy[whichBar+1] == 0) Message = " "+Symbol()+" M"+Period()+": Major Cycle Buy"; if (alertsPushNotif) SendNotification(Message); } { if (MajorCycleSell[whichBar] != 0 && MajorCycleSell[whichBar+1] == 0) Message = " "+Symbol()+" M"+Period()+": Major Cycle Sell"; if (alertsPushNotif) SendNotification(Message); }
Looks like when your "alertsOnCurrent" is set to true, you'll be comparing the values of bar 0 with bar 1, and since bar 0 is still being changed continuously - so the highlighted conditions will be true and false multiple times within the same bar, hence you get continuous alerts.
So either you set "alertsOnCurrent" to false, or change whichBar to be 1 or 2, rather than 0 or 1.
Hi Mr Seng Joo Thio,
thank you for the reply,
im trying to wrap my head around your solution but im struggling, if i change the "alertsOnCurrent" to false, i get the continues push notifications... when i change the "alertsOnCurrent" to true, i dont get any notifications.....
other than that your other idea i also tried that but im a noob and dont know where to add the 1/2 /0/ 1 :(
im trying to wrap my head around your solution but im struggling, if i change the "alertsOnCurrent" to false, i get the continues push notifications... when i change the "alertsOnCurrent" to true, i dont get any notifications.....
other than that your other idea i also tried that but im a noob and dont know where to add the 1/2 /0/ 1 :(
Ok, so there is another problem :) - As many ticks can come in during a candle's lifetime, you need to make sure that your alert is only triggered at the start of the newest candle. Just add in these few lines will do:
static datetime iLastCandleTime = 0; datetime iCurrCandleTime = iTime(_Symbol,_Period,0); if (iLastCandleTime<iCurrCandleTime) { // Your code in my earlier post. iLastCandleTime = iCurrCandleTime; }
Now, when I test run your codes, I noticed that your MajorCycle/MinorCycle Buy/Sell arrays may not be set correctly such that you still get one alert at the start of every candle - for that, you'll have to check through the main logic of your code, since, unless you explain what it does, nobody can help you debug.
Ok, so there is another problem :) - As many ticks can come in during a candle's lifetime, you need to make sure that your alert is only triggered at the start of the newest candle. Just add in these few lines will do:
Now, when I test run your codes, I noticed that your MajorCycle/MinorCycle Buy/Sell arrays may not be set correctly such that you still get one alert at the start of every candle - for that, you'll have to check through the main logic of your code, since, unless you explain what it does, nobody can help you debug.
thank you very much for your input :) really appreciate it, Will give it a try :)
thanks bud
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi there,
please can anyone help - im no coder and tried my best to modify this indicator to add Push Notifications on when the MajorCycle fires the Buy or Sell signal.... it works BUT the alerts never stops... it continues to alert on my mobile, what do i need to add or change so that it only push notification once.
Please see attached,
Many thanks