Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unexpected character '$' when compiling

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

    Unexpected character '$' when compiling

    Hello,I am trying to compile custom script. It works fine on my laptop but on another pc, it gives an error : Unexpected character '$' when compiling
    The code seems like usual string interpolation.

    string text=$"line-{Time[0].ToString()}";

    Any suggestions please. Thanks
    Last edited by devkin; 03-06-2024, 03:36 PM.

    #2
    Hello devkin

    What version of NinjaTrader are you currently using? Interpolated Strings will only work in the newer releases of NinjaTrader past version 8.1.2.x where the newer C# version is being used.

    Comment


      #3
      Thank you, it was 8.1.1.x on the one that wasn't working.

      Comment


        #4
        Hello devkin,

        Yes in that case you would need to use string.Format to do that in 8.1.1.x.

        string myString = string.Format("{1}", Time[0]);

        Comment


          #5
          Hi, Can I get some help with this? I'm also compiling an indicator for a version before 8.1.2. The ONLY compile error I have is related to the $ listed here after string filename. Please helppp

          Click image for larger version

Name:	image.png
Views:	249
Size:	13.8 KB
ID:	1309675

          Comment


            #6
            Hello trader123456789,

            This was addressed earlier in the thread, you need to either update to a newer version of NinjaTrader to use newer C# features or use the feature that is appropriate for the C# version used in that version of NinjaTrader. The alternate is String.Format and there is an example of that in post 4.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            558 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            324 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            546 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            547 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X