Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

CS0103 Error

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    CS0103 Error

    Hi Team,

    I’m currently working on a new indicator and have encountered the errors attached to this message.
    Below is the complete script for your reference.

    I look forward to your help in resolving this issue.
    Thank you in advance!


    using NinjaTrader.NinjaScript;
    using NinjaTrader.NinjaScript.Strategies;
    using NinjaTrader.NinjaScript.DrawingTools;
    using NinjaTrader.Gui.Tools;
    using System.Windows.Media;


    namespace NinjaTrader.NinjaScript.Indicators
    {
    public class TotoScalping : Indicator
    {
    private double ph;
    private double pl;
    private ISeries<double> emaTrend;
    private ISeries<double> emaFastTrend;
    private double auxHigh = double.NaN;
    private double auxLow = double.NaN;
    private int auxHighBar = -1;
    private int auxLowBar = -1;
    private string lastHighLineKey;
    private string lastLowLineKey;
    private bool sessionActive;

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    AddPlot(Brushes.Black, "EMA Trend");
    AddPlot(Brushes.Red, "EMA Fast Trend");
    }
    else if (State == State.DataLoaded)
    {
    emaTrend = EMA(Close, 100);
    emaFastTrend = EMA(Close, 25);
    }
    }

    protected override void OnBarUpdate()
    {
    if (CurrentBar < 16) return;

    // Pivotes altos y bajos
    ph = High[HighestBar(High, 16)];
    pl = Low[LowestBar(Low, 16)];

    // Detectar si la sesión está activa
    sessionActive = (Time[0].Hour >= 8 && Time[0].Hour < 10);

    // Líneas de resistencia (pivote alto)
    if (!double.IsNaN(ph) && emaFastTrend[0] > emaTrend[0])
    {
    if (!double.IsNaN(auxHigh) && ph < auxHigh)
    {
    if (!string.IsNullOrEmpty(lastHighLineKey))
    RemoveDrawObject(lastHighLineKey);

    lastHighLineKey = "ResistanceLine" + CurrentBar;
    Draw.Line(this, lastHighLineKey, auxHighBar, auxHigh, CurrentBar, ph, Brushes.Black, DashStyleHelper.Dash, 2);
    }
    auxHigh = ph;
    auxHighBar = CurrentBar;
    }

    // Líneas de soporte (pivote bajo)
    if (!double.IsNaN(pl) && emaFastTrend[0] < emaTrend[0])
    {
    if (!double.IsNaN(auxLow) && pl > auxLow)
    {
    if (!string.IsNullOrEmpty(lastLowLineKey))
    RemoveDrawObject(lastLowLineKey);

    lastLowLineKey = "SupportLine" + CurrentBar;
    Draw.Line(this, lastLowLineKey, auxLowBar, auxLow, CurrentBar, pl, Brushes.Black, DashStyleHelper.Dash, 2);
    }
    auxLow = pl;
    auxLowBar = CurrentBar;
    }

    // Borrar las líneas cuando las EMAs se cruzan
    if (CrossAbove(emaFastTrend, emaTrend, 1) || CrossBelow(emaFastTrend, emaTrend, 1))
    {
    auxHigh = double.NaN;
    auxLow = double.NaN;
    auxHighBar = -1;
    auxLowBar = -1;
    if (!string.IsNullOrEmpty(lastHighLineKey))
    RemoveDrawObject(lastHighLineKey);
    if (!string.IsNullOrEmpty(lastLowLineKey))
    RemoveDrawObject(lastLowLineKey);
    }

    // Graficar las EMAs en el gráfico
    Values[0][0] = emaTrend[0]; // EMA de 100 periodos
    Values[1][0] = emaFastTrend[0]; // EMA de 25 periodos

    // Etiquetas en los pivotes altos y bajos
    if (emaTrend[0] > emaFastTrend[0])
    {
    Draw.Text(this, "LowLabel" + CurrentBar, "L", CurrentBar, pl, Brushes.White); // Etiqueta "Low"
    }
    else
    {
    Draw.Text(this, "HighLabel" + CurrentBar, "H", CurrentBar, ph, Brushes.White); // Etiqueta "High"
    }

    // Cambiar el color de fondo durante las horas activas de la sesión
    if (sessionActive)
    {
    BackBrush = new SolidColorBrush(Color.FromArgb(95, 255, 255, 255)); // Fondo blanco transparente
    }
    }
    }
    }

    region NinjaScript generated code. Neither change nor remove.

    namespace NinjaTrader.NinjaScript.Indicators
    {
    public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
    {
    private TotoScalping[] cacheTotoScalping;
    public TotoScalping TotoScalping()
    {
    return TotoScalping(Input);
    }

    public TotoScalping TotoScalping(ISeries<double> input)
    {
    if (cacheTotoScalping != null)
    for (int idx = 0; idx < cacheTotoScalping.Length; idx++)
    if (cacheTotoScalping[idx] != null && cacheTotoScalping[idx].EqualsInput(input))
    return cacheTotoScalping[idx];
    return CacheIndicator<TotoScalping>(new TotoScalping(), input, ref cacheTotoScalping);
    }
    }
    }

    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
    {
    public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
    {
    public Indicators.TotoScalping TotoScalping()
    {
    return indicator.TotoScalping(Input);
    }

    public Indicators.TotoScalping TotoScalping(ISeries<double> input )
    {
    return indicator.TotoScalping(input);
    }
    }
    }

    namespace NinjaTrader.NinjaScript.Strategies
    {
    public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
    {
    public Indicators.TotoScalping TotoScalping()
    {
    return indicator.TotoScalping(Input);
    }

    public Indicators.TotoScalping TotoScalping(ISeries<double> input )
    {
    return indicator.TotoScalping(input);
    }
    }
    }

    #endregion​
    Attached Files

    #2
    Hello Bernabé,

    You are missing the required using statements, please open any stock indicator like the SMA and copy all of the using statements from the top where you see region using. And replace the statements you have in your file.

    Comment


      #3
      Thanks Jesse!
      Have a nice day!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      60 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      39 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      21 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      23 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      51 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X