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:	259
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 sjsj2732, Yesterday, 04:31 AM
            0 responses
            27 views
            0 likes
            Last Post sjsj2732  
            Started by NullPointStrategies, 03-13-2026, 05:17 AM
            0 responses
            283 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            280 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            131 views
            1 like
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            90 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Working...
            X