PDA

View Full Version : NinjaTrader DDE Connection


bukkan
05-08-2010, 09:26 AM
hi folks,
I have made a small script which enables NinjaTrader to act as a DDE server. Thus data can be sent from NinjaTrader to any client application, say like Excel.

I have used an open source dde library namely Ndde (http://ndde.codeplex.com/) to make the Dde connection.

Its completely free including the code which can be found at

http://www.volumedigger.com//NinjaTrader/Miscellaneous/NinjaTrader_DDE.aspx

the script can be further improved so looking for the communities participation.

cheers..

DISCLAIMER:
USE THE SCRIPT ENTIRELY AT YOUR OWN RISK. I AM NOT RESPONSIBLE FOR ANY DAMAGES WHATSOEVER.

NinjaTrader_Ben
05-08-2010, 12:05 PM
Thanks for contributing!

bukkan
05-08-2010, 01:42 PM
thanks Ben.

m_h_chen
10-27-2010, 08:28 AM
Can someone provide info regarding feeding data to NinjaTrader via DDE? Many thanks

Vincent

NinjaTrader_RyanM
10-27-2010, 08:39 AM
Hello Vincent,

Welcome to the NinjaTrader forums!

We don't support DDE directly but you may get some ideas from the original post in this thread.

You can use the dll interface (http://www.ninjatrader.com/support/helpGuides/nt7/dll_based_integration.htm) to drive data into NinjaTrader. More information on this is available here:
http://www.ninjatrader.com/support/helpGuides/nt7/external_data_feed_connection.htm

m_h_chen
10-27-2010, 08:42 AM
Thanks a lot for information provided, will look into those links you minetioned. Thanks again

Vincent

Ninja DDE
02-01-2011, 09:47 PM
bukkan,

Would have info on how to set Excel as a DDE server to a blank web page (perhaps PHP, ASP, or Java scripts)? I need to run some formulas on the data from Ninja Trader using Excel, and then send the results to a blank web page which is stored on my "intranet".

http://i51.tinypic.com/jsyicn.png

bukkan
02-02-2011, 12:27 AM
I am not aware whether you could put a dde link in IE as you wanted. better you google a bit and first see whether the same is possible with IE or not.

cheers

Dervakon
02-23-2011, 03:15 PM
Hi everybody,
Do you think I can find it for the version 6.5 please

Thanks

bukkan
02-24-2011, 10:01 AM
i have not coded in 6.5 for long so pls do double check for code optimization. otherwise the attach works for NT6.5.

Dervakon
02-24-2011, 10:03 AM
Thank you I will try

Dervakon

Dervakon
02-24-2011, 10:17 AM
I try but it's not working. When I try to go on Utilities>Import ninjascript... it's said that; The NinjaScriptt achive file you wish to import was generated with a newer version of ninjaTrader...

Thanks

bukkan
02-24-2011, 10:40 AM
in my previous post i have attached the raw cs file. how can you import the same?

anyway try this.

Dervakon
02-24-2011, 10:44 AM
Thanks for your help but it's not working... It was the same error

Dervakon
02-24-2011, 10:49 AM
Hi Bukkan,
I saw my version of NinjaTrader is 6.5.0.10...but I don't know how to change it in info...

Thanks

bukkan
02-24-2011, 11:04 AM
unzip and edit the xml file. zip the whole edited stuff again, and then import the same.

Dervakon
02-24-2011, 11:17 AM
I appreciated your help very much... I try it but now it's tell my can,t find the file C:\User\JMR\Documents\NinjaTrader 6.5\bin\Custom\Tmp\Import\DDE\AdditionalReferences .txt.

I don't know what to do

Dervakon

bukkan
02-24-2011, 12:35 PM
download the latest version of NT6.5 and then import the zip file.

Dervakon
02-28-2011, 03:19 PM
Hi all ,

Do you know somebody who use the DDE from Bukkan and is OS is window 7...

Thanks

mechcow
05-03-2011, 08:12 AM
nice one.. one question tho, (it's prob possible but I jus can't get an ideal result) how do you pass many different indicators value into NinjaServer.ItemValue? For example for every level1 price change, i want to pass SMA(5), SMA(20), SMA(....1000) as well as values from custom indicators to the DDE server.
the NinjaServer.ItemValue seems to be 'flooded' with these values. the gives conflicting values on the Excel client.. thanks

bukkan
05-03-2011, 08:50 AM
can you post your code, and if possible a video of the issue you are facing. some folks have reported some issues in Win7, but i am on XP and couldnt replace the issues.

thanks

mechcow
05-04-2011, 07:12 AM
Thanks for the fast response! I'm on XP btw
i know something's wrong with my concept of the DDE server construct. Dun exactly know where. I'll use my understanding of your codes as reference.

I believe that NinjaServer.ItemValue = e.Price in the OnMarketData(MarketDataEventArgs e) block initializes the value of the server.
The part I'm not too sure is how/when I should invoke server.Advise(topic,"Command"); For your code, the condition is if (e.MarketDataType == MarketDataType.Last).

However I can't use MarketDataType if I I want an item with value SMA(3)[0], right?
I need something like

//if SMA(3) value is different from SMA(3) previous value
if (SMA(3)[0] != SMA(3)[1] && server != null)
{
NinjaServer.ItemValue = SMA(3)[0];
server.Advise(topic,"SMA3");
}
else
if (SMA(30)[0] != SMA(30)[1] && server != null)
{
NinjaServer.ItemValue = SMA(30)[0];
server.Advise(topic,"SMA30");
}
.
.
.
.
I know my concept is flawed somewhere.. because the only the first if condition has output on the client Excel, the subsequent if conditions are never captured and Excel outputs #NA

How would you pump values from indicators (not just variables of MarketDataEventArgs) to the server? or is this even possible?

Thanks

bukkan
05-04-2011, 07:31 AM
//if SMA(3) value is different from SMA(3) previous value
if (SMA(3)[0] != SMA(3)[1] && server != null)
{
NinjaServer.ItemValue = SMA(3)[0];
server.Advise(topic,"SMA3");
}
else
if (SMA(30)[0] != SMA(30)[1] && server != null)
{
NinjaServer.ItemValue = SMA(30)[0];
server.Advise(topic,"SMA30");
}



just remove the else from the code. it is due to that you are not getting the values for SMA30. otherwise it should work fine. in excel make sure item value is 'SMA3' and 'SMA30'

mechcow
05-04-2011, 08:09 AM
hmm, now, without the else there's another problem. The DDE values on the client picks up values of other items as well. So a value generated by =NJDDE|EURUSD!'SMA3' on Excel actual oscillates between the values generated by both server.Advise(topic,"SMA3") and server.Advise(topic,"SMA30"). I can see the numbers just oscillating back and forth.

Doesnt matter the logic is in OnMarketData() or OnBarUpdate()

Ever encountered something like that? Timer needed to introduce some delay?

bukkan
05-04-2011, 09:01 AM
cant say what you are doing but this (see attached) is working fine at my end.

mechcow
05-04-2011, 09:34 AM
cant say what you are doing but this (see attached) is working fine at my end.
thanks for your help! appreciate it.. all's fine when I changed the indicator setting 'Calculate On Bar Close' to true, which is what I need anyway

jojojo
08-21-2011, 09:23 AM
Does this work in vers.7,too?
Is it possible to add topics for last/bid/ask - volume ?

Thank you
Jojo

bukkan
08-21-2011, 10:37 AM
it is made for and tested on NT7 only.

yes any value will work, you have to modify the code accordingly.

jojojo
08-22-2011, 06:19 AM
Thanks first.
Unfortunately I'm not good in programming - I do not understand how to put this

" if (e.MarketDataType == MarketDataType.Bid)eVolumeBid = e.Volume;" - thing

into the right context, as far I understand there is no direct MarketDataType.Last/Ask/Bid Volume.
You have to substitute Volume with something like e.-variable ?
Maybe you can head me in the right direction.

Regs
Jojo

bukkan
08-22-2011, 12:57 PM
i didnt get you properly but the MarketDataEventArgs provides volume. like e.Volume provides the volume for the respective pricetype.

jojojo
08-23-2011, 01:18 AM
I just do not know how to code it for volume.
regs

bukkan
08-23-2011, 12:46 PM
just modify the code

NinjaServer.ItemValue = e.Price;


to

NinjaServer.ItemValue = (double)e.Volume;

jojojo
08-24-2011, 11:59 AM
if I add this in the OnMarketData method :

NinjaServer.ItemValue = (double)e.Volume;

if (e.MarketDataType == MarketDataType.Last)
{
if (showlast && server != null) server.Advise(topic,"Volume");
}

it seemes not to work for volume - only last, bid and ask are transferred

tmwff
10-27-2011, 04:59 AM
Is your ddl program also working with the latest ninja Version. I installed it, but I get an error massage that it has programming errors.
Thanks, Torsten

bukkan
10-27-2011, 09:07 AM
hello,
the indi works fine with the current release of NR.

in win7 there may be issues but its more due to administrative privilege etc. i havent investigated the same in details but overall dde is an obsolate tech and i am looking into rtd, socket etc to replace the same.

regards...

alexxx76
01-31-2012, 02:53 PM
I'm trying to plot a spread (diff between 2 instruments) and then apply an indicator to it.
I tried using indicators that will plot the spread (Spread, index, pairs), but run into a problem when I try to add another indicator to the plot. (Charts crash (big red X), indicators or other main symbol plot disappear, etc)
---------------------------------------------------------------------------------------------------------------------------------------
So I figured if we get the "spread" to NT as a symbol, applying indicators to it should work just fine.

Excel sheet captures live data from NINJAtrader, performs the calculation, and passes the result back to NT in a form of custom symbol.

I also learned that I can NOT have my live connection (CQG) and "External data" simultaneously.

anyone on this DDE thread can advise on how this may be accomplished?

Thanks