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

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 Skifree, Today, 03:41 AM
      1 response
      2 views
      0 likes
      Last Post Skifree
      by Skifree
       
      Started by usazencort, Today, 01:16 AM
      0 responses
      1 view
      0 likes
      Last Post usazencort  
      Started by kaywai, 09-01-2023, 08:44 PM
      5 responses
      603 views
      0 likes
      Last Post NinjaTrader_Jason  
      Started by xiinteractive, 04-09-2024, 08:08 AM
      6 responses
      23 views
      0 likes
      Last Post xiinteractive  
      Started by Pattontje, Yesterday, 02:10 PM
      2 responses
      23 views
      0 likes
      Last Post Pattontje  
      Working...
      X