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.






    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.

    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.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        56 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        133 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        73 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        45 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        49 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X