Announcement

Collapse
No announcement yet.

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.

    https://ninjatrader.com/support/help...urence_mro.htm
    https://ninjatrader.com/support/help...s/?gethigh.htm
    https://ninjatrader.com/support/help...?lowestbar.htm
    https://ninjatrader.com/support/help...highestbar.htm

    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 aaadetos, 05-04-2021, 09:28 AM
        1 response
        5 views
        0 likes
        Last Post Lancer
        by Lancer
         
        Started by Stanfillirenfro, Today, 04:34 AM
        1 response
        6 views
        0 likes
        Last Post Stanfillirenfro  
        Started by Impeesa, Today, 04:31 AM
        0 responses
        4 views
        0 likes
        Last Post Impeesa
        by Impeesa
         
        Started by knarfoe, Today, 03:41 AM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_Jason  
        Started by leschgarrett, Today, 03:58 AM
        0 responses
        1 view
        0 likes
        Last Post leschgarrett  
        Working...
        X