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

Higher highs

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

    Higher highs

    Hi
    Would anybody show me a
    simple script identifying the 2 last higher highs (or lower lows) of a price sequence ?
    Thanks in advance

    #2
    Hello fliesen,

    Thank you for the post.

    You will access high and low values of an instrument with the High[] and Low[] array respectively. With some additional logic, you can find the last two highest (or lowest) prices of the instrument.

    There is also a few useful functions for this:
    LowestBar(), HighestBar(), and Most Recent Occurrence (MRO)

    In this example, I am using Most Recent Occurrence to find the last two highest highs:

    Code:
    protected override void OnBarUpdate()
    		{
    			int firstBarsAgo = MRO(() => High[0] > Bars.GetHigh(CurrentBar), 1, 100);
      			int secondBarsAgo = MRO(() => High[0] > Bars.GetHigh(CurrentBar), 2, 100);
    			//int firstBarsAgo = MRO(() => High[0] > Open[0], 1, 10);
      			//int secondBarsAgo = MRO(() => High[0] > Open[0], 2, 10);
      			if (firstBarsAgo > -1 && secondBarsAgo > -1 && firstBarsAgo != -1 && secondBarsAgo != -1){
    				Print(true);
    				Print(firstBarsAgo);
    			        Print(secondBarsAgo);
          			        Print("The first higher bar was " + High[firstBarsAgo]);
    			        Print("The second higher bar was " + High[secondBarsAgo]);
    				
    			}
    				
    				
    		}
    I have added links to all of the subjects mentioned here.






    I have also attached an example so you can try it out.

    Please let us know if we may be of any further assistance.
    Attached Files
    Last edited by NinjaTrader_ChrisL; 08-17-2017, 02:46 PM.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Thank you.
      The only limit is that MRO can't be used in multiseries.
      Is there eventually anything else available for multiseries ?

      Comment


        #4
        Hello fliesen,

        Thank you for the follow-up.

        I can submit a feature request to add support for multi series scripts. This function could also be easily reimplemented manually for use in multi series scripts, you would have to take care of the lookback period and occurrence rank logic.

        Here is the feature ID: SFT-2624

        If there is anything else I may assist with please let me know.
        Last edited by NinjaTrader_ChrisL; 08-17-2017, 02:18 PM.
        Chris L.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by jeronymite, 04-12-2024, 04:26 PM
        3 responses
        44 views
        0 likes
        Last Post jeronymite  
        Started by Barry Milan, Yesterday, 10:35 PM
        7 responses
        20 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by AttiM, 02-14-2024, 05:20 PM
        10 responses
        179 views
        0 likes
        Last Post jeronymite  
        Started by ghoul, Today, 06:02 PM
        0 responses
        9 views
        0 likes
        Last Post ghoul
        by ghoul
         
        Started by DanielSanMartin, Yesterday, 02:37 PM
        2 responses
        13 views
        0 likes
        Last Post DanielSanMartin  
        Working...
        X