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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    45 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    21 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    31 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    50 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    42 views
    0 likes
    Last Post CarlTrading  
    Working...
    X