|
-
Aug 10th, 2010, 07:26 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] DDE with Amibroker
Hi Guys,
I need some help setting up DDE with a third party application. The info on the application can be found here http://www.amibroker.com/dde.html
The software amibroker shows stock market charts and says that data sent thru DDE will be recognised.
CONFIGURING DDE PLUGIN TO WORK WITH YOUR VENDOR
Various data vendors come use different DDE connection strings, here a few typical exampels will be shown.
Amibroker DDE Setup says :
Most documentation of DDE uses Excel DDE syntax which looks as follows:
=SERVER|TOPIC!ITEM
Server is a name of the DDE server such as WINROS, IQLINK, REUTER, CQGPC, MT, MTLink, etc.
Topic is the topic of DDE conversation. Depending on Data source
topic may be just the ticker symbol (like in IQFeed), or the field name (like in winros).
Item is the item of DDE conversation. Depending on data source it can be field name (like in IQFeed) or ticker symbol (like in Winros).
So DDE connection string in two most common standards look as follows:
=WINROS|LAST!MSFT
=IQLINK|MSFT!LAST
When I made an application in VB 6, whereby the form was selected as source. And I placed few text boxes. So -
-My program name is server name
-My forum is Topic
-My text box is item
Right ??
I am trying to connect to the program but have been unsuccessful so far.
My os is Win 7. If anyone can kinda advice or point out what I am doing wrong it would be great.
Thanks a lot,
Cheers,
GR
-
Aug 16th, 2010, 09:19 AM
#2
Thread Starter
Fanatic Member
Re: DDE with Amibroker
Hi Guys,
I am able to send data to amibroker using DDE now. The way is similar to excel.
For example : if i type in excel : DDE|Form1|txtopen then i see data in a particular cell.
Now simlar method is use by amibroker to communicate. But if I want to send data for multiple compaines then how can I do that ?
here form1 is hardcoded. And thats link topic. For eg for DELL i have to use DDE|DELL!txtopen and for microsoft i have to do DDEL|MSFT!txtopen . What should I do in such cases? I cannot change the linktopic just like that.
Help will be appreciated.
Thanks,
GR
-
Aug 16th, 2010, 10:56 AM
#3
Re: DDE with Amibroker
Why can't you change the link topic? Per MSDN, change LinkMode to zero first, then change linktopic. Unless the DDE server has a way of sending multiple values, you will most likely have to loop thru your ticker symbols rebuilding the linktopic, or use multiple textboxes one for each ticker? For future questions, sample code could be helpful for us to see what you are attempting/doing.
-
Aug 16th, 2010, 12:49 PM
#4
Thread Starter
Fanatic Member
Re: DDE with Amibroker
Thanks for your reply LaVolpe.
Let me elaborate and mention clearly what I am trying to do & how.
A third party product accepts data thru DDE. The product is a charting product so it accepts data for various companies thru DDE.
Now the way it accepts data is like this -
-> program name|topic|item
a standard DDE fashion.
The product says that let the topic be the name of the company so if if the topic matches name of that company, it will pump data for that company and so data for various companies can be pushed in.
I want to push data for several companies. But in VB 6 the way I send data is -> DDE|Form1!txtopen , DDE|Form1!txthigh and so on. I have 4 text boxes and they comprise data for 1 symbol/company.
Now the linktopic is form1. I know it can be changed to name of the company and that should do the job. But once you change it (at runtime) the DDE connection gets cut.
For e.g. if I set my linktopic to MSFT. then my DDE connection is - DDE|MSFT!txtopen , DDE|MSFT!txtclose so on. Good if I am only sending data for MSFT. But if I want to send data for DELL after I do for MSFT then what do I do ?
If I set linkmode to 0 and change linktopic then the DDE connection gets cut. Thats the issue.
Conclusion is the link topic is a hinderance and is not allowing me to send data for multiple symbols.
How can I solve this ?
Help will be appreciated.
GR
-
Aug 16th, 2010, 12:56 PM
#5
Re: DDE with Amibroker
After changing LinkTopic, you should then reset the LinkMode per MSDN instructions in the link I gave you.
1) Set LinkMode=0
2) Change LinkTopic
3) reset LinkMode=1,2, or 3 to establish new connection
-
Aug 16th, 2010, 02:02 PM
#6
Thread Starter
Fanatic Member
Re: DDE with Amibroker
 Originally Posted by LaVolpe
