Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 JonesJoker, 04-22-2024, 12:23 PM
        9 responses
        46 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by timko, Today, 06:45 AM
        1 response
        7 views
        0 likes
        Last Post gaz0001
        by gaz0001
         
        Started by Waxavi, 04-19-2024, 02:10 AM
        3 responses
        41 views
        0 likes
        Last Post gaz0001
        by gaz0001
         
        Started by Max238, Today, 01:28 AM
        2 responses
        26 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Started by Shansen, 08-30-2019, 10:18 PM
        25 responses
        949 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Working...
        X