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 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