Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw.Horizontal line does not work on alternative scales?

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

    Draw.Horizontal line does not work on alternative scales?

    Hi,

    I was surprised to find that draw.horizontal line appears to be fixed to the right scale, i.e. even if you manually set the scale to left in your code, the line will not plot (or it will, but it's not visible due to being on the wrong scale).

    Without resorting to graphics methods or fudging a plot, I can't see a way to simply draw a horizontal line on the left scale. Is this possible?

    Thanks.

    #2
    Hello,

    Thanks for your post.

    Please clarify for me what exactly you would like to set to scale on the left. Horizontal lines are not attached to a scale and are set at a Y-Coordinate value.

    I look forward to your reply.
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      Hi,

      Thanks. Here is an example

      Draw.HorizontalLine(this,"CurrentLevel", false, aNumberlike5,Brushes.Yellow, DashStyleHelper.Dash ,1);

      The indicator that uses this uses the left scale and plots numbers from 1 to 30. I wanted to simply draw a horizontal line at the current value, so it draws across all the plot bars and you can compare the current value easily with past bar values. Problem is, bars plot on the left scale (price is on the right) and draw.horizontalline only seems to plot on the right scale.

      Can you point me in the direction of easily drawing a horizontal line on the left scale, if possible?

      Thanks again.,

      Comment


        #4
        Are these horizontal lines being drawn by a script, or by hand?
        If they are drawn by a script, what is the alignment of the script?
        Josh G.NinjaTrader Customer Service

        Comment


          #5
          Hi,

          By script. It's an indicator, but plots it's bars in the main price window, hence the reason to use the left scale. The script is aligned to the left with "ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Left;". Set to left scale in indicator properties too.

          Comment


            #6
            To do this, you will want to change your isAutoScale bool to true and use the overload that uses DrawOnPricePanel, with it set to false. This is because you want the line to scale to the indicator panel and not the price panel. The below snippet should do what you want.
            Code:
            Draw.HorizontalLine(this,"CurrentLevel", true, Close[0] ,Brushes.Yellow, false);
            Please let me know if you have any further questions.
            Josh G.NinjaTrader Customer Service

            Comment


              #7
              Percet. Thank you. In the end, I used this overload, without IsAutoScale as I wanted a dashed line and it still works.

              Draw.HorizontalLine(this,"pjsRBP", BarsDown,Brushes.WhiteSmoke, DashStyleHelper.Dash ,1,false);


              Bit counter intuitive perhaps, because I am drawing on the price panel! I think I misunderstood that option.

              All working now though. Thanks for your help.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              637 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              366 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              107 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              569 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              571 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X