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 CarlTrading, 03-31-2026, 09:41 PM
            1 response
            67 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            36 views
            0 likes
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            60 views
            1 like
            Last Post CaptainJack  
            Started by CarlTrading, 03-30-2026, 11:51 AM
            0 responses
            62 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 03-30-2026, 11:48 AM
            0 responses
            53 views
            0 likes
            Last Post CarlTrading  
            Working...
            X