Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator Doesn't Plot

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

    Indicator Doesn't Plot

    My code compiles, but the indicator doesn't draw anything on the chart. I checked that "Skewness" is loaded under Initialize() and that I set the value. Once again I am neglecting something basic... just need someone to point me in the right direction please.


    protected override void Initialize()
    {
    Add(
    new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Skewness"));
    CalculateOnBarClose =
    true;
    Overlay =
    false;
    PriceTypeSupported =
    false;
    closeOpen =
    new DataSeries(this);
    sDev =
    new DataSeries(this);
    }


    protected override void OnBarUpdate()
    {
    closeOpen.Set(Close[
    0] - Open[0]);
    if ( CurrentBar >= barLookBack )
    {
    sDev.Set(StdDev(closeOpen, barLookBack)[0]) ;

    double xBar = Convert.ToDouble(SMA(closeOpen , barLookBack));
    double sumofCloseOpen = 0 ;

    for(int i = barLookBack; i >= 0; i--)
    {
    sumofCloseOpen = Math.Pow(closeOpen[i] - xBar,
    3) + sumofCloseOpen ;
    }

    Skewness.Set(
    1 / ( (barLookBack - 1) * Math.Pow(sDev[0], 3) ) * sumofCloseOpen);
    }
    }

    #2
    First start by checking the LOG tab for some error.

    If you don't have any, I would start by checking each variable value by adding Print() statements and opening the Output dialog.
    mrlogik
    NinjaTrader Ecosystem Vendor - Purelogik Trading

    Comment


      #3
      Originally posted by mrlogik View Post
      First start by checking the LOG tab for some error.

      If you don't have any, I would start by checking each variable value by adding Print() statements and opening the Output dialog.
      double xBar = Convert.ToDouble(SMA(closeOpen , barLookBack));

      Unable to cast object of type 'NinjaTrader.Indicator.SMA' to type System.IConvertible.


      I changed xBar to a DataSeries and got it working.

      Thanks again mrlogik.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      571 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      330 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
      548 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      549 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X