Pine Script Alert Condition
Posted: Thu Dec 10, 2020 8:56 pm
I am having problems with random alerts and don't understand where the problem is. The following illustrates my issue. Its a very simple script that I would expect to generate an alert every 2 min on any ticker with real-time data using the option "Once Per Minute" using a 1 minute chart. However on a random basis I get an alert in between the 2 minute window
//@version=4
study("Alert Condition Test Harness")
alertcondition(minute % 2 ? 0 : 1, title="Alert Condition Test", message="Should be every 2 mins")
Here is an example Alert Log fle
Alert ID Ticker Description Time
126037673 FX:EURGBP, 1m Should be every 2 mins 2020-12-10T20:52:00.000Z As Expected
126037673 FX:EURGBP, 1m Should be every 2 mins 2020-12-10T20:51:00.000Z Did not expect
126037673 FX:EURGBP, 1m Should be every 2 mins 2020-12-10T20:50:00.000Z As Expected
126037673 FX:EURGBP, 1m Should be every 2 mins 2020-12-10T20:48:02.000Z As Expected
126037673 FX:EURGBP, 1m Should be every 2 mins 2020-12-10T20:47:01.000Z Did not expect
126037673 FX:EURGBP, 1m Should be every 2 mins 2020-12-10T20:46:01.000Z As Expected
126037673 FX:EURGBP, 1m Should be every 2 mins 2020-12-10T20:44:43.000Z As Expected
Anyone know why this would occur. The condition minute % 2 ? 0 : 1 is only true every even minute.
//@version=4
study("Alert Condition Test Harness")
alertcondition(minute % 2 ? 0 : 1, title="Alert Condition Test", message="Should be every 2 mins")
Here is an example Alert Log fle
Alert ID Ticker Description Time
126037673 FX:EURGBP, 1m Should be every 2 mins 2020-12-10T20:52:00.000Z As Expected
126037673 FX:EURGBP, 1m Should be every 2 mins 2020-12-10T20:51:00.000Z Did not expect
126037673 FX:EURGBP, 1m Should be every 2 mins 2020-12-10T20:50:00.000Z As Expected
126037673 FX:EURGBP, 1m Should be every 2 mins 2020-12-10T20:48:02.000Z As Expected
126037673 FX:EURGBP, 1m Should be every 2 mins 2020-12-10T20:47:01.000Z Did not expect
126037673 FX:EURGBP, 1m Should be every 2 mins 2020-12-10T20:46:01.000Z As Expected
126037673 FX:EURGBP, 1m Should be every 2 mins 2020-12-10T20:44:43.000Z As Expected
Anyone know why this would occur. The condition minute % 2 ? 0 : 1 is only true every even minute.