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 DJ888, 04-16-2024, 06:09 PM
            4 responses
            12 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by terofs, Today, 04:18 PM
            0 responses
            7 views
            0 likes
            Last Post terofs
            by terofs
             
            Started by nandhumca, Today, 03:41 PM
            0 responses
            6 views
            0 likes
            Last Post nandhumca  
            Started by The_Sec, Today, 03:37 PM
            0 responses
            3 views
            0 likes
            Last Post The_Sec
            by The_Sec
             
            Started by GwFutures1988, Today, 02:48 PM
            1 response
            9 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Working...
            X