After changing LinkTopic, you should then reset the LinkMode per MSDN instructions in the link I gave you.
1) Set LinkMode=0
2) Change LinkTopic
3) reset LinkMode=1,2, or 3 to establish new connection
Are you talking about the linktopic of form or controls. Changing the form's link topic either gives an error at runtime or drops the DDE connection.
-
Aug 16th, 2010, 03:00 PM
#7
Re: DDE with Amibroker
 Originally Posted by greatchap
Are you talking about the linktopic of form or controls. Changing the form's link topic either gives an error at runtime or drops the DDE connection.
The textboxes. Changing the link topic will abort the connection.
The following (if I read your connection string correctly), should automatically update Text1 with Microsoft's Last quote whenever it is sent by the source/server.
Code:
Text1.LinkMode = vbLinkNone
Text1.LinkTopic = "DDE|MSFT" ' modify as needed & maybe via code
Text1.LinkItem = "LAST" ' only needs to be set once if always reflects ticker's LAST field
On Error Resume Next
Text1.LinkMode = vbLinkAutomatic
If Err Then
MsgBox Err.Description
End If
The following (if allowed) can update the Text1 DDE target field with value in Text2. Example only
Code:
Text2.LinkMode = vbLinkNone
Text2.LinkTopic = Text1.LinkTopic
Text2.LinkItem = Text1.LinkItem
On Error Resume Next
Text2.LinkMode = vbLinkManual
If Err Then
MsgBox Err.Description
Else
Text2.LinkPoke
If Err Then MsgBox Err.Description
Text2.LinkMode = vbLinkNone
End If
Edited: Note about the 2nd code example above. Doing so, if successful, should force an automatic update of Text1 to be same value as Text2.
Last edited by LaVolpe; Aug 16th, 2010 at 03:38 PM.
-
Aug 17th, 2010, 02:25 AM
#8
Thread Starter
Fanatic Member
Re: DDE with Amibroker
 Originally Posted by LaVolpe
