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

Refer to a bar

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

    Refer to a bar

    Hello,

    how can I define in a strategy "if the price is higher than the high of the last bar of prior day" and how can I define "if close is higher than open of first bar of the actual day" My question does not refer to the higher, lower.. but it refers how I can mark and touch a price of the LAST BAR OF PRIOR DAY and a price of the FIRST BAR OF TODAY.

    Thanks in advance.
    Tony

    #2
    if (Close[0] > PriorDayOHLC().PriorHigh[0])

    if (Close[0] > CurrentDayOHL().CurrentOpen[0])
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Refer to bar

      Hello Josh,

      thank you for your reply. Maybe I´ve a misunderstanding of your reply but for me it seems that your information "if (Close[0] > PriorDayOHLC().PriorHigh[0])" is the high of prior day. I know how to use high of prior day. I asked for high of last bar of prior day (this must not be the high of prior day).

      Thanks in advance.
      Tony

      Comment


        #4
        Then use GetBar() to get the bars ago for the timestamp of the last bar of the prior day and then use High[x] where x is the return value from GetBar.

        Or you could try BarsSinceSession + 1 to go back one bar further than the first bar of the session which would be the previous session's close.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          When you use GetBar() for the current session does it retrieve from historical data or real time data? Is there a way to specifically ask for historical? For example

          Say I'm 20 minutes into the day's session and I want to get the opening price of the current session. If i use currentohlc it will retrieve the bars from the real time feed. What if I want to get the bar from the historical bars? The same data I would get if I manually asked the chart to reload historical data

          Thanks

          Comment


            #6
            Not sure what you mean. When you use GetBar() you tell it at what time you want to go "get". You provide the time and date, and the method returns you how many bars back that time and date is.

            There is no real time bar vs. historical bar distinction. It is just whatever bar you see on the chart. If you are connected to a data provider, then this would be a real-time bar as you call it.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              I have found that the bars that show up on the chart real-time and when I choose to reload historical data, differ. Particularly, at the open. There is another thread called "Incorrect Opening Price?" where I have screen shots on the differences. Another Ninjatrader support person stated that

              "Unfortunately that may just be the data IB is pushing through on the open. When you reload historical data it is not pulling real-time data any more, but rather from a historical feed which can be different."

              Currently I am using currentohlc to get the opening price for the day which again, differs slightly from the historical data.

              I am looking for a way to get the opening price based on historical data feed without having to do a manual reload.

              Comment


                #8
                IZ_Trader, I would suggest you check with your data provider on this, some handle the day open differently then others - which provider(s) are you using?
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  I have reproduced this scenario with using both esignal and Interactive brokers as data feeds. After trying different things, my suspicion is that the chart is looking at my machines local time to retrieve bars instead of native market time. When you retrieve historical data you always get native market time. Which is why I was hoping there was a way to programmatically retrieve the historical open of the current session.

                  Comment


                    #10
                    eSignal is timestamped natively and IB is local.

                    PC clock sync is always important. Be sure to sync your PC clock and also ensure you are using correct session begin/end times.
                    Josh P.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by futtrader, 04-21-2024, 01:50 AM
                    4 responses
                    41 views
                    0 likes
                    Last Post futtrader  
                    Started by Option Whisperer, Today, 09:55 AM
                    1 response
                    11 views
                    0 likes
                    Last Post bltdavid  
                    Started by port119, Today, 02:43 PM
                    0 responses
                    7 views
                    0 likes
                    Last Post port119
                    by port119
                     
                    Started by Philippe56140, Today, 02:35 PM
                    0 responses
                    7 views
                    0 likes
                    Last Post Philippe56140  
                    Started by 00nevest, Today, 02:27 PM
                    0 responses
                    7 views
                    0 likes
                    Last Post 00nevest  
                    Working...
                    X