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

last price greater then high of bar

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

    last price greater then high of bar

    On my chart I have an indicator that prints only when the last price via the onmarketupdate function is greater than high[0]. Should that be possible? I was thinking that they should at least be equal.

    #2
    Hello hansob3,

    Thank you for your post.

    OnMarketData() will actually be called after OnBarUpdate() and therefore would not have the last price above the High[0] unless the OnMarketData() was updating outside the Trading Hours Template defined start and end times (which is the only time OnBarUpdate() is called).

    Please let me know if you have any questions.

    Comment


      #3
      Here is a snippet of the debug output where I am having an issue.

      2018-03-09 06:31:58:451 OnMarketUpdate:
      CurrentBar: 825
      Price: 2740.25
      Vol: 2
      Bid: 2740 - Ask: 2740.25
      2018-03-09 06:31:58:451 Bar Added - Down to Up
      Last Price: 2740.25
      Reversal Price: 2740.25
      2018-03-09 06:31:58:451 OnBarUpdate:
      CurrentBar: 826

      The timestamps are identical but the Bar added needs to come first in the sequence. I have a modified Point and Figure that I use but the logic of when a bar is created is the same as the builtin version. In the attached screenshot you can see the high/close of the bar but yet I get a tick above printed. Those 2 lots should be the beginning of the next bar.

      My thinking is that the Bars would generate the events that the indicators would consume.
      Attached Files

      Comment


        #4
        Hello hansob3,

        Thank you for your response.

        Are you building your own bar type here or using an indicator to render the bars?

        Can you attach your script to your response?

        You can export your file by going to Tools > Export > NinjaScript Add On > Add > select your file > OK > Export > name the file 'NTsupport' > Save.

        The file will be located under Documents\NinjaTrader 8\bin\Custom\ExportNinjaScript. Please attach the file to your response.

        I look forward to your response.

        Comment


          #5
          I use a modified point and figure to build the bars. I tried exporting but I get an error about DayBarsType(), MinuteBarsType(), ... not in the assembly. It is in the initial lookback days method. All I did was copy the original Point and Figure but changed some of the logic but I did not change any of the logic that decides when a new bar should be added. I added a print statement to print right after the AddBar is called. I use the close, 1 tick 4 box reversal with a base period of 1 tick and tick replay checked. I do not break on EOD.


          Attached is a test script that I made to go with the bars that allows you to see the debug messages.

          I am using an indicator to render the volume numbers on the chart. I would like to do it as a bar type.

          I forgot to mention that this happens on every bar, just easier to see when its above the high/low.
          Attached Files
          Last edited by hansob3; 03-09-2018, 12:21 PM.

          Comment


            #6
            Hello hansob3,

            Thank you for your patience.

            Here is an excerpt from my Output:
            OnBarUpdate:
            CurrentBar: 286

            OnMarketData:
            CurrentBar: 286
            Price: 2786.75
            Vol: 1
            High: 2789.75 - Low: 2784.75
            Bid: 2786.75 - Ask: 2787

            OnBarUpdate:
            CurrentBar: 287

            OnMarketData:
            CurrentBar: 287

            Price: 2787
            Vol: 5
            High: 2786.75 - Low: 2785.25
            Bid: 2786.75 - Ask: 2787

            OnBarUpdate:
            CurrentBar: 287

            OnMarketData:
            CurrentBar: 287
            Price: 2787
            Vol: 1
            High: 2786.75 - Low: 2785.25
            Bid: 2786.75 - Ask: 2787
            We can clearly see OnBarUpdate is called first here. I am failing to understand the item we are investigating here. Can you provide further detail on what you are inquiring on?

            I look forward to your response.

            Comment


              #7
              The issue I am having is that the AddBar method within the bar type is not called before the OnBarUpdate within the indicator. I have attached the bar type that I use. If you use that bar type with the previous indicator you get the results that I originally posted.

              So my question is shouldn't the bar type AddBar be called before calling the OnBarUpdate within the indicator? In the sequence of events it shows that even though the price has met the if statement within the bar type to add a bar it is not called till after the OnBarUpdate and OnMarketData events are called.

              Thanks

              Bryan
              Attached Files

              Comment


                #8
                Hello hansob3,

                Thank you for your response.

                I am still receiving the output I saw before even with 'MyBarVS'. Do I need to use a specific 'Box Size', 'Base Period Type', 'Base Period Value', or 'Reversal' to see what you are reporting?

                I look forward to your response.

                Comment


                  #9
                  I use a 1 for box size, 4 for reversal, base type is 1 tick with tick replay enabled.

                  Comment


                    #10
                    Hello hansob3,

                    Thank you for your response.

                    I am seeing the same results as I was with the 1 Minute base period. Can you copy your Output to a text document and then attach the document to your response?

                    I look forward to your response.

                    Comment


                      #11
                      See attachment.

                      Take the example at the 2018-03-14 07:35:30:272 mark. That line is printed out when a new bar is added. You can see the last price is 2781 and that matches the reversal price, hence the new bar. If you take a look a few lines above you see the OnMarketData event with that same price, that tick should have triggered the AddBar and that OnMarketData event should be the first tick on the newly added bar.

                      Thanks,
                      Bryan
                      Attached Files
                      Last edited by hansob3; 03-14-2018, 07:12 AM.

                      Comment


                        #12
                        Hello hansob3,

                        Thank you for your response.

                        Your Logged details show that the 2781 price level triggering the AddBar is called first as seen below:
                        2018-03-14 07:35:30:272 Bar Added - Up to Down
                        Last Price: 2781
                        Reversal Price: 2781
                        2018-03-14 07:35:30:272 OnBarUpdate:
                        CurrentBar: 1495
                        2018-03-14 07:35:30:272 OnMarketData:
                        CurrentBar: 1495
                        Price: 2781
                        Vol: 1
                        High: 2781 - Low: 2781
                        Bid: 2781 - Ask: 2781.25
                        While that same price is seen in a bar update and market data update directly before does not suggest that it is what called the AddBar.

                        Do you have an example where the AddBar is shown last and the next OnBarUpdate and the next OnMarketData calls are not the exact same price?

                        I look forward to your response.

                        Comment


                          #13
                          Attached is another log with timestamps. Take a look at the very last one in the file. Timestamp: 2018-03-15 12:48:53:780


                          2018-03-15 12:48:53:780 OnBarUpdate:
                          CurrentBar: 476
                          Time: 636567149322030000
                          2018-03-15 12:48:53:780 OnMarketData:
                          CurrentBar: 476
                          Price: 2751.75
                          Vol: 1
                          High: 2752.75 - Low: 2752
                          Bid: 2751.75 - Ask: 2752
                          Time: 636567149322030000
                          2018-03-15 12:48:53:835 Bar Added - Up to Down
                          Last Price: 2751.75
                          Reversal Price: 2751.75
                          Time: 636567149322260000
                          2018-03-15 12:48:53:835 OnBarUpdate:
                          CurrentBar: 477
                          Time: 636567149322260000
                          2018-03-15 12:48:53:835 OnMarketData:
                          CurrentBar: 477
                          Price: 2752
                          Vol: 1
                          High: 2751.75 - Low: 2751.75
                          Bid: 2751.75 - Ask: 2752
                          Time: 636567149322260000
                          While that same price is seen in a bar update and market data update directly before does not suggest that it is what called the AddBar.
                          What calls AddBar?

                          A tick came in at 2751.75 and was added to bar 467, but that same tick is what triggers the AddBar logic. Shouldn't that tick that came in fire the AddBar logic before is reaches the OnBarUpdate and MarketData events? What event triggers the OnBarUpdate?
                          Attached Files

                          Comment


                            #14
                            Hello hansob3,

                            Thank you for your response.

                            AddBar() is called in OnDataPoint() based on the BarsTypes' logic in OnDataPoint().

                            I am only able to see this behavior with your BarsType which is just the PointAndFigureBarsType. I will continue to test further and follow up with you when I have any details.

                            Comment


                              #15
                              Hello hansob3,

                              Thank you for your patience.

                              This occurs when the tick has the same price level for the last tick of the bar and the tick of the new bar. AddBar triggers the OnBarUpdate call and we known that OnMarketData will be called after OnBarUpdate. The behavior you are seeing is expected and in the proper sequence.

                              Please let me know if you have any questions.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by BarzTrading, Today, 07:25 AM
                              2 responses
                              26 views
                              1 like
                              Last Post BarzTrading  
                              Started by devatechnologies, 04-14-2024, 02:58 PM
                              3 responses
                              20 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Started by tkaboris, Today, 08:01 AM
                              0 responses
                              6 views
                              0 likes
                              Last Post tkaboris  
                              Started by EB Worx, 04-04-2023, 02:34 AM
                              7 responses
                              163 views
                              0 likes
                              Last Post VFI26
                              by VFI26
                               
                              Started by Mizzouman1, Today, 07:35 AM
                              1 response
                              11 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Working...
                              X