The textboxes. Changing the link topic will abort the connection.
The following (if I read your connection string correctly), should automatically update Text1 with Microsoft's Last quote whenever it is sent by the source/server.
Code:
Text1.LinkMode = vbLinkNone
Text1.LinkTopic = "DDE|MSFT" ' modify as needed & maybe via code
Text1.LinkItem = "LAST" ' only needs to be set once if always reflects ticker's LAST field
On Error Resume Next
Text1.LinkMode = vbLinkAutomatic
If Err Then
MsgBox Err.Description
End If
The following (if allowed) can update the Text1 DDE target field with value in Text2. Example only
Code:
Text2.LinkMode = vbLinkNone
Text2.LinkTopic = Text1.LinkTopic
Text2.LinkItem = Text1.LinkItem
On Error Resume Next
Text2.LinkMode = vbLinkManual
If Err Then
MsgBox Err.Description
Else
Text2.LinkPoke
If Err Then MsgBox Err.Description
Text2.LinkMode = vbLinkNone
End If
Edited: Note about the 2nd code example above. Doing so, if successful, should force an automatic update of Text1 to be same value as Text2.
Dude, I am the server. I need to send data (not receive it). Modifying the linkitem/linktopic of text boxes and changing link mode to automatic gives error that no foreign application responded to DDE. Well thats true as I am dde server and I need to send data.
-
Aug 17th, 2010, 11:16 AM
#9
Re: DDE with Amibroker
Well, one more shot & I think you should be able to adapt the following example to your needs.
I assume you want to use the same server form for multiple ticker symbols by changing the server form's LinkTopic. Unsure if it is possible, but you can create a form for each ticker, dynamically.
I. DDE Server - New project
1. On Form1, add 1 command button
2. Add new form & add 2 textboxes there. Name one of them LAST and the other BID
3. On that new form, change LinkMode property to: 1
4. Paste this code in Form1
Code:
Option Explicit
Private Sub Command1_Click() ' example loading 2 forms for 2 tickers
Dim f As Form2
Set f = New Form2
With f
f.LinkTopic = "DELL" ' client link topic
f.Last.Text = "DELL 'Last' Field" ' sample data
f.Bid.Text = "DELL 'Bid' Field" ' sample data
End With
Set f = New Form2
With f
f.LinkTopic = "MSFT" ' client link topic
f.Last.Text = "MSFT 'Last' Field" ' sample data
f.Bid.Text = "MSFT 'Bid' Field" ' sample data
End With
Command1.Enabled = False
End Sub
Private Sub Form_Load()
Command1.Caption = "Load Tickers"
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim f As Variant
For Each f In Forms
If Not f Is Me Then Unload f
Next
End Sub
II. DDE Client
1. New project, add 2 textboxes and 2 command button. Leave all default named
2. Add this code to the form
Code:
Option Explicit
Private Sub Form_Load()
Command1.Caption = "MSFT"
Command2.Caption = "DELL"
End Sub
Private Sub Command1_Click()
With Text1
.LinkItem = "LAST" ' name of server's text box
.LinkTopic = "Project1|MSFT" ' rename Project1 to Server's eventual EXE name
.LinkMode = vbLinkAutomatic
End With
With Text2
.LinkItem = "BID" ' name of server's text box
.LinkTopic = Text1.LinkTopic
.LinkMode = vbLinkAutomatic
End With
End Sub
Private Sub Command2_Click()
Text1.LinkTopic = "Project1|DELL" ' rename Project1 to Server's eventual EXE name
Text2.LinkTopic = Text1.LinkTopic
Text1.LinkMode = vbLinkAutomatic ' changing linktopic breaks connection, re-connect
Text2.LinkMode = vbLinkAutomatic
End Sub
III. Example
1. Run the server & click the command button
2. Run the client. Click the MSFT then DELL
Last edited by LaVolpe; Aug 17th, 2010 at 11:54 AM.
-
Aug 17th, 2010, 11:24 AM
#10
Thread Starter
Fanatic Member
Re: DDE with Amibroker
 Originally Posted by LaVolpe
Well, one more shot & I think you should be able to adapt the following example to your needs.
I assume you want to use the same server form for multiple ticker symbols by changing the server form's LinkTopic. Unsure if it is possible, but you can create a form for each ticker, dynamically.
I. DDE Server - New project
1. On Form1, add 1 command button
2. Add new form & add 2 textboxes there. Name one of them LAST and the other BID
3. On that new form, change LinkMode property to: 1
4. Paste this code in Form1
Code:
Option Explicit
Private Sub Command1_Click() ' example loading 2 forms for 2 tickers
Dim f As Form2
Set f = New Form2
With f
f.LinkTopic = "DELL" ' client link topic
f.LinkMode = 1
f.Last.Text = "DELL 'Last' Field" ' sample data
f.Bid.Text = "DELL 'Bid' Field" ' sample data
End With
Set f = New Form2
With f
f.LinkTopic = "MSFT" ' client link topic
f.LinkMode = 1
f.Last.Text = "MSFT 'Last' Field" ' sample data
f.Bid.Text = "MSFT 'Bid' Field" ' sample data
End With
Command1.Enabled = False
End Sub
Private Sub Form_Load()
Command1.Caption = "Load Tickers"
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim f As Variant
For Each f In Forms
If Not f Is Me Then Unload f
Next
End Sub
II. DDE Client
1. New project, add 2 textboxes and 2 command button. Leave all default named
2. Add this code to the form
Code:
Option Explicit
Private Sub Form_Load()
Command1.Caption = "MSFT"
Command2.Caption = "DELL"
End Sub
Private Sub Command1_Click()
With Text1
.LinkItem = "LAST" ' name of server's text box
.LinkTopic = "Project1|MSFT" ' rename Project1 to Server's eventual EXE name
.LinkMode = vbLinkAutomatic
End With
With Text2
.LinkItem = "BID" ' name of server's text box
.LinkTopic = Text1.LinkTopic
.LinkMode = vbLinkAutomatic
End With
End Sub
Private Sub Command2_Click()
Text1.LinkTopic = "Project1|DELL" ' rename Project1 to Server's eventual EXE name
Text2.LinkTopic = Text1.LinkTopic
Text1.LinkMode = vbLinkAutomatic ' changing linktopic breaks connection, re-connect
Text2.LinkMode = vbLinkAutomatic
End Sub
III. Example
1. Run the server & click the command button
2. Run the client. Click the command buttons as desired
Thanks buddy for your help. Infact to be honest, I did exactly the same thing before I read your post.
I created a form and then created multiple instances of that form and set link topic at runtime. The link mode was already source so there was no problem. It's working. I appreciate your help.
Just on other note, can I loop between those normal forms (not child) thru a code. For eg in a way for each x form in totalforms. x=this form and so on.
-
Aug 17th, 2010, 11:31 AM
#11
Re: DDE with Amibroker
 Originally Posted by greatchap
