Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

the name b does not exist in the current context?

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

    the name b does not exist in the current context?

    protected override void OnBarUpdate()
    {
    // Condition set 1
    if ((EMA(14)[1] > EMA(14)[0]) && (Open[0] >= Close[1]) && IsReverseBarUp(b, 3.0) == true);
    {
    }
    }

    Hello, I have this method which wont compile because it says b does not exist in the current context?

    even though i have specified what it is in another part of the code?

    public static bool IsReverseBarUp(Bar b, double bodyFullRatio)

    see?

    Can anybody help me here?

    Best Regards,

    James

    #2
    Will this do better?

    public static bool IsReverseBarUp(Bars b, double bodyFullRatio)

    Comment


      #3
      reply

      The issue is not this line, the issue is it does not recognise b (highlighted in red in the code) as anything.

      thanks for your reply, add me on chat [email protected] to talk

      Comment


        #4
        james377, that is because you haven't declared b as a bar, which would be necessary in order for the script to compile. What you have so far is a method that takes b in as input, but like I said b is never declared anywhere. Once you have it declared, you'd have to set it as well.
        AustinNinjaTrader Customer Service

        Comment


          #5
          hi

          i understand what you mean but i dont know how to do this?

          Comment


            #6
            Hi james377,

            Thanks for posting, someone will reply shortly, later today.
            TimNinjaTrader Customer Service

            Comment


              #7
              james377,

              Let us take a step back. "Bars" is a reserved word and you can't "create" bars on your own. What exactly are you trying to pass in? Usually the correct type would be a DataSeries object instead of declaring things as Bars.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Perhaps Bar[b] is what you are trying for try BarsAgo[b], [0] being the current bar.

                Comment

                Latest Posts

                Collapse

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