• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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 Captain_Qwark, Today, 10:55 AM
      3 responses
      19 views
      0 likes
      Last Post NinjaTrader_PaulH  
      Started by kmpc1, Today, 11:03 AM
      1 response
      13 views
      0 likes
      Last Post NinjaTrader_PatrickG  
      Started by jransom, Today, 09:08 AM
      1 response
      19 views
      0 likes
      Last Post NinjaTrader_Kate  
      Started by mtamaku, Today, 09:19 AM
      0 responses
      23 views
      0 likes
      Last Post mtamaku
      by mtamaku
       
      Started by traderMNQ, Today, 09:00 AM
      4 responses
      20 views
      0 likes
      Last Post traderMNQ  
      Working...
      X