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


        #4

        Very interesting that code. I am trying to do something similar but only looking for the maximum value of the momentum (14) in the last N candles and create a plot to detect when that maximum is broken. Could you help me? Thank you

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        50 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        126 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        69 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        42 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        46 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X