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

LowestBar / HighestBar not giving Low and high ??

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

    LowestBar / HighestBar not giving Low and high ??

    Hello, I'm fairly new to Ninjascript and cannot understand why I am not getting the highest "high" or lowest "low" of a group of bars -- what I am getting is the Highest or Lowest "close" - not the extreme points of the bar.

    The code I am using is...

    LowestLowUK = Low[LowestBar(Low, EndBarUK-StartBarUK)];
    HighestHighUK = High[HighestBar(High, EndBarUK-StartBarUK)];

    I suspect there is some setting that I am not using but I am running out of ideas having trawled the help and the forum.

    #2
    You can just use MIN(Low, 20)[0] and MAX(High, 20)[0].
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Josh View Post
      You can just use MIN(Low, 20)[0] and MAX(High, 20)[0].
      Thanks for the quick reply - but still no joy....

      Tried this with the following code using both methods over 5 days....

      EndBarUK = CurrentBar;
      LowestLowUK = Low[LowestBar(Low, EndBarUK-StartBarUK)];
      Print("The current MIN value is " + LowestLowUK.ToString());
      HighestHighUK = High[HighestBar(High, EndBarUK-StartBarUK)];
      Print("The current MAX value is " + HighestHighUK.ToString());

      LowestLowUK = MIN(Low, EndBarUK-StartBarUK)[0];
      Print("The current MIN value is " + LowestLowUK.ToString());
      HighestHighUK = MAX(High, EndBarUK-StartBarUK)[0];
      Print("The current MAX value is " + HighestHighUK.ToString());
      Print("--------------------");


      with the following result

      The current MIN value is 120.27
      The current MAX value is 120.88
      The current MIN value is 120.27
      The current MAX value is 120.88
      --------------------
      The current MIN value is 118.47
      The current MAX value is 118.685
      The current MIN value is 118.47
      The current MAX value is 118.685
      --------------------
      The current MIN value is 118.035
      The current MAX value is 118.45
      The current MIN value is 118.035
      The current MAX value is 118.45
      --------------------
      The current MIN value is 117.115
      The current MAX value is 117.48
      The current MIN value is 117.115
      The current MAX value is 117.48
      --------------------
      The current MIN value is 119.495
      The current MAX value is 119.87
      The current MIN value is 119.495
      The current MAX value is 119.87
      --------------------
      The current MIN value is 120.22
      The current MAX value is 121.15
      The current MIN value is 120.22
      The current MAX value is 121.15
      --------------------

      Comment


        #4
        Hi scottyboy, did you check the sample code provided by Josh? Did this deliver the correct High / Low extreme values 20 bars back?

        If yes, you will need to debug your 'EndBarUK-StartBarUK' to see why it does arrive a wrong bar number.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Bertrand View Post
          Hi scottyboy, did you check the sample code provided by Josh? Did this deliver the correct High / Low extreme values 20 bars back?

          If yes, you will need to debug your 'EndBarUK-StartBarUK' to see why it does arrive a wrong bar number.
          Unfortunately - no. The bar range is irrelavant, it's just not returning the high and low of the range chosen -- seems to be using the close. look at the image attached. The inner light grey area is meant to be defining the Bar highs and lows -- you can see that it isn't. It's not a problem drawing the box.

          I'm using IB data feed.
          Attached Files

          Comment


            #6
            scottyboy,

            You are misunderstanding the functions. You do not specify a range. You specify a lookback period from the CurrentBar.

            MIN(Low, 20)[0] looks back 20 bars from the current bar. It evaluates all of those bars.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Josh View Post
              scottyboy,

              You are misunderstanding the functions. You do not specify a range. You specify a lookback period from the CurrentBar.

              MIN(Low, 20)[0] looks back 20 bars from the current bar. It evaluates all of those bars.
              Sorry, I confused the issue by saying "Range". I am looking back from the CurrentBar. Assume that "EndBarUK-StartBarUK" works out as 20 ( in reality I am looking back for 2 hours ).

              Comment


                #8
                Right, so you are then getting the low from the latest bar and 20 bars ago.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Josh View Post
                  Right, so you are then getting the low from the latest bar and 20 bars ago.
                  The problem I have is it is not giving me the "low" of the last 20 bars -- it is giving me the lowest "close" price of the last 20 bars. Have a look at the chart I posted and look at the light grey inner box (ignore the dark grey bands ) and you will see that the lowest point is on the "close" of a bar and not the absolute lowest point of the bars.

                  Sorry for banging on about this but I need to resolve what I am doing wrong before I can progress.

                  Thanks again for your time.

                  Comment


                    #10
                    From your chart you are not looking at the last 20 bars. You have the big black arrow at the top meaning you have bars hidden. I have no way of correlating your print outs and what is on the chart, especially without timestamps.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by NinjaTrader_Josh View Post
                      From your chart you are not looking at the last 20 bars. You have the big black arrow at the top meaning you have bars hidden. I have no way of correlating your print outs and what is on the chart, especially without timestamps.
                      OK - here's a live chart...
                      Attached Files

                      Comment


                        #12
                        scottyboy,

                        I need a live chart and its corresponding print outs along with timestamps. Please add Time[0] to your print functions.

                        Print(Time[0] + " " + .... etc);
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          Originally posted by NinjaTrader_Josh View Post
                          scottyboy,

                          I need a live chart and its corresponding print outs along with timestamps. Please add Time[0] to your print functions.

                          Print(Time[0] + " " + .... etc);
                          OK - you asked for it

                          --------------------
                          20/01/2009 16:16:00 The current MIN value is 1.3938
                          20/01/2009 16:16:00 The current MAX value is 1.39865
                          20/01/2009 16:16:00 The current MIN value is 1.3938
                          20/01/2009 16:16:00 The current MAX value is 1.39865
                          --------------------

                          Here's the chart and also the fiblines.cs indicator that generates it.
                          Attached Files

                          Comment


                            #14
                            I cannot go through your indicator and decipher what it is trying to do. Just do a very simple MIN(Low, 20)[0] and a MAX(High, 20)[0]. You will find it gets you the lowest low and highest high as determined from the last 20 bars.

                            I guarantee you it works. If you feel it doesn't work you need to check your use of EndBarUk - StartBarUk.

                            Look at the attached picture. There are dots plotted for the close, lowest low, highest high. It is all accurate.
                            Attached Files
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              Hello Josh,

                              Got it sorted -- cut and pasted my stuff into your minmax.cs file and it gave the high's and low's as promised. I have No idea why my original file would not work - there's a glitch in it somewhere that is causing the strange behaviour.

                              Thanks for all you help and patience - it was excellent service.

                              Regards

                              Scottyboy.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by FrancisMorro, Today, 03:24 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post FrancisMorro  
                              Started by Segwin, 05-07-2018, 02:15 PM
                              10 responses
                              1,769 views
                              0 likes
                              Last Post Leafcutter  
                              Started by Rapine Heihei, 04-23-2024, 07:51 PM
                              2 responses
                              30 views
                              0 likes
                              Last Post Max238
                              by Max238
                               
                              Started by Shansen, 08-30-2019, 10:18 PM
                              24 responses
                              943 views
                              0 likes
                              Last Post spwizard  
                              Started by Max238, Today, 01:28 AM
                              0 responses
                              10 views
                              0 likes
                              Last Post Max238
                              by Max238
                               
                              Working...
                              X