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

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 Waxavi, Today, 02:10 AM
              0 responses
              6 views
              0 likes
              Last Post Waxavi
              by Waxavi
               
              Started by TradeForge, Today, 02:09 AM
              0 responses
              11 views
              0 likes
              Last Post TradeForge  
              Started by Waxavi, Today, 02:00 AM
              0 responses
              2 views
              0 likes
              Last Post Waxavi
              by Waxavi
               
              Started by elirion, Today, 01:36 AM
              0 responses
              4 views
              0 likes
              Last Post elirion
              by elirion
               
              Started by gentlebenthebear, Today, 01:30 AM
              0 responses
              5 views
              0 likes
              Last Post gentlebenthebear  
              Working...
              X