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 bmartz, 03-12-2024, 06:12 AM
        4 responses
        32 views
        0 likes
        Last Post bmartz
        by bmartz
         
        Started by Aviram Y, Today, 05:29 AM
        4 responses
        12 views
        0 likes
        Last Post Aviram Y  
        Started by algospoke, 04-17-2024, 06:40 PM
        3 responses
        28 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by gentlebenthebear, Today, 01:30 AM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by cls71, Today, 04:45 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X