progr. question

 
I just left Metastock Rt behind to get to know MetaTrader Software, which seems much more flexible.
I'd like to ask simple question:
I have an indicator, which shows a signal(graphic) under certain conditions in the typical form of "if then...else etc."
Now, I implemented the function "PlaySound("alert.wav")" when the (signal-) condition(if then..) mentioned above is true.
The problem is:
How do I program the condition/signal so that it is triggering the acoustic alert only if the condition is true FOR THE LAST BAR(and maybe both for "last Bar-1" and the last bar to confirm etc.)in the chart?
(now the alert is triggered as soon as I add the indicator to the chart window) I'd appreciate any help.
Reason: