Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Drawtextfixed

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

    Drawtextfixed

    Hi there.

    I am am trying to convert my NT7 drawtextfixed code to NT8. Simple example:

    Draw.TextFixed(this, "tag 2",(Open[0]-Close[0].ToString("N0")), TextPosition.TopRight, BarBrush = Brushes.Blue, _newsHeadingFont, BarBrush = Brushes.Red, BarBrush = Brushes.DarkGreen, 100);



    I am getting the following error - The error says this relates to < or > <- etc so no sure of the problem. It looks like it doesn't like the Open[0] - Close [0] part. Thanks in advance!
    TimerIndicator.cs Operator '-' cannot be applied to operands of type 'double' and 'string' CS0019 140 33

    #2
    Hello djkiwi,

    Thanks for your post.

    The compiler error is telling you that you are improperly trying to use the subtraction operator between a double and a string. A string is a text variable and would not be subtracted from a double which has decimal values.

    Please check where you are trying to perform subtraction between a string and a double to see where the error is at.

    Hint: (Open[0]-Close[0].ToString("N0"))

    Did you meant to do this instead? (Open[0]-Close[0]).ToString("N0")

    Some basic programming concepts can be found below and more robust C# programming materials can be found externally to NinjaTrader.

    Basic Programming Concepts - https://ninjatrader.com/support/help...g_concepts.htm

    We look forward to assisting.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    81 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    42 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    64 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    66 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    54 views
    0 likes
    Last Post CarlTrading  
    Working...
    X