I have been playing around with an indicator I found and have set it up to be able to email me when it triggers. the problem is it sends the mail every tick.
what I havent been able to do is get the code that allows it to send an alert and then not send another for 15 mins (until the next bar as its on a 15 min chart)
At the moment I have a bunch of code that checks for the signal and sets indicator trigger to 1 for up trigger and 2 for down then the code that sends the mail, which checks for the trigger and then checks that its triggering for the current minute so that it doesnt trigger for every historical trigger on every chart!
i tried adding something like sentmin=itime(NULL,0,i) inside the triggers ‘if’ and then turning the indicator off if sentmin<Time[i] but it didnt seem to work.
gah still triggers every pip for the first minute (due to the line above that makes sure its the current minute so it doesnt trigger for the entire chart hustory when mt4 is opened)
then in if statement that sends the alert
if trigger>0
sentmin=Time[0]
send email etc etc
end if
trigger = 0
makes no sense, it sets sentmin whenever the trigger is activated, then checks to make sure sentmin isnt the same when it checks for the trigger. Time[0] on a 15 min chart only changes after 15 mins when the next bar opens right? so for 15 mins after a trigger, sentmin should equal time[0] and not trigger again! but it somehow ignores it.
gaaaah nothing works!! Ive attached the indicator im playing around with. its basically the cowabunga indicator and im playing around with it testing various things.
at the moment it checks the previous bar and the one before that for a valid signal, but then its resending the signal on every tick of the current bar even with the code i put in the IF statement where it sends the emails at line 173 to try and stop it sending any for 15 mins but it continues to send on every tick for the first minute of the current bar (after the 1st minute the other part of the IF statement stops any further triggers).
can anyone see whats wrong with it? im not bothered about the rest of the code thats a bit of a mess with trying various things, i just need to let it send 1 alert email and then not do that again for 15 mins until the next bar opens so i dont get 300 emails a day!
seems to be based on number of bars increasing by 1 every time a new bar starts, but wouldnt this mean an endless number of bars? I would have thought when a new bar appears the oldest one is removed so you dont end up with 5 billion bars crashing the whole program
im not sure the indicator is working very well at the moment but at least i wont get spammed to death on top of losing money