Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Compile error } expected

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

    Compile error } expected

    I am getting a compile error but cant see the mistake, it is indicating error " } expected" on the second line of the code below where the "{" is, ive looked at the code and just cant see it. can you see anything im missing?

    if(pivotSeries[0] > pivotSeries[1]) // Test pivots to see if day is bullish
    {
    if(Closes[2][0] > pp && Closes[2][0] < r1)
    {
    private int x = 0;

    for(int i=0;i < strength;i++)
    {
    if(Lows[2][i] > pp)
    {
    x++;
    }
    else
    break;
    }


    if(x == strength && badTradeCount <= lossingTradeAllowance)
    {
    longEntryPP = EnterLongLimit(0,true, 1,pp + entryAllowance * TickSize , "Long Entry PP");
    }
    }

    #2
    GKonheiser, looks like to me your never close down the first { one?

    Comment


      #3
      no I checked, as far as I can see they are all closed out.

      Comment


        #4
        What does "statement expected " mean Im getting ti every time i use this in my code :-

        if(Closes[2][0] > pp && Closes[2][0] < r1)
        {
        private int x = 0;

        for(int i=0;i < strength;i++)
        {
        if(Lows[2][i] > pp)
        {
        x++;
        }
        else
        break;
        }


        if(x == strength && badTradeCount <= lossingTradeAllowance)
        {
        longEntryPP = EnterLongLimit(0,true, 1,pp + entryAllowance * TickSize , "Long Entry PP");
        }
        }

        Comment


          #5
          If you count opening brackets, they are 5. Closing brackets are only 4 in the code you have pasted.

          Comment


            #6
            GKonheiser, you would need to go through each { ] one by one, as they all need to be eventually closed out the editor would highlight them as well for you. Just looking at the code the first one is never closed down properly.

            Comment


              #7
              Hi Bertrand,

              IIm commented everything out and slowly un-commenting to isolate the issue. When I get to "private int x = 0; "
              the compiler starts throwing up errors. Is there any thing wrong with this statement in the code section below,

              if(Closes[2][0] > pp && Closes[2][0] < r1)
              {
              private int x = 0;
              //
              // for(int i=0;i < strength;i++)
              // {
              // if(Lows[2][i] > pp)
              // {
              // x++;
              // }
              // else
              // break;
              // }
              //
              // if(x == strength && badTradeCount <= lossingTradeAllowance)
              // {
              // longEntryPP = EnterLongLimit(0,true, 1,pp + entryAllowance * TickSize , "Long Entry PP");
              // }
              }

              Comment


                #8
                Yes GKonheiser, you don't want to declare this int in the if block

                private int x = 0;

                Just declare globally in your variables for example and just set x to 0 should work better.

                Comment


                  #9
                  Ah, that was the problem then. Why is it not possible to declare a variable in an if block?

                  Thanks again for the help. The forum is invaluable.

                  Comment


                    #10
                    Believe that's from the C# language specs, it would expect a so called embedded statement then after the if (boolean) and would not accept a declaration statement (which your prior one was).

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    566 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    330 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    101 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    547 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    548 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X