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 Hwop38, 05-04-2026, 07:02 PM
      0 responses
      164 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      318 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      246 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      350 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      179 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Working...
      X