hi guys if anyone with has an experience with ninjascript editor i get a lot of error trying to add simple filters to this indicator that show arrows to filter signals here are the condition for the filters :
first for the buy signal i want to add the filter of the 8ema must be abov the 10ema and the 21 ema and for the sell case i want the 8 ema to be under the 10 ema and under the 21 ema, the buy signal the candle must close above the 8 ema and for the sell the candle must close undder the 8 ema + sound alert when arrow prints
if anyone can help debugging this code i will be more than happy it a good strategy for scalping between .
here is the code that gets a tone of errors :
// Inside NinjaTrader.NinjaScript.Indicators namespace
region Using declarations
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Gui;
import NinjaTrader.Gui.Chart;
import NinjaTrader.Gui.SuperDom;
import NinjaTrader.Gui.Tools;
import NinjaTrader.Data;
import NinjaTrader.NinjaScript;
using NinjaTrader.Core.FloatingPoint;
#endregion
namespace NinjaTrader.NinjaScript.Indicators
{
public partial class SCALPbuysell : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
{
// Existing code...
region Properties
[Browsable(false)]
[XmlIgnore]
public Series<double> EMA8 { get; private set; }
[Browsable(false)]
[XmlIgnore]
public Series<double> EMA10 { get; private set; }
[Browsable(false)]
[XmlIgnore]
public Series<double> EMA21 { get; private set; }
#endregion
protected override void OnStateChange()
{
// Existing code...
if (State == State.SetDefaults)
{
// Set default values for existing parameters...
EMA8 = new Series<double>(this);
EMA10 = new Series<double>(this);
EMA21 = new Series<double>(this);
}
}
protected override void OnBarUpdate()
{
// Calculate EMAs
double ema8Value = EMA(Closes[0], 8)[0];
double ema10Value = EMA(Closes[0], 10)[0];
double ema21Value = EMA(Closes[0], 21)[0];
// Buy Signal Filter: 8 EMA above 10 EMA and 21 EMA, Candle closes above 8 EMA
bool buyFilter = ema8Value > ema10Value && ema8Value > ema21Value && Close[0] > ema8Value;
// Sell Signal Filter: 8 EMA below 10 EMA and 21 EMA, Candle closes below 8 EMA
bool sellFilter = ema8Value < ema10Value && ema8Value < ema21Value && Close[0] < ema8Value;
// Your main logic here...
if (buyFilter)
{
// Buy Signal Action
Print("Buy Signal on " + this.Name);
// Your logic for Buy Signal...
}
else if (sellFilter)
{
// Sell Signal Action
Print("Sell Signal on " + this.Name);
// Your logic for Sell Signal...
}
}
// Remaining code from the provided BuySellCandleMarker class goes here...
}
}
Comment