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 andrewtrades, Today, 04:57 PM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by chbruno, Today, 04:10 PM
      0 responses
      3 views
      0 likes
      Last Post chbruno
      by chbruno
       
      Started by josh18955, 03-25-2023, 11:16 AM
      6 responses
      436 views
      0 likes
      Last Post Delerium  
      Started by FAQtrader, Today, 03:35 PM
      0 responses
      7 views
      0 likes
      Last Post FAQtrader  
      Started by rocketman7, Today, 09:41 AM
      5 responses
      19 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X