# Problems with Conditional Orders and Wealth-Lab 4

**URL:** <https://forums.collective2.com/t/problems-with-conditional-orders-and-wealth-lab-4/1164>\
**Category:** C2 Software Development\
**Created:** [March 6, 2009, 11:23am UTC](https://forums.collective2.com/t/problems-with-conditional-orders-and-wealth-lab-4/1164 "2009-03-06T11:23:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![CliffFiess](https://avatars.discourse-cdn.com/v4/letter/c/7993a0/32.png) [@CliffFiess](https://forums.collective2.com/u/CliffFiess)\
**Post date:** [March 6, 2009, 11:23am UTC](https://forums.collective2.com/t/problems-with-conditional-orders-and-wealth-lab-4/1164/1 "2009-03-06T11:23:54Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![MatthewKlein](https://yyz2.discourse-cdn.com/flex028/user_avatar/forums.collective2.com/matthewklein/32/21382_2.png) [@MatthewKlein](https://forums.collective2.com/u/MatthewKlein)\
**Post date:** [March 6, 2009, 1:16pm UTC](https://forums.collective2.com/t/problems-with-conditional-orders-and-wealth-lab-4/1164/2 "2009-03-06T13:16:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![BobSvan2](https://yyz2.discourse-cdn.com/flex028/user_avatar/forums.collective2.com/bobsvan2/32/21391_2.png) [@BobSvan2](https://forums.collective2.com/u/BobSvan2)\
**Post date:** [March 6, 2009, 2:51pm UTC](https://forums.collective2.com/t/problems-with-conditional-orders-and-wealth-lab-4/1164/3 "2009-03-06T14:51:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![CliffFiess](https://avatars.discourse-cdn.com/v4/letter/c/7993a0/32.png) [@CliffFiess](https://forums.collective2.com/u/CliffFiess)\
**Post date:** [March 6, 2009, 3:18pm UTC](https://forums.collective2.com/t/problems-with-conditional-orders-and-wealth-lab-4/1164/4 "2009-03-06T15:18:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![CliffFiess](https://avatars.discourse-cdn.com/v4/letter/c/7993a0/32.png) [@CliffFiess](https://forums.collective2.com/u/CliffFiess)\
**Post date:** [March 6, 2009, 4:05pm UTC](https://forums.collective2.com/t/problems-with-conditional-orders-and-wealth-lab-4/1164/5 "2009-03-06T16:05:52Z")

</div>

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
