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

Using PriordayOHLC to retreive 2 days ago

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

    Using PriordayOHLC to retreive 2 days ago

    Hi - I'm programming a strategy which will need to compare the close of 2 days ago with the close of 1 day ago. How can I do get the close of 2 days ago, ie:

    PriorDayOHLC().PriorClose[0] < PriorDayOHLC().PriorClose[0]

    ?

    #2
    PriorDayOHLC().PriorClose[1] < PriorDayOHLC().PriorClose[2]
    RayNinjaTrader Customer Service

    Comment


      #3
      That seems to prevent any trades from showing up

      What am I doing wrong with this code? Basically, I'm trying to say if the close of the 833 AM bar is below yesterday's close and the close of 2 days ago is below yesterday's close, buy at the market. IE

      if (ToTime(Time[0]) == ToTime(8, 33, 0)
      && Close[
      0] > PriorDayOHLC().PriorClose[0] + -2 * TickSize
      && PriorDayOHLC().PriorClose[
      2] < PriorDayOHLC().PriorClose[1])
      {
      EnterLong()

      }

      Thanks in advance for any assistance.

      Comment


        #4
        Any time you run a strategy/indicator and it does not work as expected you should check the Control Center log tab for any errors. I suspect you might see one that says "index out of range"

        If yes, please see the following tip for additional information.

        RayNinjaTrader Customer Service

        Comment


          #5
          No Erros on Log

          There are no errors on the log - I'm running it on a 1 minute ES Chart with 15 days of info - the index is in range.

          It appears the logic isn't working. But under this logic on the ES - there should have been many trades over the course of that 15 days. What is wrong with the syntax of comparing the close of 2 days ago to the close of 1 day ago?

          Comment


            #6
            Since I don't have your data set I can't tell what this code snippet should or should not do.

            At this stage, you will have to debug your code and break into smaller pieces to see what is happening/not happening and why.

            Here is a tip we created to provide some ideas in this area - http://www.ninjatrader-support.com/v...ead.php?t=3418
            RayNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by quantismo, Yesterday, 05:13 PM
            1 response
            12 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by The_Sec, 04-16-2024, 02:29 PM
            3 responses
            16 views
            0 likes
            Last Post NinjaTrader_ChristopherS  
            Started by hurleydood, 09-12-2019, 10:45 AM
            15 responses
            1,098 views
            0 likes
            Last Post Leeroy_Jenkins  
            Started by danieldunn2024, Today, 03:06 AM
            1 response
            5 views
            0 likes
            Last Post NinjaTrader_Erick  
            Started by cre8able, Yesterday, 04:16 PM
            1 response
            16 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Working...
            X