Linking Excel and .NET application

Discussion in 'Trading Software' started by RedDuke, Jan 23, 2008.

  1. RedDuke

    RedDuke

    Hello,

    Does anyone know how to link excel cell into .net application? I am using Ninja Trader and need to link one excel cell (the value changes in real time) into its indicator. I was told that it can be done since Ninja indicators are written in .NET framework, but I can not figure out how to do it. I tried googling it, but without success.

    Thanks,
    redduke
     
  2. RedDuke

    RedDuke

    Can anyone help with this?

    Thanks
     
  3. RedDuke

    RedDuke

    Hi KarateChop,

    Thanks for the link. The demo does things a bit diferent than what I need to do.

    I also had one of elitetrader members sending me .net program that does the trick, but I am having difficult time migrating it to Ninja Script so far.

    Regards,
    redduke
     
  4. RedDuke

    RedDuke

    With a help of a fellow ET member I was able to develop an indicator that will read dynamic excel content (by dynamic I mean it can be changed real time, and it does not have to be saved). There 2 glitches (will discuss below) currently, but it is working for the most part.

    In order to compile attached code (remove .txt extension) you would need to create as assembly reference to System.Data.dll. Once you upload indicator, right click within indicator editor and go to References and click on Add. Navigate to C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322 and choose System.Data.dll.

    The indicator is developed to extract value of cell A1 from Sheet2 for Ninja 6.5 version. It is triggered when a trade goes through and its volume is greater than 50 (you can add your own conditions). I perform all my calculation in Sheet1 (based on real time input from X-trader market data) and then link results to cell A1 of Sheet2. You want to keep as little data within selected Sheet as possible for performance reasons, but it does not have to be 1 cell if you need more obviously. Once value is extracted it is displayed within Output Window. This indicator has the least code that is required to get the data, you can add as much of your own as needed. I also added commented through out code to help with understanding of what is going on.

    Now the glitches:

    1) After some time (it is random), you will get Excel popup saying “that you trying to open an existing file and all data will be lost”. All you need to do is just say No. However until you do it your Ninja chart will be frozen. This used to happened much more frequently until I added code to call Garbage Collected after every 5 trades and closing/reopening connection after every 10 trades. This helped tremendously, but did not solve issue entirely. I usually get about 2 popups every hour.
    2) I think it is related to 1. Once I try to disconnect, Ninja freezes and I have to close it via Task Manager. I have also seen similar freeze when I tried to place sim trade via DOM. So, it is Ok to use for charting purpose only for now.

    If anyone has any insight on how these issues please reply.

    Regards,
    redduke