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

OnMarketDepth method

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

    OnMarketDepth method

    Hello,

    I use OnMarketDepth method to build price ladder the same way like it is done for "SampleLevel2Book" Next, price ladder I use to create indicator which shows me some bar values in seperate window. I know that OnMarketDepth is a real-time data stream but is there any way to keep values which I get from price ladder? When I change timeframe all outputs which I collect disapear and my indicator is buit from the beginning based on real-time data stream.

    I would be glad for any help.


    #2
    Hello kanarkia,

    Thank you for the post.

    The script would need to save "slices" of the level 2 data. A good data structure for this would be the Dictionary structure because it takes two types for the key/value. Your key could be a DateTime object and the values could be a level 2 "slice" or image for that time.

    Please let me know if you have any questions.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hello,

      It makes sense. Thanks for that. One question more. Is there any method to keep it saved and available always when Ninjatrader starts?

      Comment


        #4
        Hello kanarkia,

        Thanks for the reply.

        There are no methods in NinjaTrader that allow for storing indicator values. One would need to store the data in a text file, XML file, or an SQL DB and retrieve the data when the script starts up.

        Please let me know if I can assist further.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Hello ChrisL,

          Thanks for the replay.

          Would you suggest the best and the easiest way to do that? Any example which I can relay on?

          Cheers

          kanarkia

          Comment


            #6
            Hello kanarkia,

            Thanks for the reply.

            This project would take some advanced C# concepts such as data organization and serializing a complex data structure to a file for storage. It might even take some Asynchronous programming as to not hang up NinjaTrader's processing.

            I modified the SampleLevel2 book a bit by adding in memory slice storage. As a disclaimer, this sample is not complete and not considering many things such as:

            1. Loading the previously gathered historical data from a txt, JSON, or some other kind of file while in the historical mode.
            2. When/how to write the collected data to a file and clear out the Dictionaries memory.
            3. How often we should gather this data.
            4. Since I was getting duplicate keys for the DateTime key, I needed to append a GUID to each DateTime key to keep them unique, this could lead to us needing to consider how to access the data we need properly, possibly even consider a different key for the structure altogether.

            Please let me know if you have any questions.



            Attached Files
            Chris L.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by BarzTrading, Today, 07:25 AM
            2 responses
            17 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
            4 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
            10 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Working...
            X