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

Prior Day Close and Current Day Open

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

    Prior Day Close and Current Day Open

    Hello staff,

    Is there any way to access the actual Close of the prior day and the Open of the current day when I am using a Renko chart that is set to not break at the End of Day?
    The indicators PriorDayOHLC and CurrentDayOHL are not showing the true values due to my charts not breaking at the End of Day.

    I'm looking forward to your reply.

    #2
    Hello GLFX005,

    Thanks for your post.

    You could add a daily series to the strategy and then reference Closes[1][1] for the prior day's close and Opens[1][0] for the current day open. More information adding creating a Multi Time Frame script and how to reference Price Series in a Multi Time Frame script can be found below.

    Multi Time Frame and Instruments - https://ninjatrader.com/support/help...nstruments.htm

    We look forward to assisting.
    JimNinjaTrader Customer Service

    Comment


      #3
      Hello Jim,

      Thank you for your reply.

      I went ahead and applied some of the logic into an indicator which you can view in the code here --> https://pastebin.com/0z3XuJBk
      But the indicator is not plotting any lines, I would like the indicator to plot a line above and below the current day Open.
      What am I doing wrong in the code? Am I not loading up the Daily bar data properly?

      I'm looking forward to your reply.

      Comment


        #4
        Hello GLFX005,

        I would suggest checking the log tab of the Control Center to see if the indicator has received an error. Your logic references Opens[1][0], but it is not clear that the indicator has processed any daily bars before you are referencing that Price Series.

        This is similar to our Help Guide article on ensuring that enough bars have been processed in the data series you are accessing. In this case though, we will need to make sure that the script has processed at least one bar on the daily series. You can check the CurrentBar for the first added data series with CurrentBars[1].



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

        Comment


          #5
          Hello Jim,

          I was indeed getting that error but I have now resolved it by adding this to the code.

          {
          if (BarsInProgress != 0)
          return;

          if (CurrentBars[0] < 25)
          return;

          if (CurrentBars[1] < 25)
          return;

          Values[0][0] = Opens[1][0] + HighOffset;
          Values[1][0] = Opens[1][0] - LowOffset;
          }


          but I am still not getting any plots drawn on the chart even though there is no error occurring in the log tabs.
          any idea how to find out what's wrong?

          Comment


            #6
            Hello GLFX005,

            When you add prints to your logic, is the logic reaching where you assign the plot values?

            You are telling the script: "If 25 bars of daily data have not been processed, return." Are you loading more than 25 days of data on the chart?

            If you check for 1 daily bar, and load more data than that on the chart, do you see results?

            I.E.

            Code:
            if (CurrentBars[1] < 1)
                return;
            Debugging Tips - https://ninjatrader.com/support/help...script_cod.htm

            I look forward to assisting.
            JimNinjaTrader Customer Service

            Comment


              #7
              double d1=Opens[2][0];
              double d2=Closes[2][1];
              Print("QQQ:" +"today open : " + d1 + " last close: " + d2);
              if (BarsInProgress ==2)

              {
              if(Opens[2][0]> Closes[2][1])
              {
              action = true;
              }
              else if (Opens[2][0]< Closes[2][1])
              {
              action = false;
              }

              }

              i have 1 min 5 min and daily time series,why the following errors found, "Error on calling OBarUpdate method on bar-1.You are accessing an index with a value that is invalid since it os out of range

              Comment


                #8
                Hello stantenlee,

                This looks like the same issue, but on the 2nd added data series.

                The steps to take to resolve:
                1. Add a unique print after each line of code
                2. What is the line of code that is throwing the error?
                3. What BarsAgo index is being used on that line? (What is in the square brackets? '[X]')
                4. What is the CurrentBar index for that data series when that line of code is referenced? (How many bars have been processed in that data series when you are referencing that many bars ago?)
                Checking the information above will tell you exactly where the error is thrown, the specific index that you are using that is invalid, and how many bars that you need to check before referencing that many bars ago on that data series.

                Please refer to the links in posts #2 and #4 for working with Multi Time Frame scripts and for making sure there are enough bars in the data series you are referencing.
                JimNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by jaybedreamin, Today, 05:56 PM
                0 responses
                7 views
                0 likes
                Last Post jaybedreamin  
                Started by DJ888, 04-16-2024, 06:09 PM
                6 responses
                18 views
                0 likes
                Last Post DJ888
                by DJ888
                 
                Started by Jon17, Today, 04:33 PM
                0 responses
                4 views
                0 likes
                Last Post Jon17
                by Jon17
                 
                Started by Javierw.ok, Today, 04:12 PM
                0 responses
                12 views
                0 likes
                Last Post Javierw.ok  
                Started by timmbbo, Today, 08:59 AM
                2 responses
                13 views
                0 likes
                Last Post bltdavid  
                Working...
                X