Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cannot impliciily convert type double to NinjaScript Series,double

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

    Cannot impliciily convert type double to NinjaScript Series,double

    I'm trying to add an SMA average volume to the volume indicator.


    AddPlot(Brushes.Blue, "Avg"); // NEW -- Average Volume Plot [0]
    ...
    double avgVol = SMA(Volume, Period)[0];
    Values[0] = avgVol;
    ..
    [Browsable(false)]
    [XmlIgnore()]
    public Series<double> Default
    {
    get { return Values[0]; }
    }
    ...
    But I got the following compile error:



    Error: Cannot impliciily convert type double to NinjaScript Series,double>

    Code: CS0029

    I have the same problem when I changed to:

    Values[0] = SMA(Volume, Period)[0];

    However, I was succesful in compiling the following code when I did in another NinjaScript:
    ...
    DiffUp[0] = CCI(Period)[0];
    ...
    DiffDown[0] = CCI(Period)[0];

    ...

    I could find much information on the Beta 8 Help Guide. Appreciate any suggestions you can provide.

    Thanks,

    Richard

    #2
    Originally posted by Richard168 View Post
    double avgVol = SMA(Volume, Period)[0];
    Values[0] = avgVol;
    Code:
    Values[0][0] = avgVol;
    -=Edge=-
    NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

    Comment


      #3
      Originally posted by -=Edge=- View Post
      Code:
      Values[0][0] = avgVol;
      Thanks for your quick reply. It works!
      Last edited by Richard168; 08-15-2015, 07:07 AM.

      Comment


        #4
        Hello Richard168,

        Thanks for your posts and thanks to member -=Edge=- for his appreciated input.

        I found that when adding the sma plot to the indicator that I had to set it to be Values[1][0] as this was the 2nd plot (the Vol is the first plot [0][0]).

        Alternatively you don't need to create an indicator to accomplish this. You can add the SMA to the Vol indicator on the chart by changing the input series via the indicator panel of the SMA indicator to be the Vol indicator. This method allows you to use any moving average and can be done without coding. See attached.
        Attached Files
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by JoMoon2024, Today, 06:56 AM
        0 responses
        6 views
        0 likes
        Last Post JoMoon2024  
        Started by Haiasi, 04-25-2024, 06:53 PM
        2 responses
        17 views
        0 likes
        Last Post Massinisa  
        Started by Creamers, Today, 05:32 AM
        0 responses
        5 views
        0 likes
        Last Post Creamers  
        Started by Segwin, 05-07-2018, 02:15 PM
        12 responses
        1,786 views
        0 likes
        Last Post Leafcutter  
        Started by poplagelu, Today, 05:00 AM
        0 responses
        3 views
        0 likes
        Last Post poplagelu  
        Working...
        X