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:	272
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 Hwop38, 05-04-2026, 07:02 PM
            0 responses
            152 views
            0 likes
            Last Post Hwop38
            by Hwop38
             
            Started by CaptainJack, 04-24-2026, 11:07 PM
            0 responses
            304 views
            0 likes
            Last Post CaptainJack  
            Started by Mindset, 04-21-2026, 06:46 AM
            0 responses
            244 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by M4ndoo, 04-20-2026, 05:21 PM
            0 responses
            345 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by M4ndoo, 04-19-2026, 05:54 PM
            0 responses
            175 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Working...
            X