Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

I don't know why I'm getting CS0021

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

    I don't know why I'm getting CS0021

    I'm trying to add an ema to an Exponential version of the Awesome Oscillator. I've added an EMA to another histogram type indicator. However, I have no idea why I'm getting CS0021. I looked at NS's reference guide for CS0021, but everything looks right...to me at least. Here is the code:


    private double ao = 0; // EMA difference

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"AOEMA with a exponential moving average.";
    Name = "AOEMAma";
    Calculate = Calculate.OnBarClose;
    IsOverlay = false;
    DisplayInDataBox = true;
    DrawOnPricePanel = false;
    DrawHorizontalGridLines = false;
    DrawVerticalGridLines = false;
    PaintPriceMarkers = false;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
    //See Help Guide for additional information.
    IsSuspendedWhileInactive = true;
    EMA1 = 5;
    EMA2 = 34;
    EMA_Period = 5;
    AddPlot(new Stroke(Brushes.Lime, 2), PlotStyle.Bar, "AOBarPlot");
    AddPlot(new Stroke(Brushes.Red, 2), PlotStyle.Bar, "AOLinePlot");
    AddLine(Brushes.Gray, 0, "ZeroLine");
    AddPlot(Brushes.Blue, "EMALine");
    }
    else if (State == State.Configure)
    {
    }
    }

    protected override void OnBarUpdate()
    {
    ao = EMA(Median,EMA1)[0] - EMA(Median,EMA2)[0]; // Get EMA difference

    AOBarPlot[0] = ao; // plot the bar histogram
    AOLinePlot[0] = ao; // plot the line on top of the histogram

    //Value[4][0] = EMA(aoEMA2(EMA1,EMA2),EMA_Period)[0];

    if (IsRising(AOBarPlot)) // Color Bar based on Current value to initial value
    {
    PlotBrushes[0][0] = Brushes.Lime;
    Value[4][0] = EMA(aoEMA2(EMA1,EMA2),EMA_Period)[0];
    }
    else
    {
    PlotBrushes[0][0] = Brushes.Red;
    Value[4][0] = EMA(aoEMA2(EMA1,EMA2),EMA_Period)[0];
    }
    }

    #2
    I solved the Value to Values problem. Now, the indicator isn't visible after it compiles.

    Comment


      #3
      I solved all problems. I changed Values to EMALine and it worked.

      Comment


        #4
        Hello jamestrader21x, thanks for your post.

        We appreciate you writing in. If there is anything else that comes up please let me know and I will be happy to help.

        Best regards,
        -ChrisL

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        579 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        334 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        554 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        551 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X