• 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

Highest Value of Indicator Reading

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

    Highest Value of Indicator Reading

    Hi,
    as much as HighestBar command returns the number of bars ago the highest price value occurred within the specified look-back period - I am trying to code the same for an indicator.
    Example, Get the highest value of Momentum within the last 30 Bars... any advice?
    I am aware of the MAX function but I would like to know HOW MANY BARS ago that high was reached...

    #2
    Hello JBU1314,

    Thank you for your note.

    I have attached an indicator which will print to the output window the bars ago that the Momentum indicator was at its maximum as well as print the time of that bar.

    The code looks like,

    Code:
    	protected override void OnBarUpdate()
    		{
    			
    			if(State == State.Historical) return;
    			
    			int barsAgohigh =((HighestBar(Momentum(14), 30)));
    			
    			Print(barsAgohigh.ToString() +" "+ Time[barsAgohigh]);
    		}
    Please let us know if you need further assistance.
    Attached Files
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Thank you so much Alan. Appreciate the fast response!!!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by ballboy11, Today, 01:04 PM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_PaulH  
      Started by Linda1507, Today, 01:22 PM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_Kate  
      Started by ntbone, Today, 12:15 PM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by ballboy11, Today, 12:32 PM
      2 responses
      6 views
      0 likes
      Last Post ballboy11  
      Started by brownsfan019, Today, 12:04 PM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_PatrickG  
      Working...
      X