NexusFi: Find Your Edge


Home Menu

 





OHLC Data for downloading to Excel.csv


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one cclsys with 6 posts (0 thanks)
    2. looks_two sam028 with 4 posts (1 thanks)
    3. looks_3 Big Mike with 3 posts (3 thanks)
    4. looks_4 zeller4 with 1 posts (0 thanks)
    1. trending_up 15,569 views
    2. thumb_up 4 thanks given
    3. group 5 followers
    1. forum 15 posts
    2. attach_file 0 attachments




 
Search this Thread

OHLC Data for downloading to Excel.csv

  #1 (permalink)
 zeller4 
Orlando Florida
 
Experience: Intermediate
Platform: NT8
Trading: CL, NQ, ES, RTY
Posts: 477 since Jun 2009
Thanks Given: 1,416
Thanks Received: 404

Hey BigMike,

Looking for a way to download OHLC data to Excel.csv format...

Any help you can give is greatly appreciated!

Kirk

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
REcommedations for programming help
Sierra Chart
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
How to apply profiles
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
23 thanks
GFIs1 1 DAX trade per day journal
18 thanks
  #2 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,443 since Jun 2009
Thanks Given: 33,217
Thanks Received: 101,607


zeller4 View Post
Hey BigMike,

Looking for a way to download OHLC data to Excel.csv format...

Any help you can give is greatly appreciated!

Kirk

This is a text file (same as csv for Excel).

the code is just a few lines, but I will upload it to File Sharing too

 
Code
                            

        
protected override void OnBarUpdate()
        {
            
        
string logfile = @"c:\users\mike\desktop\ninja.txt";
        
        
string logprefix Time[0].Month.ToString("00") + "/" Time[0].Day.ToString("00") + "/" Time[0].Year ", " Time[0].Hour.ToString("00") + ", " Time[0].Minute.ToString("00") + ", ";
        
        
StreamWriter log;
        
log=File.AppendText(logfile);
        
        
// Date, Hour, Minute, Open, High, Low, Close
        
        
log.WriteLine(logprefix Close[0].ToString("0.00") + ", " Open[0] + ", " High[0] + ", " Low[0] + ", " Close[0]);
        
log.Close();
                        
        } 
Download it here:


Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #3 (permalink)
suprsnipes
Melbourne, Australia
 
Posts: 6 since Nov 2009
Thanks Given: 4
Thanks Received: 0


Hi Big Mike,

I have a question regarding this code. I appreciate the effort you have put into this and had no problem setting this up but I was hoping you could answer a question for me.

As the data is stored in a .txt file do you have any suggestions as to how I could access this file and use the data within Excel in real-time for further analysis?

Regards,
suprsnipes

Reply With Quote
  #4 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,443 since Jun 2009
Thanks Given: 33,217
Thanks Received: 101,607

The closest I did personally was with my MySQL project, I was writing tick-by-tick data from Ninja to my MySQL server, and then ran queries from Excel.

But it is far more complex.

You should try asking Hapster, he has a very extensive Excel spreadsheet he trades from, and I feel certain he has incorporated a live data feed.

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #5 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,629

Incorporating real-time data to Excel from NT is not really NT job, their is no good way to do this.
This is the job of the data feed itself, adding some layers (NT here) between the feed and Excel is not a good idea.
With the IB API, there is an Excel sheet, with DDE stuff, and you can have real-times quotes, position, etc, etc.

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
  #6 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,443 since Jun 2009
Thanks Given: 33,217
Thanks Received: 101,607

Aww c'mon Sam, just write a quick Zen DDE interface...

Or you could email Matt maybe @ Zen, he might have one already.. ?

Zen-Fire: Zen-Fire API

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #7 (permalink)
 
cclsys's Avatar
 cclsys 
Sydney, NS
 
Experience: Intermediate
Platform: Ninja
Broker: Zen-Fire
Trading: TF,S,GC
Posts: 605 since Nov 2009
Thanks Given: 248
Thanks Received: 393

Mike, your forum is amazing. This morning I decided to try to export data from NT into text files so I could work on coding simple patterns into TS in order to do easy P-L analysis. I find the NT strategy writing and analysis interface too hard at this point.

I just could not find a way to open any of the txt files in TS2000i which itself is tricky with that stuff. So I come on your forum and bingo, there is a solution.

BUT: I cannot get the hours to separate from the seconds. The NT way of exporting it blends date hours minutes seconds into one cell. Fine, I split it. But then it tracks minutes with seconds which TS cannot handle.

So your code is perfect. Just hours and minutes. But it separates hours and minutes which TS cannot handle. It just want 0734 for 734 am.

So I take your original line for logprefix and get rid of the comma between the hours and minutes but this is what it prints out:

10/26/2009, 00, 23, 1056.00, 1056, 1056.1, 1056, 1056

Here is the altered line from your code:
string logprefix = Time[0].Month.ToString("00") + "/" + Time[0].Day.ToString("00") + "/" + Time[0].Year + ", " + Time[0].Hour.ToString("00") + Time[0].Minute.ToString("00") + ", ";

I cannot for the life of me see why it keeps putting in the comma. I closed down strategy analyser, loaded different instrument, different strategies, then put barclose back in but still spits out the commas between hours and seconds despite the code not telling it to.

Any suggestions?
Buy a new computer to clear the cache?
Start over next week after installation of new OS?

Visit my NexusFi Trade Journal Reply With Quote
  #8 (permalink)
 bukkan 
Calcutta, India
 
Experience: Intermediate
Platform: ArthaChitra
Posts: 278 since Jun 2009
Thanks Given: 161
Thanks Received: 271


cclsys View Post
It just want 0734 for 734 am.

try Time[0].ToString("HHmm")

Reply With Quote
  #9 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,629

cclsys, your code is correct.
Did you remove the 1st .txt file generated ? (because it's an AppendText())...

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
  #10 (permalink)
 
cclsys's Avatar
 cclsys 
Sydney, NS
 
Experience: Intermediate
Platform: Ninja
Broker: Zen-Fire
Trading: TF,S,GC
Posts: 605 since Nov 2009
Thanks Given: 248
Thanks Received: 393


BM. Apologies. I didn't realise that it was only appending to existing file so in fact it was working fine.

I have spent a while looking for how to tell it to first erase all previous data before appending but can't find the lingo. Could you please tell me what to write in first to get it to flush out the earlier stuff then start again any time the strat is run?

Visit my NexusFi Trade Journal Reply With Quote




Last Updated on December 6, 2009


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts