![]() |
|
|||||||
| Connecting Support for establishing connections to your broker or market data service provider. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Jun 2010
Posts: 3
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Aug 2007
Location: Breda, Netherlands
Posts: 11,316
Thanks: 92
Thanked 354 times in 345 posts
|
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
Jason
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Jun 2010
Posts: 3
Thanks: 0
Thanked 0 times in 0 posts
|
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? |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Aug 2007
Location: Breda, Netherlands
Posts: 11,316
Thanks: 92
Thanked 354 times in 345 posts
|
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
Jason
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Junior Member
Join Date: Jun 2010
Posts: 11
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#6 |
|
Junior Member
Join Date: Nov 2004
Location: B.C., Canada
Posts: 2
Thanks: 0
Thanked 0 times in 0 posts
|
did the code work in realtime. If so, would you care to share what you have?
Thanks in advance, Reg |
|
|
|
|
|
#7 | |
|
Senior Member
Join Date: Feb 2009
Posts: 285
Thanks: 2
Thanked 54 times in 41 posts
|
Quote:
this indicator will make a dde connection to excel where you can stream the data. |
|
|
|
|
|
|
#8 |
|
Junior Member
Join Date: Jun 2010
Posts: 11
Thanks: 0
Thanked 0 times in 0 posts
|
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.
|
|
|
|
|
|
#9 |
|
Junior Member
Join Date: Jun 2010
Posts: 11
Thanks: 0
Thanked 0 times in 0 posts
|
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 } } |
|
|
|
|
|
#10 |
|
Junior Member
Join Date: Jan 2011
Posts: 8
Thanks: 0
Thanked 0 times in 0 posts
|
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?
|
|
|
|
|
|
#11 |
|
Junior Member
Join Date: Jun 2010
Posts: 11
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#12 |
|
Junior Member
Join Date: Nov 2008
Posts: 5
Thanks: 0
Thanked 0 times in 0 posts
|
Hey Mechow
Could you pleaase provide an example for us novice coders? It woulod be a great help thanx |
|
|
|
|
|
#13 |
|
Junior Member
Join Date: Jun 2010
Posts: 11
Thanks: 0
Thanked 0 times in 0 posts
|
visit:
http://www.ninjatrader.com/support/f...601#post214601 DionysusToast explains it much better than me
|
|
|
|
|
|
#14 |
|
Member
Join Date: Feb 2011
Posts: 48
Thanks: 10
Thanked 1 time in 1 post
|
Hi Mechcow,
I would like to know where you put the Thread.Sleep(1000);//dunno if this helps in any way Thanks... |
|
|
|
![]() |
| Tags |
| excel |
| Thread Tools | |
| Display Modes | |
|
|
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 |