Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Wanting to Plot VWMA+std and VWMA-std

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

    Wanting to Plot VWMA+std and VWMA-std

    I am trying to create two new series to plot on the chart as VWMA+STD and VWMA-STD, but keep getting error msg "cannot convert..." . In fact, creating a new series based on any (simple) math operation between two series, and plotting the results...
    Any suggestion would be appreciated ..
    BB

    #2
    Hello bboukai,

    Thank you for your post.

    If you are getting a compile error, please post a screenshot of the error along with the line of code referenced in the error.

    Comment


      #3
      Here is the error msg-- but my problem is setting it up-- I surely can use any example you might have...
      Attached Files

      Comment


        #4
        Can you please post the line of code referenced in the error?

        Below is some general code for how to assign the value of two indicators to a custom Series:

        Code:
        //at the class level
        private Series<double> mySeries;
        
        //in OnStateChange when State is State.DataLoaded
        mySeries = new Series<double>(this);
        
        //within OnBarUpdate
        mySeries[0] = VWMA(14)[0] + StdDev(20)[0];

        Comment


          #5
          This is helpful-- I overcame the error mas following your example.... but now how can I add the plot of MySeries (of your example to the chart ) . When I use
          AddPlot(Brushes.Orange, "MySeries");

          in State == State.DataLoaded it complies but not executed .

          Comment


            #6
            The code above will just assign the value to a series, that series is not a plot.

            If you want to assign the value to a plot it's not necessary to create an entire other series, you can just directly assign the value to a plot via AddPlot().

            The Help Guide page has code demonstrating.

            Comment


              #7
              This is not helpful-- as I already stated before that I use

              AddPlot(Brushes.Orange, "MySeries");

              in State == State.DataLoaded it complies but does not execute. I even tried, per the guide, State == State.Configure,, but still no plot...​

              Comment


                #8
                To be clear, I provided you the Help Guide because you still need to assign a value to the plot (not just create a custom series and assign values to the series). In addition to creating the plot in OnStateChange(), you should be assigning values to the plot (not the series) in OnBarUpdate. Assigning values to the series will not create a plot.

                If it is compiling, and you are assigning a value to the plot in the script, then you will need to debug it.


                To understand why the script is behaving as it is, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

                In the script add prints (outside of any conditions) that print the date time of the bar and all values compared in every condition.

                The prints should include the time of the bar and should print all values from all variables and all hard coded values in all conditions that must evaluate as true for this action to be triggered. It is very important to include a text label for each value and for each comparison operator in the print to understand what is being compared in the condition sets.

                The debugging print output should clearly show what the condition is, what time the conditions are being compared, all values being compared, and how they are being compared.

                Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).

                I am happy to assist you with analyzing the output from the output window.

                Run or backtest the script and when the output from the output window appears save this by right-clicking the output window and selecting Save As... -> give the output file a name and save -> then attach the output text file to your reply.

                Below is a link to a support article that demonstrates using informative prints to understand behavior and includes a link to a video recorded using the Strategy Builder to add prints.

                https://support.ninjatrader.com/s/ar...nd-TraceOrders
                Last edited by NinjaTrader_Gaby; 05-09-2025, 09:03 AM.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                547 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                323 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                99 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                543 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                545 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X