• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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?
    BertrandNinjaTrader Customer Service

    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.
            BertrandNinjaTrader Customer Service

            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.
                BertrandNinjaTrader Customer Service

                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).
                    BertrandNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by sardana, Today, 05:52 AM
                    0 responses
                    2 views
                    0 likes
                    Last Post sardana
                    by sardana
                     
                    Started by Mykro, Yesterday, 04:58 PM
                    1 response
                    11 views
                    0 likes
                    Last Post NinjaTrader_PaulH  
                    Started by akuntysh, Today, 02:43 AM
                    0 responses
                    5 views
                    0 likes
                    Last Post akuntysh  
                    Started by thgamey, Today, 02:05 AM
                    0 responses
                    9 views
                    0 likes
                    Last Post thgamey
                    by thgamey
                     
                    Started by tpdk2012, Today, 12:51 AM
                    1 response
                    13 views
                    0 likes
                    Last Post NinjaTrader_ChrisSch  
                    Working...
                    X