Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

indicator error class member declaratione

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

    indicator error class member declaratione

    Hello,
    Am hvae error in xyz.cs file like this { get; set; } = Brushes.LightGreen;
    and the erro is1.invalid token '=' in class,struct,or interface member declaration.
    2. invalid token ';' in class, struct or interface member declaratione.
    and the code CS1519 error code
    Please can you send the solutione .

    #2
    Hello,

    Thank you for the post.

    In this case, the .net version used in NinjaTrader would not support this syntax as it is from a newer .net version, you would need to just create a property and assign it from the appropriate state. This is a .net 6 feature where NinijaTrader 8 uses .net 4.5.X

    Code:
    public Brush MyBrush {get;set;}
    From State.SetDefaults you could set the brush:

    Code:
    MyBrush = Brushes.LightGreen;
    When reviewing syntax online at MSDN or using completion tools in other applications like a Visual studio you may run into this. Resharper specifically will recommend this which will create invalid syntax for the version being used.


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      expresiion error in .cs file

      Hi ,
      I have change the code ,still am getting this error expressione expected
      Code:
      protected void DisposeUnmanagedGraphics()
              {
                  BuyLadderBrushDx?.Dispose(); BuyLadderBrushDx = null;
                  SellLadderBrushDx?.Dispose(); SellLadderBrushDx = null;
                  PositiveDeltaBrushDx?.Dispose(); PositiveDeltaBrushDx = null;
                  NegativeDeltaBrushDx?.Dispose(); NegativeDeltaBrushDx = null;
                  ChartBackgroundBrushDx?.Dispose(); ChartBackgroundBrushDx = null;
              }
      in this part all the line with in a method expression expected error is there.

      Please rever back am not able to fix this issue from last 3 days.

      Comment


        #4
        Hello,

        This would be invalid for the version of .net being used again. The ? (safe navigation operator) would not be valid in NinjaScript. The NinjaScript editor should be highlighting the space between the word and a question mark as red indicating a problem. This is a C# 6 feature also which would not be able to be used in NinjaScript. You would instead just need to check for null using equality:

        if(BuyLadderBrushDx != null) BuyLadderBrushDx.Dispose();

        If you are using automation tools like Visual studio or other external editors, please be careful as to what syntax you use or allow to be generated as this is not for the correct .net version we are using. External tools that target a higher version of .net will recommend items like checking for null on an object with the safe navigation operator, this would not work with NinjaScript. If in doubt, undo the last changes you had made until you get back to a compiled state, and then try doing a small portion of the change again to find what specifically is wrong.



        Please let me know if I may be of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by frslvr, 04-11-2024, 07:26 AM
        9 responses
        121 views
        1 like
        Last Post caryc123  
        Started by rocketman7, Today, 09:41 AM
        4 responses
        15 views
        0 likes
        Last Post rocketman7  
        Started by selu72, Today, 02:01 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_Zachary  
        Started by WHICKED, Today, 02:02 PM
        2 responses
        15 views
        0 likes
        Last Post WHICKED
        by WHICKED
         
        Started by f.saeidi, Today, 12:14 PM
        8 responses
        21 views
        0 likes
        Last Post f.saeidi  
        Working...
        X