I am running into the following error message: "Use of unassigned local variable 'SendAlert' ". I know that setting a value at the beginning of the OnBarUpdate( ) section will work but that causes a problem.
Here's the logic of my script:
1. I want the custom indicator to send me an email alert when a condition is met
2. I need to use CalculateOnBarClose = false, so the condition is checked at every tick
3. I want to receive the alert only once for a given candle, when the condition is met
4. I want to suppress the alert for the remaining ticks until a new candle is created
5. When a new candle is created, I re-evaluate whether the condition is met (loop to #3)
I cannot assign a value to SendAlert at the begining of OnBarUpdate( ) because that may override the value set in a conditional statement during the previous tick. The variable needs to be set outside the protected override void OnBarUpdate() section. Putting bool SendAlert = true in the protected override void Initialize() section did not work. That still generated the error mentionned at the beginning of this post.
What is the solution to this issue? Thanks.
- MarcusPlexus
Comment