I want to use the Strategy builder to play Audio Alerts, because:
1) then I'll be able to copy alerts between templates/workspaces easily and more importantly
2) one of my most important indicators doesn't support Audio Alerts, but it does output into Ninja strategy.
This is a simple strat I tried to make in the strategy builder,
if any kind person could direct me as to what I did wrong,
I'd appreciate that as the alert is not working at all.
Thank you.
namespace NinjaTrader.NinjaScript.Strategies
{
public class EmaAudioAlert : Strategy
{
private EMA EMA1;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Ema Audio Alert";
Name = "EmaAudioAlert";
Calculate = Calculate.OnEachTick;
EntriesPerDirection = 1;
EntryHandling = EntryHandling.AllEntries;
IsExitOnSessionCloseStrategy = true;
ExitOnSessionCloseSeconds = 30;
IsFillLimitOnTouch = false;
MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
OrderFillResolution = OrderFillResolution.Standard;
Slippage = 0;
StartBehavior = StartBehavior.WaitUntilFlat;
TimeInForce = TimeInForce.Gtc;
TraceOrders = false;
RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
StopTargetHandling = StopTargetHandling.PerEntryExecution;
BarsRequiredToTrade = 20;
// Disable this property for performance gains in Strategy Analyzer optimizations
// See the Help Guide for additional information
IsInstantiatedOnEachOptimizationIteration = true;
}
else if (State == State.Configure)
{
}
else if (State == State.DataLoaded)
{
EMA1 = EMA(Close, 2);
EMA1.Plots[0].Brush = Brushes.Goldenrod;
AddChartIndicator(EMA1);
}
}
protected override void OnBarUpdate()
{
if (BarsInProgress != 0)
return;
if (CurrentBars[0] < 1)
return;
// Set 1
if (CrossAbove(EMA1, EMA1, 1))
{
PlaySound(@"C:\Program Files\NinjaTrader 8\sounds\Alert2.wav");
}
}
}
}

Comment