Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

order flow transition to live

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

    order flow transition to live

    Some help me with fixing the values of my custom order flow. It has no problem with historical bars but when it tries to transition to realtime bars it does have a difference. The first chart is correct and the second is wrong.
    Attached Files

    #2

    Hello luxurious_04,

    Is there a specific part of your logic that you wanted help with?

    From the given details I can understand that you created some type of custom order flow and have rendered it to the chart. I understand the problem relates to how your logic is working between historical and realtime. Beyond that there are not enough details present for me to understand why that may happen or what that may relate to in your logic.

    If you have a specific part of your code which you have determined is working differently we could start by looking at that to better understand why that's different. You may otherwise need to make a simple version of the problem in a new script to test this.

    I look forward to being of further assistance.

    Comment


      #3
      Below is the main logic of the recording. I am using Tick Replay.

      protected override void OnMarketData(MarketDataEventArgs e)
      {
      if(CurrentBars[0] < 0 || e.MarketDataType != MarketDataType.Last)
      return;
      if(e.Price >= e.Ask)
      {
      //record for ask price and volume
      }
      else if(e.Price <= e.Bid)
      {
      //record for bidprice and volume
      }
      }

      Comment


        #4
        Hello luxurious_04,

        That does appear to be what we suggest in the help guide in regard to working with historical tick replay data. Do you have an additional set of logic for working in realtime OnMarketData events?

        The way the tick replay uses Last events and e.Price would only be helpful for specifically tick replay data. You would otherwise need to develop a second set of logic for realtime processing as that would work differently than tick replay.


        There are some samples of working with ask/bid in the OnMarketData help guide page: https://ninjatrader.com/support/help...b=onmarketdata

        There is an additional sample that shows determining if you are using tick replay: https://ninjatrader.com/support/help...tsub=istickrep



        I look forward to being of further assistance.

        Comment


          #5
          Does OnMarketData freeze while the state is in the transition from historical to realtime? I just want to confirm it, if it does then how can process the tick data or events while the indicator is in the state of transition from historical to realtime?
          Last edited by luxurious_04; 09-01-2020, 09:26 AM.

          Comment


            #6
            Hello luxurious_04,

            That should be correct as there is no data coming in at that point, the state is specifically defined as: Transition is called once as the object has finished processing historical data but before it starts to process realtime data.

            OnMarketData would only be called for market data events, there should be no data during transition it would be either historical with tick replay or it would not be historical and would be realtime.

            I look forward to being of further assistance.

            Comment


              #7
              I tried adding some printing on the of OnDataPoint event in my custom 1-minute bar type, it will print after my indicator signals the transition state:

              My indicator prints OnMarketData events from historical then transition:

              9/1/2020 4:58:44 AM, OnMarketData : Historical
              **************************************** state: Transition, bar: 404, close: 6581 ********************************

              ***** this print outs came from my custom 1 minute dataseries or chart that I used while the state is in transition *****

              9/1/2020 4:58:50 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505, bid: 3504.75, volume: 2
              9/1/2020 4:58:50 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505, bid: 3504.75, volume: 1
              9/1/2020 4:58:50 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505, bid: 3504.75, volume: 1
              9/1/2020 4:58:50 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505, bid: 3504.75, volume: 1
              9/1/2020 4:58:50 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505, bid: 3504.75, volume: 1
              9/1/2020 4:58:50 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505, bid: 3504.75, volume: 1
              9/1/2020 4:58:50 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505, bid: 3504.75, volume: 1
              9/1/2020 4:58:50 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505, bid: 3504.75, volume: 1
              9/1/2020 4:58:50 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505, bid: 3504.75, volume: 2
              9/1/2020 4:58:50 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505, bid: 3504.75, volume: 1
              9/1/2020 4:58:50 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505, bid: 3504.75, volume: 2
              9/1/2020 4:58:50 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505, bid: 3504.75, volume: 1
              9/1/2020 4:58:50 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505, bid: 3504.75, volume: 1
              9/1/2020 4:58:50 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505, bid: 3504.75, volume: 1
              9/1/2020 4:58:50 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505, bid: 3504.75, volume: 1
              9/1/2020 4:58:50 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505.25, bid: 3505, volume: 1
              9/1/2020 4:58:50 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505.25, bid: 3505, volume: 1
              9/1/2020 4:58:59 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505, bid: 3504.75, volume: 2
              9/1/2020 4:59:00 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505, bid: 3504.75, volume: 1
              9/1/2020 4:59:00 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505, bid: 3504.75, volume: 1
              9/1/2020 4:59:01 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505, bid: 3504.75, volume: 1
              9/1/2020 4:59:01 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505, bid: 3504.75, volume: 1
              9/1/2020 4:59:01 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505, bid: 3504.75, volume: 2
              9/1/2020 4:59:01 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505, bid: 3504.75, volume: 1
              9/1/2020 4:59:02 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505, bid: 3504.75, volume: 1
              9/1/2020 4:59:02 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505, bid: 3504.75, volume: 1
              9/1/2020 4:59:02 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505, bid: 3504.75, volume: 2
              9/1/2020 4:59:02 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505, bid: 3504.75, volume: 1
              9/1/2020 4:59:02 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505, bid: 3504.75, volume: 1
              9/1/2020 4:59:02 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505, bid: 3504.75, volume: 1
              9/1/2020 4:59:02 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505, bid: 3504.75, volume: 1
              9/1/2020 4:59:02 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505, bid: 3504.75, volume: 1
              9/1/2020 4:59:02 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505, bid: 3504.75, volume: 1
              9/1/2020 4:59:02 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505, bid: 3504.75, volume: 2
              9/1/2020 4:59:02 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505, bid: 3504.75, volume: 1
              9/1/2020 4:59:04 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505.25, bid: 3505, volume: 6
              9/1/2020 4:59:04 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505.25, bid: 3505, volume: 1
              9/1/2020 4:59:04 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505.25, bid: 3505, volume: 1
              9/1/2020 4:59:04 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505.25, bid: 3505, volume: 1
              9/1/2020 4:59:04 AM, ************************ 2. bars.Count: 405, close: 3505, ask: 3505.25, bid: 3505, volume: 1
              9/1/2020 4:59:06 AM, ************************ 2. bars.Count: 405, close: 3504.75, ask: 3505, bid: 3504.75, volume: 1
              9/1/2020 4:59:06 AM, ************************ 2. bars.Count: 405, close: 3504.75, ask: 3505, bid: 3504.75, volume: 1
              9/1/2020 4:59:06 AM, ************************ 2. bars.Count: 405, close: 3504.75, ask: 3505, bid: 3504.75, volume: 1
              9/1/2020 4:59:06 AM, ************************ 2. bars.Count: 405, close: 3504.75, ask: 3505, bid: 3504.75, volume: 1

              ***** my indicator now process the OnMarketData
              9/1/2020 4:59:06 AM, OnMarketData : Realtime

              The bar-type process some data while in transition I think. I am missing a couple of volumes because the indicator OnMarketData doesn't process while it is in the transition state.

              Comment


                #8
                I mean the last data event time of the indicator is

                9/1/2020 4:58:44 AM, OnMarketData : Historical

                then OnMarketData process again at:

                9/1/2020 4:59:06 AM, OnMarketData : Realtime

                So from that time, the bar-type has data events but the indicator doesn't have. What I am trying to say is that there's a gap of data events. How can I eliminate that gap?

                Comment


                  #9
                  Hello luxurious_04,

                  Without more details on the code you used for the print and test I couldn't really provide any insight here. My prior comment was specifically for the indicator question that you had, there may be other factors when comparing two types like a BarsType and indicator.

                  I look forward to being of further assistance.

                  Comment


                    #10
                    Where can I send the file?

                    Comment


                      #11
                      All I want is how can I get the tick data when the indicator is in transition since OnMarketData freeze at that state. When I plot the indicator in the chart and it process historical data if it consumes to much time then there's a tick data gap when it transitions to real-time data. I want to know how can I get those tick data.

                      Comment


                        #12
                        Hello luxurious_04,

                        You can post the sample here if you have a small sample that shows what you are describing. I would not be able to debug your larger script however we can take a look at a small extracted sample of what you are printing. To go off of something that already exists you can just duplicate the standard minute bars and add the print in that. If your indicator is complicated you can extract the print and place that in a new empty indicator so it is used in the same way.

                        I look forward to being of further assistance.

                        Comment


                          #13
                          Ok, I have attached it.
                          Attached Files

                          Comment


                            #14
                            Hello luxurious_04,

                            This seems to be the indicator, you said that you were doing a comparison against a bars type. Do you have a sample of that as well? The indicator appears to have your existing logic in it, I would suggest for the BarsType to simply duplicate the minute bars type and add the print to that. If you then see the same issue we can be sure that it is not related to anything else you are doing.

                            I Look forward to being of further assistance.

                            Comment


                              #15
                              It's a very simple bar type, it is the minute bar type and I only added print outs when it adds, update the bar data points.
                              Attached Files

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              656 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              371 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              109 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              574 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              579 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X