Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

AddPlot

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

    AddPlot

    Does AddPlot method work for OnRender?

    I got my cma in OnRender
    use AddPlot(Brushes.Blue, "cma");

    wont work

    Thank you
    Last edited by frankduc; 08-15-2019, 06:15 AM.

    #2
    Hello frankduc,

    Thanks for your post.

    Plot rendering is handled behind the scenes. If you use OnRender, you will also have to call base.OnRender() in OnRender to display the plots. If you do not call base.OnRender, you could use your own code for rendering the plots. Please see the example snippets in the documentation below.

    OnRender - https://ninjatrader.com/support/help...s/onrender.htm

    We look forward to being of further assistance.

    Comment


      #3
      i did add before my cma code

      base.OnRender(chartControl, chartScale);

      but i still cant see any line in the chart.

      Comment


        #4
        Hello frankduc,

        Please see the demonstration below and test the same on your end.



        I suggest comparing against this indicator and to also ensure that your indicator is working and plotting without using OnRender code, and then to test with the OnRender code included to narrow the issue down further.

        It will also be helpful to check the the log of the Control Center for any errors that may be thrown and will need to be corrected.

        Please let us know if we can be of further assistance.

        Comment


          #5
          for(int barIndex = foundIndex; barIndex <= ChartBars.ToIndex; barIndex++)
          {
          double closePrice = Bars.GetClose(barIndex);
          double volumes = Bars.GetVolume(barIndex);
          double clovol = closePrice * volumes;


          sum1 += clovol++;
          sum2 += volumes++;


          cma = sum1 / sum2;



          }
          and of course
          AddPlot(Brushes.Blue, "cma"); in


          State.SetDefaults

          Do i need to add something in region proprieties?


          The way i see it in your video the cma would appear in a bottom indicator. My cma is like a sma its an average and must show up in the chart.

          If i code the cma in OnbarUpdate with Value[0] = cma; i can see the last dot value and price of the cma but not the line in the chart. Strange!

          no error in the log and the cma return what's its suppose to return. unless my cma return only the last value? but i dont think its the case.
          in proprieties indicator i can see the Plot CMA its just that the line wont show up.
          Last edited by frankduc; 08-16-2019, 11:59 AM.

          Comment


            #6
            Hello frankduc,

            If i code the cma in OnbarUpdate with Value[0] = cma; i can see the last dot value and price of the cma but not the line in the chart. Strange!
            This is the behavior that would be seen if you have a plot added with values assigned but base.OnRender() is not called in OnRender(). Please ensure that a) you are assigning the plot's Value in OnBarUpdate to a valid value, and b) that base.OnRender() is being called in OnRender() if you are using OnRender() in the script.

            Plot values are intended to be assigned in OnBarUpdate so each bar has a plot value associated with it. If you are trying to assign the Plot's Value in OnRender, you will only be updating the developing Plot Value when render passes occur and you will not have any historical plots.

            We look forward to being of further assistance.

            Comment


              #7
              Using
              base.OnRender(chartControl, chartScale); in OnRender create an horizontal blue line at the level of the CMA last value.
              Actually i use the code of the cma in OnbarUpdate and in OnRender and i tried to erase the cma from OR but with no success. The cma is called in private double.
              Something is preventing the line from drawing.
              What do you mean by:
              a) you are assigning the plot's Value in OnBarUpdate to a valid value

              Value[0] = cma is a valid value no? if i print Value[] ill get all the values cma for each bar from
              foundIndex to ChartBars.ToIndex

              Comment


                #8
                Hello frankduc,

                If you are assigning Value[0] on OnBarUpdate as seen in my video, you will be assigning a valid value for each bar.

                I suggest setting up the same test I have on your end, and then to comment code in your script until it matches the demonstration.

                Please let me know if we can be of further assistance.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                649 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                370 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                109 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                573 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                576 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X