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

DrawText() in white space

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

    DrawText() in white space

    Greetings!

    I'm determined to clean up my charts and as part of that I want to have labels for horizontal lines which my strategy draws appear in white space (i.e. not obscured by bars). I have now set up my default chart with a right margin of 150 pixels (Chart Properties | Right Side Margin) so I have my white space available.

    My question is, how can I use DrawText to access that space?

    For example: my strategy has created a line which shows my entry price. I'd like it to be labelled as "Entry=100.99". Currently, I'm using the following code:

    DrawText(stub + "Text",true,"Entry=" + value,0,value,10,Color.Black,new Font("Arial",12),StringAlignment.Far,Color.Transpa rent,Color.Transparent,0);

    This puts the text 10 bars back, but inevitably it is buried in other bars or markings.

    How can I move that to the RIGHT of the current bar (and into the margin that I have created expressly for that purpose)?

    Thanks as always.

    #2
    Originally posted by cmt_Robert View Post
    Greetings!

    I'm determined to clean up my charts and as part of that I want to have labels for horizontal lines which my strategy draws appear in white space (i.e. not obscured by bars). I have now set up my default chart with a right margin of 150 pixels (Chart Properties | Right Side Margin) so I have my white space available.

    My question is, how can I use DrawText to access that space?

    For example: my strategy has created a line which shows my entry price. I'd like it to be labelled as "Entry=100.99". Currently, I'm using the following code:

    DrawText(stub + "Text",true,"Entry=" + value,0,value,10,Color.Black,new Font("Arial",12),StringAlignment.Far,Color.Transpa rent,Color.Transparent,0);

    This puts the text 10 bars back, but inevitably it is buried in other bars or markings.

    How can I move that to the RIGHT of the current bar (and into the margin that I have created expressly for that purpose)?

    Thanks as always.
    Use a negative index for the barsAgo parameter. You may also want to use StringAlignment.Near instead of StringAlignment.Far.

    Comment


      #3
      So intuitive...and yet I never thought to try it! Thank you!!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by rocketman7, Today, 02:12 AM
      5 responses
      23 views
      0 likes
      Last Post rocketman7  
      Started by trilliantrader, 04-18-2024, 08:16 AM
      7 responses
      28 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by samish18, 04-17-2024, 08:57 AM
      17 responses
      66 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by briansaul, Today, 05:31 AM
      1 response
      15 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by PaulMohn, Today, 03:49 AM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Working...
      X