Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error: Class member declaration expected (Line 122 Column 26) Plz help me fix it

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

    Error: Class member declaration expected (Line 122 Column 26) Plz help me fix it

    using System;
    using System.Windows.Media;

    namespace NinjaTrader.NinjaScript.Indicators
    {
    public class OrderBlockIndicator : Indicator
    {
    private double _marketVolume;
    private double _limitVolume;
    private double _totalVolume;

    private int _startBar;
    private int _endBar;

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Identify potential order blocks";
    Name = "OrderBlockIndicator";
    Calculate = Calculate.OnBarClose;
    IsOverlay = true;
    DisplayInDataBox = false;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = true;
    PaintPriceMarkers = false;
    ScaleJustification = ScaleJustification.Right;
    IsSuspendedWhileInactive = true;

    BlockVolumeRatio = 2.0;
    ContourLineColor = Brushes.Yellow;
    ContourLineWidth = 2;
    }
    else if (State == State.Configure)
    {
    AddDataSeries(Data.BarsPeriodType.Minute, 1);
    }
    }

    protected override void OnBarUpdate()
    {
    if (BarsInProgress == 1)
    {
    // Calculate market and limit volumes
    double volume = Instrument.MasterInstrument.InstrumentType == Cbi.InstrumentType.CryptoCurrency ? Core.Globals.ToCryptocurrencyVolume((long)Volume[1][0]) : Volume[1][0];
    if (Close[1][0] > Open[1][0])
    {
    _marketVolume += volume;
    }
    else
    {
    _limitVolume += volume;
    }
    _totalVolume += volume;

    // Check for potential order block
    double blockVolume = BlockVolumeRatio * _marketVolume;
    if (_limitVolume >= blockVolume)
    {
    _startBar = Math.Max(0, CurrentBar - Bars.Period.Value);
    }
    if (_marketVolume >= blockVolume && _startBar > 0)
    {
    _endBar = CurrentBar;

    // Mark order block with contour line
    double low = Low[1][_startBar];
    double high = High[1][_endBar];
    Draw.Rectangle(this, "OrderBlock" + _startBar, true, _startBar, low, _endBar, high, null, ContourLineColor, ContourLineWidth);
    }
    }
    else if (BarsInProgress == 0)
    {
    // Reset volumes at the start of a new session
    if (Bars.IsFirstBarOfSession)
    {
    _marketVolume = 0;
    _limitVolume = 0;
    _totalVolume = 0;
    _startBar = -1;
    _endBar = -1;
    }
    }
    }

    region Properties

    [NinjaScriptProperty]
    [Range(0.1, double.MaxValue)]
    [Display(Name = "BlockVolumeRatio", Description = "Ratio of market order volume to limit order volume for a potential order block", Order = 1, GroupName = "Parameters")]
    public double BlockVolumeRatio { get; set; }

    [NinjaScriptProperty]
    [XmlIgnore]
    [Display(Name = "ContourLineColor", Description = "Color of contour line marking potential order blocks", Order = 2, GroupName = "Parameters")]
    public Brush ContourLineColor { get; set; }

    [Browsable(false)]

    #2
    Originally posted by minhthinh1608 View Post
    using System;
    using System.Windows.Media;

    namespace NinjaTrader.NinjaScript.Indicators
    {
    public class OrderBlockIndicator : Indicator
    {
    private double _marketVolume;
    private double _limitVolume;
    private double _totalVolume;

    private int _startBar;
    private int _endBar;

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Identify potential order blocks";
    Name = "OrderBlockIndicator";
    Calculate = Calculate.OnBarClose;
    IsOverlay = true;
    DisplayInDataBox = false;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = true;
    PaintPriceMarkers = false;
    ScaleJustification = ScaleJustification.Right;
    IsSuspendedWhileInactive = true;

    BlockVolumeRatio = 2.0;
    ContourLineColor = Brushes.Yellow;
    ContourLineWidth = 2;
    }
    else if (State == State.Configure)
    {
    AddDataSeries(Data.BarsPeriodType.Minute, 1);
    }
    }

    protected override void OnBarUpdate()
    {
    if (BarsInProgress == 1)
    {
    // Calculate market and limit volumes
    double volume = Instrument.MasterInstrument.InstrumentType == Cbi.InstrumentType.CryptoCurrency ? Core.Globals.ToCryptocurrencyVolume((long)Volume[1][0]) : Volume[1][0];
    if (Close[1][0] > Open[1][0])
    {
    _marketVolume += volume;
    }
    else
    {
    _limitVolume += volume;
    }
    _totalVolume += volume;

    // Check for potential order block
    double blockVolume = BlockVolumeRatio * _marketVolume;
    if (_limitVolume >= blockVolume)
    {
    _startBar = Math.Max(0, CurrentBar - Bars.Period.Value);
    }
    if (_marketVolume >= blockVolume && _startBar > 0)
    {
    _endBar = CurrentBar;

    // Mark order block with contour line
    double low = Low[1][_startBar];
    double high = High[1][_endBar];
    Draw.Rectangle(this, "OrderBlock" + _startBar, true, _startBar, low, _endBar, high, null, ContourLineColor, ContourLineWidth);
    }
    }
    else if (BarsInProgress == 0)
    {
    // Reset volumes at the start of a new session
    if (Bars.IsFirstBarOfSession)
    {
    _marketVolume = 0;
    _limitVolume = 0;
    _totalVolume = 0;
    _startBar = -1;
    _endBar = -1;
    }
    }
    }

    region Properties

    [NinjaScriptProperty]
    [Range(0.1, double.MaxValue)]
    [Display(Name = "BlockVolumeRatio", Description = "Ratio of market order volume to limit order volume for a potential order block", Order = 1, GroupName = "Parameters")]
    public double BlockVolumeRatio { get; set; }

    [NinjaScriptProperty]
    [XmlIgnore]
    [Display(Name = "ContourLineColor", Description = "Color of contour line marking potential order blocks", Order = 2, GroupName = "Parameters")]
    public Brush ContourLineColor { get; set; }

    [Browsable(false)]
    This is pic

    Comment


      #3
      Hello minhthinh1608,

      Thanks for your post.

      This error generally refers to a NinjaScript property that you have created.

      What exactly is the line of code that the error is referring to in the code you shared (Line 122 Column 26)?

      ​Is Line 122 part of a NinjaScript property you created? If so, how is that property being made in the script?

      Thanks in advance; I look forward to assisting further.
      <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

      Comment


        #4
        Originally posted by minhthinh1608 View Post
        This is pic
        Error are: Class member declaration expected; '}' expected Code CS1513. NinjaScript property i'm created. You can see in my post

        Comment


          #5
          Hello minhthinh1608,

          Thanks for your note.

          When testing the properties you shared in post # 1 and # 2, I am able to compile the script without errors. See the attached screenshot.

          This error, CS1513, indicates that the compiler expected a closing curly brace '}' that was not found.

          To resolve this, you will need to go through each line of code in your script to ensure that each one of the opening curly braces '{' has a closing curly brace '}' accompanying it. Note that each opening curly brace must have a closing curly brace.

          For more information about this error, you could do a quick Google search for 'C# CS1513 Compile Error' and view the MSDN documentation that appears in the search results.

          Please let me know if I may assist further.​
          Attached Files
          <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

          Comment


            #6
            I have checked all of them but can't find any missing

            Comment


              #7
              Hello minhthinh1608,

              Thanks for your note.

              If you run a compile and still get the error message stating "}" expected, this means there is a missing closing curly brace somewhere in the script.

              Based on the code you shared, it seems like you might be missing a closing curly brace to go with the 'namespace NinjaTrader.NinjaScript.Indicators' opening curly brace. You might be missing a closing curly brace to go with the public class OrderBlockIndicator : Indicator opening curly brace.

              Ultimately, it would be up to you to locate the missing closing curly brace(s) in your indicator's code to resolve the compile error.

              Also, please note the Properties region should be added directly after the OnBarUpdate() section of code. You could open a New > Strategy Builder window, create a couple user-defined inputs on the Inputs and Variables screen, and click the 'View code' button to see the generated syntax for how properties should be placed in a script.

              The screenshot in post # 5 also demonstrates how properties should be added in a script.

              Let me know if you have further questions.
              Last edited by NinjaTrader_BrandonH; 02-21-2023, 11:38 AM.
              <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

              Comment


                #8
                Hello CampervanSeth,

                Thanks for your notes.

                This error indicates that you have a missing closing curly brace somewhere in your script.

                You would need to ensure you go through each curly brace in your code to make sure that every open curly brace has a closing curly brace to go with it.

                It seems like you may be missing a closing curly brace for the namespace open curly brace but I suggest going through each curly brace in your code to identify exactly which open curly brace is missing a closing curly brace.
                <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                Comment


                  #9
                  Hello CamperSeth,

                  Thanks for your notes.

                  As noted in post # 9, it seems like you may need to add a closing curly brace for the namespace open curly brace to resolve the error.

                  namespace NinjaTrader.NinjaScript.Indicators
                  {
                  public class DirectionalImbalances : Indicator
                  {
                  protected override void OnStateChange()
                  {
                  if (State == State.SetDefaults)
                  {
                  Description = @"Highlights an Up or Down gap between candlesticks in a trend.";
                  Name = "DirectionalImbalances";
                  Calculate = Calculate.OnPriceChange;
                  IsOverlay = true;
                  DisplayInDataBox = false;
                  DrawOnPricePanel = true;
                  DrawHorizontalGridLines = false;
                  DrawVerticalGridLines = false;
                  PaintPriceMarkers = true;
                  ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
                  //Disable this property if your indicator requires custom values that cumulate with each new market data event.
                  //See Help Guide for additional information.
                  IsSuspendedWhileInactive = true;
                  }
                  else if (State == State.Configure)
                  {
                  }
                  }

                  protected override void OnBarUpdate()
                  {
                  if (BarsInProgress != 0)
                  return;

                  if (CurrentBars[0] < 1)
                  return;

                  // Set 1
                  if ((Open[0] > Close[1])
                  && (Close[1] > Open[1])
                  && (Close[0] > Open[0]))
                  {
                  CandleOutlineBrush = Brushes.MediumSpringGreen;
                  Draw.ArrowUp(this, @"Gap_Up " + Convert.ToString(CurrentBars[0]), false, 0, (Low[0] + (-2 * TickSize)) , Brushes.MediumSpringGreen);
                  BarBrush = Brushes.MediumSpringGreen;
                  }

                  // Set 2
                  if ((Open[0] < Close[1])
                  && (Close[1] < Open[1])
                  && (Close[0] < Open[0]))
                  {
                  CandleOutlineBrush = Brushes.DeepPink;
                  Draw.ArrowDown(this, @"Gap_Down " + Convert.ToString(CurrentBars[0]), false, 0, (High[0] + (2 * TickSize)) , Brushes.DeepPink);
                  BarBrush = Brushes.DeepPink;
                  }
                  }
                  }
                  } //add this closing curly brace


                  That said, it would ultimately be up to you to debug your script and determine exactly where in the script the closing curly brace needs to be placed.

                  Note in the Support Department at NinjaTrader we do not provide debugging services in our support.
                  <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  651 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  370 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  109 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  574 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  577 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X