Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trading on level 2 values

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

    #46
    Hello chancehero,
    OnMarketData, OnMarketDepth and OnBarUpdate runs in respective thread and you should not rely on methods/functions called in one thread to compare the values returned by any other method.

    From help file:
    With NinjaTrader being multi-threaded, you should not rely on any particular sequence of events like OnMarketData() always being called before OnBarUpdate() or vice versa.
    JoydeepNinjaTrader Customer Service

    Comment


      #47
      so just stick it into OnMarketDepth()...

      ?

      still wont fix my problem of not knowing how much was sold if the quantity is the same.....

      Comment


        #48
        Hello chancehero,
        The below code in OnMarketData should give you the last traded volume.

        Code:
        protected override void OnMarketData(MarketDataEventArgs e)
        {
        	
        	if (e.MarketDataType == MarketDataType.Last)
        		Print(e.Volume);
        }
        JoydeepNinjaTrader Customer Service

        Comment


          #49
          thanks,

          but from your last post, since all my data is being generated in the OnMarketDepth() spot, using what I had originally, and what you gave me generate some possible problem?

          , even with that out of the way,

          when im calling OnMarketDepth(), it get a lot of updates, as the lvl 2 book changes, but it does not mean that a quantity was sold. but I still priint out the last sold,

          ex: 5. which gets printed continuously until a different quantity is sold, the key is that it needs to be different. which is my problem, its quite clear, that someone may sell 5 quantity and another 5 at the same price back to back and I cant tell the difference...... this is my problem,

          JP

          Comment


            #50
            Hello chancehero,
            Yes, of-course it is relative.

            I would rather check if the trade took place at bid price or ask price and then calculate accordingly.

            Please refer to the BuySellPressure or BuySellVolume indicator that comes with NinjaTrader which further demonstrates it.
            • In Control Center menu bar goto Tools>Edit NinjaScript>Indicators...
            • In the Indicators dialog please look for BuySellVolume/BuySellPressure indicators.
            JoydeepNinjaTrader Customer Service

            Comment


              #51
              got it.
              simple counter did the trick.
              PHP Code:
               if (e.MarketDataType == MarketDataType.Last) {
                              pricenow=e.Price;
                              quantitysold=e.Volume;
                          }
                          quantity_sold +=quantitysold ; 
              
              and I can see the change in price, as the events go on. which is perfect @

              Comment


                #52
                general question

                hi,
                so I just formated my computer, and didnt do a proper ninjatrader backup, but I save all the old program and the filed stored in /mydocuments . what is the name of the file or groups of files which have all my past history of trades? so that when I go in account perfomance, I can see what I did in the year.


                thanks
                JP

                Comment


                  #53
                  Hello JP,
                  The executions history is saved in the NinjaTrader.sdf file. You can locate it in the folder <My Documents>\NinjaTrader 7\db\
                  JoydeepNinjaTrader Customer Service

                  Comment


                    #54
                    Exit on close

                    hi,

                    question:

                    working on some algo, and have come up on this issue, which I imagine others have asked.

                    1) I dont want my position , stop loss limit and profit target to close or cancel.
                    1.1) I know that the stop loss and profit target will cancel themselves , but not my position

                    2) how do I restart these stop loss and profit orders , within my code when I restart ninja trader.

                    any treads discussing this?

                    thanks.
                    Last edited by chancehero; 01-17-2013, 06:49 PM.

                    Comment


                      #55
                      Hello chancehero,
                      If you do not wish the orders/position to get cancelled then please set Exit on close to false and set Time in Force to GTC (good till cancelled).

                      Also, if you are disabling the strategy then please make sure the option "Cancel exit orders when a strategy is disabled" is not checked from Tools>Options>Strategies tab> NinjaScript tab.
                      Last edited by NinjaTrader_Joydeep; 01-18-2013, 07:42 AM.
                      JoydeepNinjaTrader Customer Service

                      Comment


                        #56
                        thats it?

                        awesome !
                        will test it out .

                        thanks

                        Comment


                          #57
                          level 2 bar creation

                          hi,
                          question.

                          in onmarketdepth()
                          each time an even is created, how can I create a bar of lets say 5 min , from one even - perpetually.

                          example,
                          I need the open and close of a 5 min bar starting from a update of a event. (the open being the price at the start, and the close the price of the even that just got realized.)


                          thanks.
                          Chancehero

                          Comment


                            #58
                            Hello chancehero,
                            The easiest way is to add a secondary bar series using the Add() method.

                            Please refer to our help guide to know more about multi series concepts.
                            JoydeepNinjaTrader Customer Service

                            Comment


                              #59
                              ok,

                              let me get this straight,

                              1) in initialize(), I Add (PeriodType.Minutes,3)

                              2) then each time, OnMarketDepth() is called, I want a new series of 3 min bar data. (which is going to be very fast) - so that means that I need in 1) - to know what time to create this dataseries beforehand - which I dont know.

                              3) then, use onbarupdate() to make the trade.

                              ... it seems that Add , needs to be created for all the event that will be created in 2) - which is about 20 per second. which is going to bog down my computer. maybe there are others ways that I can achieve what I want without the Add(), ??? any ideas
                              Last edited by chancehero; 01-21-2013, 06:50 AM.

                              Comment


                                #60
                                Hello chancehero,
                                If you add a secodnary series via the Add() method using the code "Add (PeriodType.Minutes,3)" then you can simply call it from the OnMarketData event as Closes[1][0]



                                However if you try to mix OnBarUpdate and OnMarketData then please note, they run on different thread and the sequence in which they get called may not be the same.
                                With NinjaTrader being multi-threaded, you should not rely on any particular sequence of events like OnMarketData() always being called before OnBarUpdate() or vice versa.
                                JoydeepNinjaTrader Customer Service

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                629 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                362 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                105 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                564 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                568 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X