Just on other note, can I loop between those normal forms (not child) thru a code. For eg in a way for each x form in totalforms. x=this form and so on.
Yes, if I understand you. Modify the sample code in the Form_Unload event I provided above (For Each)
FYI: Setting LinkMode=1 at runtime in my example was extraneous/unneeded. It was already set at design-time.
-
Aug 18th, 2010, 01:46 AM
#12
Thread Starter
Fanatic Member
Re: DDE with Amibroker
Thanks LaVolpe. My program is working fine.
Cheers.
-
Apr 28th, 2011, 09:58 AM
#13
New Member
Re: [RESOLVED] DDE with Amibroker
I'm curious.............Why didn't you use COM object instead of DDE to autofeed data in amibroker? We used to use DDE,but it doesn't feed data to Amibroker correctly...............
TC!!!
 Originally Posted by greatchap
Hi Guys,
I need some help setting up DDE with a third party application. The info on the application can be found here http://www.amibroker.com/dde.html
The software amibroker shows stock market charts and says that data sent thru DDE will be recognised.
CONFIGURING DDE PLUGIN TO WORK WITH YOUR VENDOR
Various data vendors come use different DDE connection strings, here a few typical exampels will be shown.
Amibroker DDE Setup says :
Most documentation of DDE uses Excel DDE syntax which looks as follows:
=SERVER|TOPIC!ITEM
Server is a name of the DDE server such as WINROS, IQLINK, REUTER, CQGPC, MT, MTLink, etc.
Topic is the topic of DDE conversation. Depending on Data source
topic may be just the ticker symbol (like in IQFeed), or the field name (like in winros).
Item is the item of DDE conversation. Depending on data source it can be field name (like in IQFeed) or ticker symbol (like in Winros).
So DDE connection string in two most common standards look as follows:
=WINROS|LAST!MSFT
=IQLINK|MSFT!LAST
When I made an application in VB 6, whereby the form was selected as source. And I placed few text boxes. So -
-My program name is server name
-My forum is Topic
-My text box is item
Right ??
I am trying to connect to the program but have been unsuccessful so far.
My os is Win 7. If anyone can kinda advice or point out what I am doing wrong it would be great.
Thanks a lot,
Cheers,
GR
-
May 3rd, 2011, 01:57 AM
#14
Thread Starter
Fanatic Member
Re: [RESOLVED] DDE with Amibroker
I had not idea how to proceed with COM object? In my case it seems to feed data to amibroker via dde without much problems.
-
Sep 16th, 2011, 05:59 AM
#15
New Member
Re: [RESOLVED] DDE with Amibroker
Recently I saw this thread and found it is a very useful thread. Thank you LaVolpe and GreatChap for the discussions.
I have a question here.
Somewhere I have read that the maximum number of controls that can be active on a form at any given time is 128. So for DDE with Amibroker one cannot update more than 25 symbols (taking open, high, low, close and volume - 5 data items per ticker every time) with one instance of the form running.
Is there any solution for it?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|