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 sugalt, 04-30-2024, 04:02 AM
      2 responses
      13 views
      0 likes
      Last Post sugalt
      by sugalt
       
      Started by merc410, Today, 03:41 AM
      0 responses
      3 views
      0 likes
      Last Post merc410
      by merc410
       
      Started by Ndakotan1313, 03-14-2024, 05:02 PM
      2 responses
      60 views
      0 likes
      Last Post blaise_code  
      Started by claxxical, 05-30-2017, 12:30 PM
      37 responses
      4,457 views
      0 likes
      Last Post Padan
      by Padan
       
      Started by SugarDefwebsite, Today, 02:18 AM
      0 responses
      4 views
      0 likes
      Last Post SugarDefwebsite  
      Working...
      X