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

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 Waxavi, Today, 02:10 AM
                    0 responses
                    2 views
                    0 likes
                    Last Post Waxavi
                    by Waxavi
                     
                    Started by TradeForge, Today, 02:09 AM
                    0 responses
                    6 views
                    0 likes
                    Last Post TradeForge  
                    Started by Waxavi, Today, 02:00 AM
                    0 responses
                    2 views
                    0 likes
                    Last Post Waxavi
                    by Waxavi
                     
                    Started by elirion, Today, 01:36 AM
                    0 responses
                    4 views
                    0 likes
                    Last Post elirion
                    by elirion
                     
                    Started by gentlebenthebear, Today, 01:30 AM
                    0 responses
                    4 views
                    0 likes
                    Last Post gentlebenthebear  
                    Working...
                    X