Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unwanted plot behavior between sessions? Also,Question for plotting with onRender()

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

    Unwanted plot behavior between sessions? Also,Question for plotting with onRender()

    Hello.

    If you add a plot to a chart via:
    Code:
    AddPlot(Brushes.LawnGreen, "APlot");
    You will get the behavior inbetween sessions, shown in the image. The left image highlights this behavior, while the right side shows an example of a similar indie that does not.

    I am wondering if there is an obvious way to not have this happen, as this is a VWAP type of indicator, and I want the values to be independant of the prior session. And that sort of carry-over behavior is ugly.


    Next, my question is about plotting via the onRender() method, if I wanted to accomplish this plot with that method.

    Assuming I have the values stored for the plot in a data series like:
    Code:
    private Series<double> SomeDataSeries;
    When plotting in the onRender method... would the idea be to loop over a section of the visible portion on the chart by using something like ChartBars.FromIndex and ChartBars.ToIndex to get the visible range of the chart... and run a plot somehow as to only plot value of that dataseries for the viewable range of the chart.


    So to recap, two separate questions about plotting.
    1. Is there a simple way using the normal Plot functions to remove that carry-over behavior in between sessions, where the calculations are completely independant from day to day, and I'd like to not have the plot connect itself from the last value of the prior session to the first value of the new session?
    2. If I were going to use the onRender() method to do this plotting, is the idea to loop through in the onRender() method the viewable data in the chart, the plot the various plots I would want? If so, is there a sample showing how one would do this?
    Thanks!
    Attached Files
    Last edited by forrestang; 01-01-2021, 08:13 AM.

    #2
    Hello forrestang,

    Thanks for your post.

    1) On the first bar of the session, use PlotBrushes[][] and set the plot at that point to Transparent. This will prevent seeing the connecting line from the last bar of the session to the first bar. The next bar (after the first bar) will still draw from the first bar to the second bar, thus providing a disconnected line. I've attached an example script you can test with. It will plot from the first bar of the session to the end of the session using the close value of the first bar of the session. Assuming the close price from one session to the next is different you will see two separate lines (see screenshot). I also added a bool to switch that off and connect the lines if you want to see the effect or possibly use it as an option.

    Click image for larger version

Name:	Forrestang-1.PNG
Views:	513
Size:	30.2 KB
ID:	1134659

    Click image for larger version

Name:	Forrestang-2.PNG
Views:	439
Size:	32.1 KB
ID:	1134660

    [ATTACH]n1134661[/ATTACH]

    Another option is to plot using PlostStyle.Hash as it limits the plot to the width of the bar.


    2) Correct, you would loop through the visible bars. For an OnRender example, I would suggest looking at the Pivots indicator.


    Comment


      #3
      Originally posted by NinjaTrader_PaulH View Post
      1) On the first bar of the session, use PlotBrushes[][] and set the plot at that point to Transparent....
      Thanks, see attached pic, got that working.



      Originally posted by NinjaTrader_PaulH View Post
      2) Correct, you would loop through the visible bars. For an OnRender example, I would suggest looking at the Pivots indicator.
      Do you know of another sample indicator that may do this? If not, don't worry about it, just wondering if you may know off the top of your head of another one? I find the pivot example a bit confusing the way it was done. Again, only asking if you know of another sample indie that may do this limited plotting only on visible info if you can think of one... no need to really look, as I'll eventually figure this out.


      Attached Files

      Comment


        #4
        Hello forrestang,

        Thanks for your reply.

        Another example indicator would be "VolumeZones"

        Comment


          #5
          Originally posted by NinjaTrader_PaulH View Post
          Hello forrestang,

          Thanks for your reply.

          Another example indicator would be "VolumeZones"
          I guess the type of example I am looking for, is something that would be like a moving average.

          An example, is that I have created a set of averages, and I wanted to add text to the chart as well, but have the control I could get by using the onRender() to build the text. I added the text in the onRender() method, however this voids the plots that I have created that are assigned in the onBarUpdate() method.

          So this makes me think to have the control I want in placing the text, I would have to create the moving averages in the onRender() method as well?

          Can you think of an example that efficiently builds out something like a moving average in the onRender() method?

          Would it be extremely inefficient to create averages in this way, as you'd like be redrawing an average that spans the screen anytime the chart is manipulated?

          I am really only wanting to do this, as I cannot seem to create normal plots(for building moving averages)... AND have the control to place text where I want on-chart, in the onRender() method.
          Last edited by forrestang; 01-06-2021, 12:13 AM.

          Comment


            #6
            Hello forrestang,

            Thanks for your reply.

            Please see my reply to your other post here: https://ninjatrader.com/support/foru...ting-by-design

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            597 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            343 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            103 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            556 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            555 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X