Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem using IText with non-integer valued instrument

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

    Problem using IText with non-integer valued instrument

    Hi everyone

    Mainly to find the best bar to 'anchor' a regression channel - it's an adaptation of mine of an existing one - I've worked up a simple indicator (code below) which numbers the bars on a chart. The first bar of each session = 0, etc. This could be useful for a number of purposes.

    Code:
    private int level =1600;
    
    ...
    
    IText text = DrawText("My text" + CurrentBar,Bars.BarsSinceSession.ToString(), 0, [B]Level[/B], Color.Black);
    The variable Level gives the height on the chart the text will appear. So there's no problem for an integer-valued instrument, such as the ES or any stock.

    The problem arises with Forex charts, such as EUR/USD which is obviously a decimal (currently about 1.3060), as the appropriate parameter in IText can only be an integer. (From Help: "Y = An int value representing the y value of the draw object.)

    Is there some kind of workaround for this? If I want the text to appear at level = 1.3060, say, is there any way of doing this?

    Any ideas will be greatly appreciated.

    #2
    Hello arbuthnot,

    Thank you for your note.

    IText is used to call the objects of the DrawText() method, so you could say Print(text.Y); and that would print the Y value of the DrawText() object "text".

    However, when using DrawText() the Y value can in fact be a double: Syntax - DrawText(string tag, string text, int barsAgo, double y, Color color)

    For information on DrawText() please visit the following link: http://www.ninjatrader.com/support/h...7/drawtext.htm
    For information on IText objects please visit the following link: http://www.ninjatrader.com/support/h.../nt7/itext.htm

    Please let me know if you have any questions.

    Comment


      #3
      Thanks very much, Patrick. That works a treat!

      The answer was, as you said, to use DrawText.

      Much obliged.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      574 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      332 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      553 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      551 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X