Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to draw a line using OnRender

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

    How to draw a line using OnRender

    Hi

    I'm trying to get my head around how to use OnRender to draw a line on a chart at a given price (open price at 10am) and between a time period (e.g. 10am to 4pm) for the current session.

    I've tried studying the Sample custom render indicator and documentation online, but that seems to concentrate on drawing lines not relative to price.

    Does anyone have a simple example that could get me going, even if it just draws the line, but needs to be using OnRender.

    Thanks
    Tim

    #2
    Hello, thanks for writing in. I attached a very basic Line drawing tool that shows how you can draw a single line using the two vectors.

    Kind regards,

    -ChrisL
    Attached Files

    Comment


      #3
      Hi ChrisL

      Thanks for the reply. I was looking to use this as an Indicator rather than a drawing tool.

      This example is 400+ lines of code and I was hoping for something much simpler that I could build on within an indicator. e.g. draw a line at the open price at 10am and extend it to 4pm, ideally with a label "10am "that is visible on the chart as you scroll.

      Something similar to the Pivots indicator but even with that I was struggling to figure out which bits of the code I need.

      Anything closer to that you could help me with?

      Much appreciated.
      Tim

      Comment


        #4

        Hello, thanks for the follow-up. It would take a surprisingly large amount of code in OnRender even to draw a basic line. In the drawing tool, you would only focus on what the OnRender method is doing in that script. The most similar indicator, that still requires a large amount of code in OnRender is the ZigZag indicator, which would be the next best reference to complete a project like this.

        ​Kind regards,

        -ChrisL

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        78 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        40 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        63 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        63 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        54 views
        0 likes
        Last Post CarlTrading  
        Working...
        X