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

Bars.GetHigh(x) returns wrong value

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

    Bars.GetHigh(x) returns wrong value

    Hello,

    I encountered a situation where Bars.GetHigh(x) returns the wrong value -- or at least it appears that way.

    If you watch the following 1m40s movie (https://app.box.com/s/ttl26esieva3rlgwpff61xj04v32beql) you will see:
    * on the 4-sec chart, the bar #11190 visually shows High=2794.50, which is also displayed on the DataBox
    * the function High() provides a wrong value(2793.75), though, for that bar.

    Why does this happen, you think? Thank you.

    #2
    Hello utilizator,

    I looked at the video however there was no audio when I played it so it was a little difficult to follow. I was not able to see anything specific from that preview of what you are doing which I could make suggestions on. Do you have a simplified sample of only the problem in script form that you can provide?

    It looks like from the video this is fairly deep into your script, to further address what is happening you may need to extract only the prints you made and only the logic which is needed to reproduce the problem into a new script as a sample. This would help in seeing the overall scope of what you are doing and allow for testing. I really can't tell from the video the overall scope of what the script is doing to better understand the problem. I also cannot see where you are using GetHigh logically for this comparison here, it appears this may be in OnMarketData, is there a reason GetHigh is being used here instead of High or Highs? Was this simply for comparison purposes?

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse,

      Thank you for your reply.
      What I wanted to show was the wrong value for the High of bar #11190, as printed by the Print() instructions:

      Print("High["+CurrentBar+"-"+EStipBar+"]="+High[CurrentBar-EStipBar]);
      Print("Bars.GetHigh("+EStipBar+")="+Bars.GetHigh(E StipBar));

      Print("Low["+CurrentBar+"-"+EStipBar+"]="+Low[CurrentBar-EStipBar]);
      Print("Open["+CurrentBar+"-"+EStipBar+"]="+Open[CurrentBar-EStipBar]);
      Print("Close["+CurrentBar+"-"+EStipBar+"]="+Close[CurrentBar-EStipBar]);

      This sequence of code is a part of the OnBarUpdate().
      I could send you the source and the data series -- for you to be able to see this anomaly in context, -- if possible. Please let me know. Thank you.

      Comment


        #4
        Hello utilizator,

        Yes, I would likely need to see a simplified example of the problem. The video was not specifically helpful in highlighting what may be happening in this case. I would suggest creating a new empty indicator which has no logic and add only what is required for the prints to show the problem. We would want to avoid the remainder of your logic and output to keep the test as direct as possible. This will allow me to see the whole scope of what you are actually testing and also I can test the script myself to understand the outcome better.

        Please let me know if I may be of additional assistance.

        JesseNinjaTrader Customer Service

        Comment


          #5
          Hi Jesse,
          Thank you for your reply.
          In a simplified context the issue does not occur, I tried. I cannot think of another way for you to reproduce my results (shown in the movie) other than running this specific indicator. Is there another way? Thank you.

          Comment


            #6
            Hello utilizator,

            Thank you for your reply.

            If the new script does not show the problem that is a step in the right direction because it now exhibits the correct action which should allow for some comparison to be done between scripts.

            One way to approach this would be to compare and contrast what changed between the scripts to try and spot the differences. Forming a simplified example would be my usual suggestion to allow us to explore the problem together however if the problem no longer happens in that sample, you likely either missed what is causing the problem or have solved the problem.

            Because of this result comparing what was excluded may help in understanding what was happening. You could take a look at items which may be affecting the OnBarUpdate logic such as additional series or if statements involving BarsInProgress checks. You could also add some prints into the overall surrounding conditions to see how they are equating between tests, instead of comparing prices you could compare other variables such as the BarsInProgress or just the CurrentBar/Time to see that the conditions used were called in the same order at the same times etc..

            Alternatively, this sample could form the framework for your script and you can migrate the existing code in chunks into the sample script while confirming it remains working. You will either eventually see the problem again as you copy the code over or if you corrected the problem early on in your sample you may just see that it now works.

            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Thank you Jesse.

              For the interested programmers:
              in Playback mode the function Bars.GetHigh() lets you access 'future' bars(not yet present on chart)
              double h = Bars.GetHigh(CurrentBar+n) with n=1,2,3,…
              without signaling an error. The returned value 'h' is unreliable.
              Subsequent NT8 function calls in the script will use 'h' as the High of that bar, i.e. bar # (CurrentBar+n).

              Probably similar behavior holds for Bars.GetLow(),Bars.GetClose(),etc

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Brevo, Today, 01:45 AM
              0 responses
              3 views
              0 likes
              Last Post Brevo
              by Brevo
               
              Started by aussugardefender, Today, 01:07 AM
              0 responses
              3 views
              0 likes
              Last Post aussugardefender  
              Started by pvincent, 06-23-2022, 12:53 PM
              14 responses
              238 views
              0 likes
              Last Post Nyman
              by Nyman
               
              Started by TraderG23, 12-08-2023, 07:56 AM
              9 responses
              384 views
              1 like
              Last Post Gavini
              by Gavini
               
              Started by oviejo, Today, 12:28 AM
              0 responses
              6 views
              0 likes
              Last Post oviejo
              by oviejo
               
              Working...
              X