版本 1.10
2024.10.14
Key changes in this version:
Added a firstAlertTime variable to track when the first alert is triggered.
Added an alertsPeriodEnded boolean to indicate when the one-minute alert period is over.
In the OnInit function, we reset all alert-related variables to ensure a fresh start when the indicator is added or reloaded.
In the OnCalculate function:
First, we will check if the alert period has ended. If so, we do nothing.
When the first alert is triggered, we set the first alert time.
We only allow alerts if we're within one minute of the first alert (currentTime < firstAlertTime + 60) and haven't exceeded the alert frequency.
If it has been one minute since the first alert, we set alertsPeriodEnded to true and give a final message about the total number of alerts.
This version will:
Start giving alerts when the condition is first met.
Continue giving alerts for exactly one minute from the first alert, respecting the specified frequency.
Stop all alerts after one minute has passed since the first alert.
Provide a final message when the alert period ends, stating how many alerts were given.
The indicator will not reset or give any more alerts after this one-minute period unless it's removed and added again to the chart.