Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

IsFirstBarofSession

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

    IsFirstBarofSession

    I have attached the code I used....

    Setup....
    -- Standard Ninja Chart using YM 03-16 RTH ....
    -- ChartBars are 90 second bars
    -- DaysToLoad = 5
    -- (secondary dataseries in the code is 60 seconds...)
    -- DataFeed is standard NinjaBroker

    The code prints on Bar 0 and at the beginning of every session....

    Results.....
    with the datafeed DISCONNECTED....the code can not find the very last BarsArray[1].IsFirstBarOfSession.

    When I connect the datafeed....the code now finds the very last BarsArray[1].IsFirstBarofSession

    This seems to create a possible issue if my user disconnects midday, and then goes back in the evening to look at charts with datafeed disconnected, any code expecting to find BarsArray[1].IsFirstBarofSession will not have triggered.


    NOTE: If I have "Tick Replay" checked, this problem does not seem to appear. In that instance the BarsArray[1] does seem to be able to find the IsFirstBarofSession on the very last session.
    Attached Files

    #2
    Hello,

    Thank you for writing in.

    I will be reviewing your code and this case. When I have additional details I will follow up here on this thread.

    Comment


      #3
      Hello,

      Thank you for writing in.

      With the initial set up of your chart, you have already have a Data Series on the chart. In the Configure state of your code, you are adding the same instrument to the chart.

      Please try: AddDataSeries(BarsPeriodType.Second, 60)

      What does this do with your Chart?

      I'll be waiting for your reply.

      Comment


        #4
        ...accidentally clicked into the wrong thread...(sorry)

        Comment


          #5
          Clearly I did not communicate well....

          My Chart was 90 seconds...but it could be ANYTHING as long as it is bigger than 60 seconds.
          The secondary dataseries contained in the code I sent you is 60 seconds.
          The whole intent of this exercise is to have let the code look for IsFirstBarofSession on BarsArray[1].

          The problem showed up when the secondary dataseries in the code is DIFFERENT from the primary chart. ....(there were be no need to run a secondary dataseries if it is the same as the primary chart bars)....

          Comment


            #6
            Hello,

            Thank you for the reply.

            Can you share the output window? And what you should except to output?

            I want to know if we are getting the same results.

            I'll be waiting for your reply.

            Comment


              #7
              No problem.... (give me a bit to bring up charts and data)....

              Comment


                #8
                ...(sorry for the delay.....been a busy week, but I'm guessing you guys are buried as well)...

                Attached a chart image...(this time of a 17 range chart)....taken about 1 hour into the morning cash session. I marked the 8:30 session open bar with some text.
                In this example, NinjaBroker was connected.....

                Attached the Output1 text this time showing no BIP0 IsFirstBarofSession, but showing the BIP1 IsFirstBarOfSession.

                (NOTE: in other combinations I sometimes get the issue of finding BIP0 IsFirstBarofSession, but no BIP1 IsFirstBarofSession....
                This is one of those things I should have documented better as I went, but at the time I had bigger self-inflicted problems to deal with ).




                As always, running the same the code (aaa1 which has a 60 second secondary dataseries added). NOTE: It does seem to a difference to some results if a "Historical Data" load has just been done.

                If I get time later today, I will try to run more examples, using different combinations of Primary chart bars and "connected" versus "not connected"....(all using NinjaBroker).
                Attached Files
                Last edited by photog53; 02-05-2016, 09:32 AM.

                Comment


                  #9
                  *** NOTE: I edited this post a couple of time, correcting miskeys that I didn't notice until I had already hit "save changes"....keying too fast


                  OK this is weird.... the missing "IsFirstBarofSession showed up again this morning.
                  I printed all the "IsFirstBarofSession" from a 90 Second Chart. ....(see attached screen grab of aaa1.cs ).....


                  The 'IsFirstBarofSession' jumps from 8:31am on 2/10 to 8:31am on 2/11...completely skipping the 2:01am 2/11 session start. I don't get a 'IsFirstBarofSession' for either dataseries...(neither BarsInProgress[0] nor BarsInProgress[1] )...
                  Every other day on the chart works fine except for today, where the first session (2am) is missing it's IsFirstBarofSession.

                  In this example...the problem chart is a 90 second chart with 5 days lookback.
                  This chart uses uses a "two session" Trading Hours template,
                  first session starting 2am CST ending 8:30amCST,
                  second session starting 8:30amCST ending 3:15pmCST....
                  .....(see attached screen grab of Trading Hours template)......

                  The code that executed the print is ....

                  PHP Code:
                              if (BarsInProgress == 1)
                              {
                                  if (
                  CurrentBars[1] == 0)
                                  {    Print(
                  "---BIP1 chartstart "+Times[1][0].ToString() );    }
                              
                                  else if (
                  BarsArray[1].IsFirstBarOfSession)
                                  {    Print(
                  "        BIP1 FBOS= "+Times[1][0].ToString() );    }
                              }
                              
                              
                  //>>>>>>>>>>>>>
                              
                             
                  if (BarsInProgress == 0)
                              {
                                  if (
                  CurrentBars[0] == 0)
                                  {    Print(
                  "---BIP0 chartstart "+Times[0][0].ToString() );    }
                                  else if (
                  BarsArray[0].IsFirstBarOfSession)
                                  {    Print(
                  "        BIP0 FBOS= "+Times[0][0].ToString() );    }
                              }
                              
                              if ((
                  BarsInProgress == 0) && (Bars.IsLastBarOfSession))
                                  Print(
                  "------------------------------------------------------------------------------------- "); 
                  The data feed is standard NinjaBroker....

                  The secondary data series is (60 Seconds).....


                  ---------------------------------------------------------------------------------------------------

                  For the life of me I can't pinpoint what is going on...this problem does not happen consistently....other than it usually occurs on the most recent day in the chart.
                  When it does occur, the problem doesn't always affect all charts....(like today, I brought up a Range chart and it showed a 2:01am IsFirstBarofSession for 2/11
                  but ONLY for BarsInProgress[0].....

                  At this point I would be happy if this was something stupid I am doing....just to get it fixed and out-of-the-way.
                  Attached Files
                  Last edited by photog53; 02-11-2016, 09:49 AM.

                  Comment


                    #10
                    Hello photog53,

                    Thank you for your response.

                    What time zone are you in? I would like to verify if this is time zone related. I judge from the Session Template that you are in Central Time Zone, correct?

                    Comment


                      #11
                      You are correct...Central Time

                      Comment


                        #12
                        Hello photog53,

                        I was unable to reproduce this on my end when disconnected from a live data feed.

                        So that I can ensure we are using exactly the same trading hours template, can you please attach your trading hours template to your reply? The trading hours template can be found from within the (My) Documents\NinjaTrader 8\templates\TradingHours directory on your computer.
                        Zachary G.NinjaTrader Customer Service

                        Comment


                          #13
                          I have attached the custom .xml template for this test set of Trading Hours .

                          Two quick observations....
                          I have encountered this problem even when using the standard Ninja RTH template

                          Second observation....exactly as with your comment, occasionally I have issues recreating it on command....(although it consistently seems to pop up) ....which sort of indicates that some weird combination of things are required to have it act up....or I am accidentally triggering something.

                          ....(sorry I had to save this as a .txt .... I could not get the .xml file to upload).....
                          Attached Files
                          Last edited by photog53; 02-18-2016, 12:59 PM.

                          Comment


                            #14
                            Hello photog53,

                            Thank you for your trading hours template.

                            I'm still unable to reproduce this on my end.

                            Please sync your PC clock to see if this will resolve the behavior.
                            • Close NinjaTrader.
                            • Click on the clock in the lower right corner of your desktop.
                            • Press 'Change time zone...'.
                            • Set the Time zone and press 'OK'.
                            • Click on Internet Time tab.
                            • Set the server to time.nist.gov and then click Update.


                            Your PC clock should now be updated.
                            Zachary G.NinjaTrader Customer Service

                            Comment


                              #15
                              I generally sync my clock every day...(sometimes I forget)....but it is pretty much a habit.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Rapine Heihei, Today, 08:19 PM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by Rapine Heihei, Today, 08:25 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post Rapine Heihei  
                              Started by f.saeidi, Today, 08:01 PM
                              1 response
                              9 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by Rapine Heihei, Today, 07:51 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post Rapine Heihei  
                              Started by frslvr, 04-11-2024, 07:26 AM
                              5 responses
                              98 views
                              1 like
                              Last Post caryc123  
                              Working...
                              X