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 helpwanted, Today, 03:06 AM
        1 response
        10 views
        0 likes
        Last Post sarafuenonly123  
        Started by Brevo, Today, 01:45 AM
        0 responses
        9 views
        0 likes
        Last Post Brevo
        by Brevo
         
        Started by aussugardefender, Today, 01:07 AM
        0 responses
        5 views
        0 likes
        Last Post aussugardefender  
        Started by pvincent, 06-23-2022, 12:53 PM
        14 responses
        242 views
        0 likes
        Last Post Nyman
        by Nyman
         
        Started by TraderG23, 12-08-2023, 07:56 AM
        9 responses
        387 views
        1 like
        Last Post Gavini
        by Gavini
         
        Working...
        X