NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > Application Technical Support > Connecting

Connecting Support for establishing connections to your broker or market data service provider.

Reply
 
Thread Tools Display Modes
Old 06-02-2010, 10:28 PM   #1
cjgovi
Junior Member
 
Join Date: Jun 2010
Posts: 3
Thanks: 0
Thanked 0 times in 0 posts
Default Data Streaming Into Excel and connecting Ninja to Excel

I have live prices flowing into an excel spreadsheet....as a tick happens it is written to excel live....

naturally i want to use ninjas awesome charting....

can i connect this column to ninja to get a chart and then if i have a few different columns representing different stocks i am watching can i connect these as well so if i have 1 column, i will have 1 chart in ninja...if i have 2 columns, i will have 2 columns in ninja etc

appreciate and thanks for you help

christian
cjgovi is offline  
Reply With Quote
Old 06-03-2010, 03:48 AM   #2
NinjaTrader_Jason
NinjaTrader Customer Service
 
NinjaTrader_Jason's Avatar
 
Join Date: Aug 2007
Location: Breda, Netherlands
Posts: 11,316
Thanks: 92
Thanked 354 times in 345 posts
Default

Hello Christian,

You can use the External Data Feed to drive NinjaTrader with data from external applications. Please see the link below for more information.
http://www.ninjatrader-support.com/H...onnection.html
NinjaTrader_Jason is offline  
Reply With Quote
Old 06-03-2010, 04:51 AM   #3
cjgovi
Junior Member
 
Join Date: Jun 2010
Posts: 3
Thanks: 0
Thanked 0 times in 0 posts
Default can you give me abit more help please

i am stuck basically at the begining

can u give me a few steps on how to get the live data from excel into ninja trader

do i have to write a program?
cjgovi is offline  
Reply With Quote
Old 06-03-2010, 05:59 AM   #4
NinjaTrader_Jason
NinjaTrader Customer Service
 
NinjaTrader_Jason's Avatar
 
Join Date: Aug 2007
Location: Breda, Netherlands
Posts: 11,316
Thanks: 92
Thanked 354 times in 345 posts
Default

Yes, you will need to use the DLL or COM interface to setup such a data connection.

Unfortunately we do not have an example listed. This functionality is targeted to users with programming experience.

If you do not have any programming experience, you can contact any of the supported NinjaScript consultants at the link below.
http://www.ninjatrader.com/webnew/pa...injaScript.htm
NinjaTrader_Jason is offline  
Reply With Quote
Old 08-07-2010, 09:02 AM   #5
mechcow
Junior Member
 
Join Date: Jun 2010
Posts: 11
Thanks: 0
Thanked 0 times in 0 posts
Default

I faced a similar problem.. but after researching, here's something to point you in the right direction. What I can do now is
1) Open excel sheet
2) read/Write data to/from NJ with Excel
I still dun know if I can have real time updates to excel, but theoretically it should be possible. Gotta wait for the markets to open

What I did ->
1. Reference Microsoft.Office.Interop.Excel.dll from the ninjaScript editor
2. insert "using Microsoft.Office.Interop.Excel;" in the topmost declaration region
3. Visit http://csharp.net-informations.com/e...open-excel.htm

You've gotta familiarize yourself with the excel apis.. the functions for worksheet/cells manipulation.. something which i've yet to do. but with the 3 points and some c# knowledge, at least you'll get the connection with NJ-excel up and running

Hope that helps
mechcow is offline  
Reply With Quote
Old 10-09-2010, 06:46 AM   #6
rkuhne
Junior Member
 
Join Date: Nov 2004
Location: B.C., Canada
Posts: 2
Thanks: 0
Thanked 0 times in 0 posts
Default any success on this?

did the code work in realtime. If so, would you care to share what you have?

Thanks in advance,

Reg
rkuhne is offline  
Reply With Quote
Old 10-09-2010, 07:17 AM   #7
bukkan
Senior Member
 
Join Date: Feb 2009
Posts: 285
Thanks: 2
Thanked 54 times in 41 posts
Default

Quote:
Originally Posted by rkuhne View Post
did the code work in realtime. If so, would you care to share what you have?

Thanks in advance,

Reg
you can try this http://www.volumedigger.com/NinjaTra...rader_DDE.aspx

this indicator will make a dde connection to excel where you can stream the data.
bukkan is offline  
Reply With Quote
Old 01-10-2011, 05:44 AM   #8
mechcow
Junior Member
 
Join Date: Jun 2010
Posts: 11
Thanks: 0
Thanked 0 times in 0 posts
Default

I dunno about pumping data into NJ from Excel, but I can provide you guys with some codes to pump data into Excel from NJ

1: remember to reference microsoft office excel interop

2:
in the Initialize() method, insert code

