Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Use Draw.Text to add text of a double variable on chart

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

    Use Draw.Text to add text of a double variable on chart

    Hello,

    I have a private variable that is a double (it is a price value from my chart which is generated depending on my entry conditions) which I want to add to my chart as text when the entry conditions appear.

    I think I need to use the Draw.Text syntax however as my variable is a double type and not string the command does not execute.

    Code:
    (Draw.Text(NinjaScriptBase owner, string tag, bool isAutoScale, string text, int barsAgo, double y, int yPixelOffset, Brush textBrush, SimpleFont font, TextAlignment alignment, Brush outlineBrush, Brush areaBrush, int areaOpacity))
    How can I convert the double variable to a string variable so that I can insert it into the line of code?

    Thanks,

    Neil

    #2
    Hello Neil,

    Thanks for your post.

    You could use .ToString() on your variable to convert the variable to a string. For example, see the sample code below.

    Code:
    double [B]closePrice[/B] = Close[0];
    
    Draw.Text(this, "tag1", [B]closePrice.ToString()[/B], 0, Low[0] - 10 * TickSize, Brushes.DodgerBlue);
    See this help guide documentation for more information about using .ToString(): https://ninjatrader.com/support/help...htsub=ToString

    Let me know if I may assist further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    56 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    133 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    73 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    45 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    49 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X