Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

High of Last 10 bars at least 30 Ticks Above Indicator

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

    High of Last 10 bars at least 30 Ticks Above Indicator

    Nope, that's what I'm looking for. Thank you!
    Last edited by GLockwood; 10-14-2013, 10:22 AM.

    #2
    Hi GLockwood,

    Thank you for your post and welcome to the forums!

    You will need to create a for loop that will test when the High price is equal to the MAX(High, 10)[1].
    Example -
    Code:
    if(CurrentBar < 10)
    	return;
    			
    int highValue = 0;
    for( int i = 0; i < 10; i++)
         {
    		if(High[i] != MAX(High, 10)[1])
    		{
    			highValue++;
    		}
    		if(High[i] == MAX(High, 10)[1])
    		{
    			Print(" ");
    			Print(highValue + ToTime(Time[0]));
    			break;
    		}
    	}
    Additionally, I would take a look at the link below on other ways to reference the correct bar

    Referencing the Correct Bar


    Let me know if I can be of further assistance.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Nope, I think that will work. Thank you!

      Comment


        #4
        Lol, having issues with the forum buttons and I keep getting logged out.

        Anyway, I have one more question. How do I reference methods like Close[0] and High[0] from outside the OnBarUpdate method. I'm trying to reference them from another method in the same class and getting the CS0120 error.

        "An object reference is required for the non-static field, method, or property 'NinjaTrader.Strategy.StrategyBase.High.get'"

        Comment


          #5
          Lol, having problems with the forum.

          Anyway, I have one more question. I'm trying to reference High[1] and Close[0] from outside of the OnBarUpdate method in my own

          public static bool EntryLongCheck()

          method within the strategy class and getting the CS0120 error:

          "An object reference is required for the non-static field, method, or reference 'NinjaTrader.Strategy.StrategyBase.High.get'"

          Thanks again!

          Comment


            #6
            GLockwood,

            You will need to pass the method through the OnBarUpdate() to get the correct reference for the code.

            Just as a side note you would want to just use public bool and not include the static.

            Let me know if I can be of further assistance.
            Cal H.NinjaTrader Customer Service

            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