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

question about prior close price

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

    question about prior close price

    I am trying to get last day close price to use on today trading. Inside onBarUpdate and if (Bars.FirstBarOfSession) I use this"

    if (BarsInProgress == 0) (using multi assets)
    {
    priorClosePrice0 = PriorDayOHLC().PriorClose[0];
    priorOpenPrice0 = PriorDayOHLC().PriorClose[0];
    }
    But checking on out windows I see that priorClosePrice0 and priorOpenPrice0 are taking values not for yesterday but the day before yestaerday.
    How can I get last day parameters? what am i doing wrong?

    #2
    Hello dafonseca,

    Are you certain that the data you are calling PriorDayOHLC on is a bar from today?

    What time is the bar that this is being checked on?

    What is the time of the session close of the session the close is returning from?


    Attached is an example that I am finding works without any issue.

    Follow these steps to import the NinjaScript:
    1. Download the script to your desktop, keep it in the compressed .zip file.
    2. From the Control Center window select the menu File > Utilities > Import NinjaScript
    3. Select the downloaded .zip file
    4. NinjaTrader will then confirm if the import has been successful.

    Critical *Note that on any files that say "File already exists on your PC" that start with an "@" symbol are the ones that came preloaded inside of NinjaTrader so you would say "No" so that you do not override those files.
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Am I trying to follow the dates.
      And as showed on attachment all previous days the priorOpen and priorClose are right, But for today (03192015) the priorOpen and close is not right (from the day before yesterday).
      Just wanna say that priorOpen and close is from instrument 1 instead of inst 0.
      One question regarding the attachment would be: why the time of the trade is showing 8:31. Does the market before 9:30 updates for priorclose? maybe that is where the error is coming from.
      .
      Attached Files

      Comment


        #4
        I make some testing and I find something weird.
        When I force the system to begin trading at 9:32 it still shows the same error (getting the open and close from the day before yesterday) but when I force it to use 9:33 it gets it all right.
        Any clue?

        Comment


          #5
          Hello dafonseca,

          Attached is a screenshot of the value that I am getting at 7:31 (MST) as well as the updated code I used to find this value.

          Is this the correct value that you are looking for?


          The first minute of the day closes at 9:31 Eastern time. What value where you expecting?

          The prior open will be from the first tick received of the previous session which will also be the open of the first minute bar of the previous session.

          Are you finding the value I am showing is correct?
          Attached Files
          Last edited by NinjaTrader_ChelseaB; 03-19-2015, 03:06 PM.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            yes, your value is correct. But i am using priorOpen and Close from intrument 1 not instrument 0 as you are, And i suspect this is causing me problems.

            Comment


              #7
              I am using ES futures as instrument 0 and VIX as instrument 1, Does it changes something ?

              Comment


                #8
                Hello dafonseca,

                Here is the same thing using the ES as the primary and the ^VIX as the secondary.

                The PriorDayOHL will be for the secondary series.

                (The only change in the code was to change Add(PeriodType.Minute, 1) to Add("^VIX", PeriodType.Minute, 1))

                Is this the correct value?

                Attached is a screenshot and the code with that one change.

                (Also, I just noticed in post #5 I had attached the wrong script. This is the correct script.)
                Attached Files
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by TraderBCL, Today, 04:38 AM
                2 responses
                11 views
                0 likes
                Last Post TraderBCL  
                Started by martin70, 03-24-2023, 04:58 AM
                14 responses
                105 views
                0 likes
                Last Post martin70  
                Started by Radano, 06-10-2021, 01:40 AM
                19 responses
                607 views
                0 likes
                Last Post Radano
                by Radano
                 
                Started by KenneGaray, Today, 03:48 AM
                0 responses
                4 views
                0 likes
                Last Post KenneGaray  
                Started by thanajo, 05-04-2021, 02:11 AM
                4 responses
                471 views
                0 likes
                Last Post tradingnasdaqprueba  
                Working...
                X