Trading Signals is just an indicator i need using any strategy, giving buy and sell signals on chart.
//here is you one to start with // // Import required namespaces #region Using declarations using System; using NinjaTrader.Cbi; using NinjaTrader.Gui.Tools; using NinjaTrader.NinjaScript; #endregion namespace NinjaTrader.NinjaScript.Indicators { public class MovingAverageCrossoverSignals : Indicator { // Inputs for the Moving Averages [Range(1, int.MaxValue), NinjaScriptProperty] [Display(Name = "Fast MA Period", Order = 1, GroupName = "Parameters")] public int FastMAPeriod { get; set; } [Range(1, int.MaxValue), NinjaScriptProperty] [Display(Name = "Slow MA Period", Order = 2, GroupName = "Parameters")] public int SlowMAPeriod { get; set; } // Series for the moving averages private SMA FastMA; private SMA SlowMA; protected override void OnStateChange() { if (State == State.SetDefaults) { // Default settings Description = "Simple Moving Average Crossover Strategy with Buy/Sell Signals"; Name = "MovingAverageCrossoverSignals"; FastMAPeriod = 10; SlowMAPeriod = 30; IsOverlay = true; AddPlot(Brushes.Green, "Buy Signal"); AddPlot(Brushes.Red, "Sell Signal"); } else if (State == State.DataLoaded) { // Initialize the moving averages FastMA = SMA(FastMAPeriod); SlowMA = SMA(SlowMAPeriod); } } protected override void OnBarUpdate() { // Ensure enough data for calculation if (CurrentBar < Math.Max(FastMAPeriod, SlowMAPeriod)) return; // Calculate moving averages double fastValue = FastMA[0]; double slowValue = SlowMA[0]; // Buy Signal: Fast MA crosses above Slow MA if (CrossAbove(FastMA, SlowMA, 1)) { Draw.ArrowUp(this, "BuySignal" + CurrentBar, true, 0, Low[0] - TickSize, Brushes.Green); Alert("BuySignal", Priority.High, "Buy Signal Triggered", "Alert1.wav", 10, Brushes.Green, Brushes.Black); PlotValues[0][0] = Low[0] - TickSize; } // Sell Signal: Fast MA crosses below Slow MA else if (CrossBelow(FastMA, SlowMA, 1)) { Draw.ArrowDown(this, "SellSignal" + CurrentBar, true, 0, High[0] + TickSize, Brushes.Red); Alert("SellSignal", Priority.High, "Sell Signal Triggered", "Alert2.wav", 10, Brushes.Red, Brushes.Black); PlotValues[1][0] = High[0] + TickSize; } } } }