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 FrancisMorro, Today, 03:24 AM
      0 responses
      1 view
      0 likes
      Last Post FrancisMorro  
      Started by Segwin, 05-07-2018, 02:15 PM
      10 responses
      1,769 views
      0 likes
      Last Post Leafcutter  
      Started by Rapine Heihei, 04-23-2024, 07:51 PM
      2 responses
      30 views
      0 likes
      Last Post Max238
      by Max238
       
      Started by Shansen, 08-30-2019, 10:18 PM
      24 responses
      943 views
      0 likes
      Last Post spwizard  
      Started by Max238, Today, 01:28 AM
      0 responses
      10 views
      0 likes
      Last Post Max238
      by Max238
       
      Working...
      X