Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trading on level 2 values

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

    #61
    ok, so, I add the add(minute 3),

    and using a command like Closes[1][0]it in onmarketDept(), will generete a , 3 minute bar series, each time its called? , and then when onmarketDepth() is called again, 1/20 of a second after, using Close[1][0] will be representative of that new series?

    so the first time the on market depth is called, lets say at 7h30m12s16millisecond, it will create 3 min bars from that time : so
    Closes[1][0] will be from 7h27m12s16millisecond to 7h30m12s16millisecond
    Closes[1][1] will be from 7h24m12s16millisecond to 7h27m12s16millisecond
    and so on,

    then I get a new update in onmarketdepth() at 7h30m12s24millisecond
    and then calling/using
    Closes[1][0] will be from 7h27m12s24millisecond to 7h30m12s24millisecond
    Closes[1][1] will be from 7h24m12s24millisecond to 7h27m12s24millisecond
    and so on,

    is that correct?

    this is what I want. - dont worry about on bar update - it wont be used.all will be done in onmarketdepth()


    thanks

    Comment


      #62
      Hello chancehero,
      NinjaTrader stamps a bar with the closing time of the bar. also the lowest granularity for any bar series is seconds and you cannot compare millisecondss.

      Thus Closes[1][1] will be say 9:27:00, Closes[1][0] will be 9:30:00 etc etc

      If you want to compare any higher granularity then you have to custom code your own code.
      JoydeepNinjaTrader Customer Service

      Comment


        #63
        ok,

        even if it was in minutes, would it do what I said:

        so the first time the on market depth is called, lets say at 7h30m, it will create 3 min bars from that time : so
        Closes[1][0] will be from 7h27m to 7h30m
        Closes[1][1] will be from 7h24m to 7h27m
        and so on,

        then I get a new update in onmarketdepth() at 7h31m
        and then calling/using
        Closes[1][0] will be from 7h28m to 7h31m
        Closes[1][1] will be from 7h25m to 7h28m
        and so on, ????

        is that correct?

        1) I simply want to understand the logic of the Add and Closes , which is still unclear throughout our discussion.
        2) what I was thinking about was to use private DataSeries xxxx; and save the values at each update and create my bar data as I pleased.

        thanks

        Comment


          #64
          Hello chancehero,
          The time wont change.
          For example if the bar time is 9:27:00 9:30:00 then at 9:31 you wont have a bar time like 9:28. It will be 9:27, 9:30, 9:33 etc etc.

          A custom data series will refer to a bar series (primary or otherwise). You may have to create your own list/array etc for storing the values.
          JoydeepNinjaTrader Customer Service

          Comment


            #65
            perfect !
            thats exactly what I wanted to know !

            thanks

            Comment


              #66
              question:

              have been wondering, any already made code by you guys that would allow me to record raw lvl 2 data?

              Comment


                #67
                Hello chancehero,
                Thanks for your note.

                You may refer to these sample code which is on similar lines.



                To write to an external file you can use the stramwriter class. Please review this sample code to know more
                JoydeepNinjaTrader Customer Service

                Comment


                  #68
                  hi thanks for the vode but I have this stuff already.

                  question:

                  1) when im in
                  PHP Code:
                      protected override void OnMarketData(MarketDataEventArgs e) { 
                  
                  and ask for
                  PHP Code:
                  Print("--------------------------");
                              Print(e.Price +"  "+ e.MarketData.Ask +"  "+ e.MarketData.Bid);
                              Print(e.MarketData.ToString());
                              Print(e.Price +"  "+ e.Volume ); 
                  
                  I get :
                  1505 Instrument='ES 03-13 Globex' Type=Ask Price=1505.25 Volume=8 Time=2/6/2013 8:40:47 AM Instrument='ES 03-13 Globex' Type=Bid Price=1505 Volume=523 Time=2/6/2013 8:40:47 AM
                  NinjaTrader.Data.MarketData
                  1505 523
                  02/06/2013 08:40:47.941 AM- tick update - 2 - on market data - bar 0: open 1505.25 close: 1505.00 low: 1505.00 high: 1505.50 volume: 0008828.00 present volume 0523.00 time: 0006.00
                  --------------------------
                  0 Instrument='ES 03-13 Globex' Type=Ask Price=1505.25 Volume=8 Time=2/6/2013 8:40:47 AM Instrument='ES 03-13 Globex' Type=Bid Price=1505 Volume=523 Time=2/6/2013 8:40:47 AM
                  NinjaTrader.Data.MarketData
                  0 195942
                  02/06/2013 08:40:47.941 AM- tick update - 2 - on market data - bar 0: open 1505.25 close: 1505.00 low: 1505.00 high: 1505.50 volume: 0008828.00 present volume 195942.00 time: 0006.00
                  --------------------------
                  1505.25 Instrument='ES 03-13 Globex' Type=Ask Price=1505.25 Volume=8 Time=2/6/2013 8:40:47 AM Instrument='ES 03-13 Globex' Type=Bid Price=1505 Volume=523 Time=2/6/2013 8:40:47 AM
                  NinjaTrader.Data.MarketData
                  1505.25 20
                  02/06/2013 08:40:47.941 AM- tick update - 2 - on market data - bar 0: open 1505.25 close: 1505.25 low: 1505.00 high: 1505.50 volume: 0008848.00 present volume 0020.00 time: 0006.00



                  NOTICE that just before someone acutally buys a contract at the ask or bid, the price drops to 0, and the volume to some crazy level.

                  got any explanation for this?

                  I know that when I call e.Volume and just print , I get the ask or bid colume that is changing. but when something gets purchased or sold, it gives me the transacted volume. but a price of 0 and some crazy volume just before, how do I deal with this ???

                  Comment


                    #69
                    ch,

                    Can you remind me which data provider you're seeing this on?
                    MatthewNinjaTrader Product Management

                    Comment


                      #70
                      patsystems

                      Comment


                        #71
                        Thanks, I was able to reproduce.

                        This is actually a result of the Market Data Type DailyVolume being updated, which is calling OnMarketData. At this time, there is no e.Price, so it comes back as 0.

                        If you run the following:

                        Code:
                        Print("--------------------------"); 
                        Print("DataType : " + e.MarketDataType);
                        Print("Bid : " +e.MarketData.Bid);
                        Print("Ask : " + e.MarketData.Ask);
                        Print("Price : " + e.Price);
                        Print("Volume : " +e.Volume);
                        Print("DailyVolume : " + e.MarketData.DailyVolume);
                        Print("sender : " + e.Sender);
                        Print("Time : " + e.Time);
                        It will result in the following:

                        DataType : DailyVolume
                        Bid : Instrument='ES 03-13 Globex' Type=Bid Price=1505.5 Volume=1124 Time=2/6/2013 1:25:05 PM
                        Ask : Instrument='ES 03-13 Globex' Type=Ask Price=1505.75 Volume=837 Time=2/6/2013 1:25:05 PM
                        Price : 0
                        Volume : 1508183
                        DailyVolume : Instrument='ES 03-13 Globex' Type=DailyVolume Price=0 Volume=1508183 Time=2/6/2013 1:25:05 PM
                        sender : NinjaTrader.Data.MarketData
                        Time : 2/6/2013 1:25:05 PM
                        You may consider asking your script to ignore calls DailyVolume or any other data type you wish to exclude:

                        if(e.MarketDataType == MarketDataType.DailyVolume) return;
                        Last edited by NinjaTrader_Matthew; 02-06-2013, 02:41 PM.
                        MatthewNinjaTrader Product Management

                        Comment


                          #72
                          thanks for the clarification.

                          next clarifying question: after that daily volume goes (what you just explained) - and I get a 0 for price, then the next spit out update , the volume will be the actual transacted volume - and the price at which it was sold - ans not the ask or bid volume . reported in the
                          e.MarketData.Ask or MarketData.Bid ....

                          whats the deal with that? very annoying to write code to split all this data coming from this stuff. any way / easy way that I can obtain this actual transacted quantity up front instead of writing a bunch of if commands when I et a price of 0?, that the next e.Volume will be the transacted quantity. ? let me know if im unclear

                          Comment


                            #73
                            figured it out. - thanks for the clarification

                            so If I want to build my own bars,

                            I get code to build it (not sharing ) OCHL, and

                            and to update my bar I can simply place a

                            PHP Code:
                            protected override void OnMarketData(MarketDataEventArgs e) {
                                 if(e.MarketDataType == MarketDataType.Last){
                            dbar.addTick(e.Price, e.Volume);
                                }
                            } 
                            
                            where the price and volume SHOULD BE the traded price and volume ?

                            and them if I want to record my lvl two book, I can simply use the same idea , and read the e.MarketDataType and properly arrange the incoming data.

                            thanks. If im wrong let me know !

                            Comment


                              #74
                              time

                              hi again,

                              question:
                              I want to save my data, and right now, I have created my simply collected of data to go into 1 file and simply dump it there.


                              PHP Code:
                              using System.IO;    // Used to write text files 
                              
                              PHP Code:
                              #region Variables
                              private string log_file_OCHL = "f://OCHL//" + DateTime.Now.ToString("dMMMyyyy") + "/data_OCHL.txt"; 
                              private bool create_file=false; 
                              
                              and in
                              PHP Code:
                              protected override void OnMarketData(MarketDataEventArgs e) {
                                          //==============================================================================================
                                          // create file directory
                                          if (create_file==false){
                                                 string activeDir = @"f:\OCHL";
                                              string newPath = System.IO.Path.Combine(activeDir,  DateTime.Now.ToString("dMMMyyyy") );
                                              System.IO.Directory.CreateDirectory(newPath);
                                              create_file=true;
                                          }
                              
                              // when I get a update 
                              string data =  DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt") + "- bar 0 : OCHL - O :"  +   bar_0_O.ToString("0000.00") + " C : " +bar_0_C.ToString("0000.00")  + " H : " +bar_0_H.ToString("0000.00")  + " L : " +bar_0_L.ToString("0000.00")       + " v : " +bar_0_v.ToString("0000000")      + " time: " +bar_0_span.ToString("0000") +   Environment.NewLine ;
                                          File.AppendAllText(log_file_OCHL,data ); 
                              

                              but I want to change it so that at 7 pm Atlantic time , it create a new folder for the next day and places the data in there, then at 10 h30 atlantic, it creates a new file until 18h45 .

                              got any type of simply way for me to do this?

                              thanks

                              Comment


                                #75
                                hi,

                                so this is weird/annoying.

                                1) onmarketdata will give me the lvl1 data which I need to see what is being sold and how much.
                                2) onmarketdepth will give me the lvl2 book 0 but not the sale price and volume

                                -any easy way to record both of these in 1 entry so I can have a lvl2 book and see how much is being sold and at the ask or bid?

                                thanks

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                599 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                344 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                103 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                558 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                557 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X