Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Visible Chartbars MAX(High)

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

    Visible Chartbars MAX(High)

    Hi,

    Maybe this is a stupid question, but unfortunately I am struggling a bit, trying to do the following.

    I am running through the visible chartbars.

    for (int index = ChartBars.FromIndex; index <= ChartBars.ToIndex; index ++)

    now what i want to check is, if Bars.GetHigh(index) is higher than the maximal high of x bars before index. or stated ottherwise if the "index" high is a new x bar high, how is this be done, i tried converting the barsago value by subtracting the indexvalue from CurrentBar, but cant get it working.

    regards

    #2
    Hello keepsimple,

    I am not quite certain that I am understanding your inquiry.

    Lets say the current index is bar 100 and x is 5 bars.

    Are you wanting to find the highest high from bar 95 to 100?

    For example:
    Code:
    if (CurrentBar > 100)
    {
    	int barIndex = 100;
    	int highestBarIndex = barIndex;
    	int x = 5;
    				
    	for (int i = barIndex; i >= (barIndex - x); i--)
    	{
    		if (Bars.GetHigh(i) > Bars.GetHigh(highestBarIndex))
    		{
    			highestBarIndex = i;
    		}
    	}
    				
    	Print(string.Format("HighestHigh time: {0} | HighestHigh index: {1} | HighestHigh: {2}", Bars.GetTime(highestBarIndex), highestBarIndex, Bars.GetHigh(highestBarIndex) ));
    }
    Last edited by NinjaTrader_ChelseaB; 09-15-2016, 08:04 AM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks Chelsea.

      that did it, should have figured out this for myself.

      Thanks for helping, solution is great as always.

      Regards

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      672 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      379 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      111 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      575 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      582 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X