I have been able to write code to place BTO orders via the Signal API. For some reason I haven’t been able to enter conditional stop losses. I am using Wealth-Lab 4 and the relevant code is:
var u01, s, id: string;
var IE: ComVariant;
IE := CreateOleObject(‘InternetExplorer.Application’);
IE.Visible := true;
u01 := ‘http://www.collective2.com/cgi-perl/signal.mpl?cmd=signal&systemid=xxxxx744&pw=xxxxxxx&instrument=stock’;
ie.navigate(u01+’&action=BTO&quant=’+floattostr(qty)+’&symbol=’+getsymbol+’&limit=’+floattostr(entry)+’&duration=DAY’);
while IE.ReadyState <> 4 do Sleep(10);
s := IE.Document.DocumentElement.OuterHtml;
id := gettoken(s, 3, ’ ‘);
ie.navigate(u01+’&action=STC&quant=’+floattostr(qty)+’&symbol=’+getsymbol+’&stop=’+floattostr(stoploss)+’&duration=DAY&conditionalupon=’+id);
while IE.ReadyState <> 4 do Sleep(10);
The BTO order is placed, but the conditional STC gives me the error message: error Can’t enter STC - Not currently long
Does anyone know what I am doing wrong? Thanks very much for any help.
Cliff: Email me the actual system id so I can examine the server logs and see what happened. I’ll post the answer here for the benefit of others.
I tried it and it works fine.
Because I have not your "gettoken" function, I filled "id" by hand by SignalId returned from Collective2.
It was nice to return to Delphi after long time again
Good Luck!
Bob
It’s interesting that it works for you. I’m pretty sure my “ID” is correct, because I have tried it with the following code:
id := gettoken(s, 3, ’ ');
id := trim(id); // in case there are leading or trailing blanks
addcommentary(id);
When I checked the commentary, the “ID” was there.
Thanks for the reply.
Matthew,
I may have found my problem. I hope you haven’t wasted too much time on this. I turns out that the addcommentary command accepts html. It displayed the id number, but it was really, “<SIGNALID>39095806</SIGNALID>”. I need to do a little more work to extract the ID.
Thanks,
Cliff