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 cmoran13, 04-16-2026, 01:02 PM
      0 responses
      36 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      23 views
      0 likes
      Last Post PaulMohn  
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      162 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      96 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      152 views
      2 likes
      Last Post CaptainJack  
      Working...
      X