|
Seattle, Washington
Experience: Intermediate
Platform: NinjaTrader
Trading: ES,NQ RTY, YM, GC, CL, SI, etc
Posts: 6 since Mar 2011
Thanks Given: 6
Thanks Received: 1
|
Greetings!
Can anyone explain how to play a sound file once while x is true. Not once per bar, just once until x is false, then the sound file would play only the first time x is true again. No matter how many bars x is true, it only plays a sound the very first time in a sequence where x is true.
I tried this below but it still sounds once per bar, not just once, while x (a rising stoch indicator) is true over multiple bars.
///SOUND ALERT and Plot Color
///
///DS Rising
bool BoolSound = false;
int SoundCounter = 0;
if(
BoolSound == false
&& DoubleStochastics(5)[0] > DoubleStochastics(5)[1]
)
{
BoolSound = true;
PlotBrushes[3][0] = Brushes.PowderBlue; //MTF barsarray 3
SoundCounter = 1;
}
else {BoolSound = false; SoundCounter = 0;}
if (CurrentBar == currentBarFlag )
return;
if(BoolSound == true
&& SoundCounter == 1)
{
PlaySound(SoundFileBuy);
currentBarFlag = CurrentBar;
SoundCounter = SoundCounter + 1;
}
Thank you for your consideration!
|