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 zstheorist, Today, 07:52 PM
      0 responses
      3 views
      0 likes
      Last Post zstheorist  
      Started by pmachiraju, 11-01-2023, 04:46 AM
      8 responses
      149 views
      0 likes
      Last Post rehmans
      by rehmans
       
      Started by mattbsea, Today, 05:44 PM
      0 responses
      5 views
      0 likes
      Last Post mattbsea  
      Started by RideMe, 04-07-2024, 04:54 PM
      6 responses
      33 views
      0 likes
      Last Post RideMe
      by RideMe
       
      Started by tkaboris, Today, 05:13 PM
      0 responses
      5 views
      0 likes
      Last Post tkaboris  
      Working...
      X