Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    JimNinjaTrader Customer Service

    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.
        JimNinjaTrader Customer Service

        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.
            JimNinjaTrader Customer Service

            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.

                JimNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by techgetgame, Yesterday, 11:42 PM
                0 responses
                8 views
                0 likes
                Last Post techgetgame  
                Started by sephichapdson, Yesterday, 11:36 PM
                0 responses
                2 views
                0 likes
                Last Post sephichapdson  
                Started by bortz, 11-06-2023, 08:04 AM
                47 responses
                1,613 views
                0 likes
                Last Post aligator  
                Started by jaybedreamin, Yesterday, 05:56 PM
                0 responses
                10 views
                0 likes
                Last Post jaybedreamin  
                Started by DJ888, 04-16-2024, 06:09 PM
                6 responses
                20 views
                0 likes
                Last Post DJ888
                by DJ888
                 
                Working...
                X