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

On render - Drawing smooth line plots - best technique

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

    On render - Drawing smooth line plots - best technique

    Hi,

    I want to replace the standard plot in the EMA with an onRender plot. This is due to the negative effects I have found with assigning colours to each bar of that plot, for slope, etc. I can avoid this if I use onrender.

    My query is, do you have any examples of how you would plot something like an EMA line plot, using onrender? The reason I ask. I made a series and drew my plot with line to line (one value to next). It works fine. My only niggle with is, is that the plot looks a bit staircase (rough), whereas the default ema plot is nice and smooth in comparison. Given it is the same underlying data, I was wondering why this might be. Do the NT team (or anyone else) have any suggestions for producing a nice, smooth line plot from a series containing something like an ema set of data? Any example code would be appreciated. I checked around, but for most simple things like this, I could not find anything using onRender.

    I'm being really finicky here, as what I have works - It's just not as pleasing to the eye!

    Thanks.

    #2
    Hello pjsmith,

    Thanks for your question.

    I do not have a specific example to share, but I can offer my insights.

    Note that the EMA will have plot values associated with each bar and each plot value is connected by a segment line. If you zoom in on the EMA, we can see that each line is connected to the plot value for the bar, and then to the plot value of the next bar. There is not any actual smoothing going on, but the fact that the line is a moving average, the visual output is somewhat smooth.

    If you would like to add additional smoothing than what would be seen when connecting each plot value, you could consider adding a point between each plot where the line should go before it connects to the next plot. I have taken an approach like this with my conversion of the Ichimoku Cloud indicator where an additional point is added where the moving average lines crossover. (This gives a definite point where the lines cross over so each cloud has a sharp point.) I have linked this indicator for your reference. It uses RenderTarget.FillGeometry, not RenderTarget.DrawLine, so the line drawing would not be as applicable as the concept of drawing the line between bars.

    I would recommend sticking with RenderTarget.DrawLine if you would like to be able to colorize segments of the plot line separately.

    IchimokuCloud - https://ninjatraderecosystem.com/use...indicator-nt8/

    The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.

    I look forward to assisting.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by briansaul, Today, 05:31 AM
    0 responses
    2 views
    0 likes
    Last Post briansaul  
    Started by fwendolynlpxz, Today, 05:19 AM
    0 responses
    4 views
    0 likes
    Last Post fwendolynlpxz  
    Started by traderqz, Yesterday, 12:06 AM
    11 responses
    28 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by PaulMohn, Today, 03:49 AM
    0 responses
    8 views
    0 likes
    Last Post PaulMohn  
    Started by inanazsocial, Today, 01:15 AM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_Jason  
    Working...
    X