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 puapwr, Today, 06:09 PM
        0 responses
        2 views
        0 likes
        Last Post puapwr
        by puapwr
         
        Started by franciscog21, Today, 05:27 PM
        0 responses
        5 views
        0 likes
        Last Post franciscog21  
        Started by hdge4u, 04-29-2024, 12:23 PM
        5 responses
        28 views
        0 likes
        Last Post MisterTee  
        Started by llanqui, 01-25-2024, 06:15 PM
        9 responses
        64 views
        0 likes
        Last Post MisterTee  
        Started by tradingnasdaqprueba, 05-07-2024, 03:42 AM
        16 responses
        67 views
        0 likes
        Last Post tradingnasdaqprueba  
        Working...
        X