Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SMA on a formula

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

    SMA on a formula

    Hello,

    I'm getting an error when I try to compile the following:

    double VOLRaw = Bollinger(RSIWAvg,2,20).Upper[0] - Bollinger(RSIWAvg,2,20).Lower[0];
    SMA VOLRawAvg = SMA(VOLRaw, k_15);


    I'm taking the difference between bollingerbands. Then I want to plot the "average difference" of the bollingerbands.

    I'm getting hte following errors:

    Indicator\AccuSignalVOLATILITY.cs Argument '1': cannot convert from 'double' to 'NinjaTrader.Data.IDataSeries' NT1503 - click for info 133 24

    Indicator\AccuSignalVOLATILITY.cs Argument '1': cannot convert from 'double' to 'NinjaTrader.Data.IDataSeries' NT1503 - click for info 133 24


    Help! This certainly must be simple to accomplish, but I'm transitioning from EL to C# and I'm having problems figuring it out.

    Thanks much

    #2
    Hello,

    Thanks for the forum post:

    double VOLRaw = Bollinger(RSIWAvg,2,20).Upper[0] - Bollinger(RSIWAvg,2,20).Lower[0];

    This line looks fine at first glance.


    SMA VOLRawAvg = SMA(VOLRaw, k_15);

    Not sure what your doing with this line though. There are two problems.

    You can't difine something of type SMA, also you are missing the [0] at the end of your SMA call. You should define VOLRAWAVG before hand in variables section

    double VOLRawAvg;

    Should probably look a little more like this:

    VOLRawAvg = SMA(VOLRaw, k_15)[0];

    Then plot VOLRawAvg.

    Let me know if I can be of further assistance.
    BrettNinjaTrader Product Management

    Comment


      #3
      While you can define a variable to be of type SMA, you will still need to declare it correctly. Your declaration is attempting to use a double as the input. You have to use a DataSeries, so you should first create a DataSeries using VOLRaw. Then you can run any indicator on the DataSeries.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      666 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      377 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      110 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      575 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      580 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X