xlApp = new ApplicationClass();
xlWorkBook = xlApp.Workbooks.Open("C:\\spreadheet.xls", 0, false, 5, "", "", false, Microsoft.Office.Interop.Excel.XlPlatform.xlWindow s, "\t", true, true, 0, true, 1, 0);
xlWorkSheet = (Worksheet)xlWorkBook.Worksheets.get_Item(4);//edit sheet 4
xlApp.Visible = true;
misValue = System.Reflection.Missing.Value;


//this will open the spreadsheet

3:
In the OnBarUpdate() method,
simply write what data you want into a cell/worksheet , for example

xlWorkSheet.Cells[1, 1] = Close[0];
xlWorkSheet.Cells[1, 2] = GetCurrentAskVolume();
xlWorkSheet.Cells[1, 3] =GetCurrentBidVolume();

Hope this helps. Working with it realtime on ES. there's a little lag in the bid/ask sizes but the last price seems ok. IMHO this interfacing will definitely fail if your trading strategy require nanoseconds decision though, otherwise seems ok

Happy coding and trading
Last edited by mechcow; 01-10-2011 at 05:48 AM.
mechcow is offline  
Reply With Quote
Old 01-10-2011, 07:19 AM   #9
mechcow
Junior Member
 
Join Date: Jun 2010
Posts: 11
Thanks: 0
Thanked 0 times in 0 posts
Default

this is a follow up for my post below.. editting excel sheet will cause the interop to crash, there's an exception that needs to be handled here

references
http://brianseekford.com/index.php/tag/0x800ac472/
http://www.ureader.com/msg/10971604.aspx

here' what i did.. a simple try/catch in the OnBarUpdate() method. Now i can manipulate the data on the spreadsheet without any exceptions already. Hope there's no more bugs

if u come across bugs, feel free to ask. Will be glad to help since the NJ forum has been very helpful since i started using it 2 yrs ago.. cheers

try
{
xlWorkSheet.Cells[1, 1] = Close[0];
xlWorkSheet.Cells[1, 2] = GetCurrentAskVolume();
xlWorkSheet.Cells[1, 3] =GetCurrentBidVolume();
//
}
catch (Exception ex)
{
//if (ex.Message.Contains("0x800"))
if (ex.Message.Contains("0x800A03EC"))
//throw;
{
return;
//insert this code into #region (it's on the very top of script)-> using System.Threading;
Thread.Sleep(1000);//dunno if this helps in any way
}

}
mechcow is offline  
Reply With Quote
Old 01-10-2011, 07:25 AM   #10
jhall
Junior Member
 
Join Date: Jan 2011
Posts: 8
Thanks: 0
Thanked 0 times in 0 posts
Default

Wow. That looks awesome. Do you know if it will work with Excel 2010? And would I be able to update Excel with multiple symbols?
jhall is offline  
Reply With Quote
Old 01-11-2011, 03:21 AM   #11
mechcow
Junior Member
 
Join Date: Jun 2010
Posts: 11
Thanks: 0
Thanked 0 times in 0 posts
Default

hmm im not too sure abt 2010 but unless there's a change in interop code, it should work.

As for symbols, i dun see any problems, just add a new instrument in your indicator then just write those values into the spreadsheet
mechcow is offline  
Reply With Quote
Old 02-22-2011, 01:04 AM   #12
profithound
Junior Member
 
Join Date: Nov 2008
Posts: 5
Thanks: 0
Thanked 0 times in 0 posts
Default

Hey Mechow
Could you pleaase provide an example for us novice coders?

It woulod be a great help

thanx
profithound is offline  
Reply With Quote
Old 02-27-2011, 08:50 PM   #13
mechcow
Junior Member
 
Join Date: Jun 2010
Posts: 11
Thanks: 0
Thanked 0 times in 0 posts
Default

visit:
http://www.ninjatrader.com/support/f...601#post214601

DionysusToast explains it much better than me
mechcow is offline  
Reply With Quote
Old 02-28-2011, 10:21 AM   #14
Dervakon
Member
 
Join Date: Feb 2011
Posts: 48
Thanks: 10
Thanked 1 time in 1 post
Default

Hi Mechcow,

I would like to know where you put the

Thread.Sleep(1000);//dunno if this helps in any way

Thanks...
Dervakon is offline  
Reply With Quote
Reply

Tags
excel

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Data from Ninja to Excel MAX Automated Trading 1 02-09-2010 02:21 PM
Datas into Excel and then back into Ninja ? picke Connecting 1 06-11-2008 11:00 AM
Exporting data into Excel brownsfan019 Charting 3 04-23-2008 09:17 AM
Ninja Indicator and Excel RedDuke Indicator Development 7 02-12-2008 06:13 PM
Linking Ninja and Excel RedDuke General Programming 3 08-16-2007 03:16 AM


All times are GMT -6. The time now is 12:38 AM.