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

Generate day bars from real time data

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

    Generate day bars from real time data

    Hi all,

    I'm using NT7 and coded a program to import historical and real time trade data from arbitrary sources.

    In my specific case I created a new instrument and made sure that "save chart data as historical" is on. Then I downloaded the trade history from Bitstamp's API (a Bitcoin exchange), opened a new chart with my BTCUSD instrument and insert the data via the DLL interface (NinjaTrader.Client.dll) via LastPlayback(string instrument, double price, int size, string timestamp). This works with real time data.

    Everything works fine, the data is displayed and saved, but there are three problems I want to solve:

    1. NT generates and saves tick and minute data, but no day data. I know I could export the historical data and reimport it or set the time period to 1440 minutes, but I'd like to know, if there is another solution without user input.

    2. When the data for a specific timestamp already exists and I run the data import again, LastPlayback() ignores the timestamp and uses the last available historical tick timestamp. This results in the undesired outcome, that duplicates are created, but even worse: with a very wrong timestamp. Is there a way to check, if a specific data record is already present?

    3. This isn't a big deal at all, but nice to have. A single trade could look like "Amount: 0.000023 BTC, Price: 136,23 $" for example, but only integer numbers are allowed as order size. I multiplied the amount by one million, so I don't loose any data, but the volume data is now shifted. Is there a way to adjust that, i.e. tell NT that 1 volume point = 0,000001?

    Have a great day!
    Last edited by dexX7; 05-26-2013, 10:21 PM.

    #2
    Hello dexX7,

    Thank you for your post.

    1. Does the Bitstamp's API provide Daily data?

    2. How are you setting the timestamp for the LastPlayback()? Is this manually entered in the code (static value) or a variable? What determines the variable (what condition)?

    3. What methods are you using for order placement?

    I look forward to your response.

    Comment


      #3
      Originally posted by NinjaTrader_PatrickH View Post
      Hello dexX7,

      Thank you for your post.

      1. Does the Bitstamp's API provide Daily data?

      2. How are you setting the timestamp for the LastPlayback()? Is this manually entered in the code (static value) or a variable? What determines the variable (what condition)?

      3. What methods are you using for order placement?

      I look forward to your response.
      Hi Patrick!

      Well, Bitstamp provides only a simple API where a GET request returns a JSON encoded transaction history, which contains timestamp, order size and price. Furthermore you can specify how far the data should reach back.

      At the beginning, I download as much as I can and after that I just download the latest transactions.

      My "connector" downloads and parses every few seconds and forwards the data to LastPlayback(). Timestamp format is "yyyyMMddHHmmss".

      The problem is.. I have to track manually, which data already has been sent to NT, because as mentioned above, importing multiple times created very wrong data.

      Bitstamp only provides tick data, so to say, but it would be no problem to generate daily data from that, if it helps.

      Order execution is done via Bitstamp's API too and not connected to NT. As far as I know there is no simple way to do that with NT.

      Comment


        #4
        Is there a way to extend and access the external data feed, which lacks of marketdepth, bar requests and order execution or even better: I found the SampleAdapter which would be very nice for further work, but I'm not sure if there is a way to include it without changing the original dlls?

        Edit:

        What's important right now: Bitcoin can be split to 0.00000001 BTC, but NinjaTrader only accepts integer values as volume data. A workaround would be the multipliaction of the volume, but that would conflict with the max value of an integer in .NET at some point, which is 2,147,483,647. That would be 21,47 BTC. But let's say I go that route and multiply the volume data with any number and round the missing fraction, how can I tell NinjaTrader what I did?

        How do I tell NT, that 1 volume point equals 0.0001 BTC? I don't like very huge numbers shown in the volume indicator or T&S window. :/
        Last edited by dexX7; 05-28-2013, 07:21 AM.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by WHICKED, Today, 12:45 PM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by samish18, Today, 01:01 PM
        0 responses
        5 views
        0 likes
        Last Post samish18  
        Started by WHICKED, Today, 12:56 PM
        0 responses
        8 views
        0 likes
        Last Post WHICKED
        by WHICKED
         
        Started by Spiderbird, Today, 12:15 PM
        2 responses
        11 views
        0 likes
        Last Post Spiderbird  
        Started by FrazMann, Today, 11:21 AM
        2 responses
        8 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Working...
        X