Search the web
Sign In
New User? Sign Up
twslink
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Sample Wealth Lab script?   Message List  
Reply | Forward Message #529 of 538 |
Re: Sample Wealth Lab script?

here is a simple script using TWSLink (from samples dir.)
{This sample demonstrates basic Steps to place an Order}

var lib: ComVariant;
var OpResult: integer=0;
var ID_MSFT: integer=0; {Unique Contract ID}
var Count: integer=0; {set to -1 and start the script}
var EntryID: integer=-1; {Order ID}

if(Count = -1) then
begin
{load the com dll}
lib := CreateOleObject('twslink.comif');
{init the com dll}
lib.INITDLL(2, 'c:\twslinkdll_wl.log', 2, 0, 3, 4000);
{register contract}
ID_MSFT := lib.REGISTER_CONTRACT('MSFT', 'STK', 'USD',
'SMART','','','',0.0,'',0,0.0);
{connect to TWS}
OpResult := lib.CONNECT('127.0.0.1', 7496, 4, 5000);
{place new order}
EntryID := lib.PLACE_ORDER(ID_MSFT, 0, 'SELL', 'LMT', 100, 39.77, 0, 'GTC', 1,
-1, '', '', -1);
{modify order -> raise the limit}
EntryID := lib.PLACE_ORDER(ID_MSFT, EntryID, 'SELL', 'LMT', 100, 39.96, 0,
'GTC', 1, -1, '', '', -1);
end;
Count := Count + 1;

as you can see, function

lib.PLACE_ORDER(ID_MSFT, 0, 'SELL', 'LMT', 100, 39.77, 0, 'GTC', 1, -1, '', '',
-1);


places an order. if you look into documentation, you can find
various functions placing an order, like
BUY_STP, SELL_STP etc.
a briefly documentation of all functions can be found
documentation\exported_functions.txt
your job now: to find the appropiate TWSLink functions for
your ordere below and pass the correct paramters to them.

sample:
SellAtStop(bar+1, (priceOpen(bar+1) - (priceHigh(bar) -
priceClose(bar))), LastPosition, 'open-1/2 exit');


int SELL_STP(id_from_register_this_charts_symbol,
0,
int uidorder,
double stopprice,
int Size,
string tif,
int transmit);


wrote:
>
>
> Here is a simple WL script. How do I program TWSLink to send orders to
> IB?
>
> *************************
>
> var Bar: integer;
> for Bar := 2 to BarCount - 2 do
> begin
> if not LastPositionActive then
> begin
> if (priceClose(bar) < priceOpen(bar)) then
> buyAtStop(bar+1, (priceOpen(bar+1) + (priceClose(bar) -
> priceLow(bar))), 'open+1/2 entry');
>
> if (priceClose(bar) > priceOpen(bar)) then
> shortAtStop(bar+1, (priceOpen(bar+1) - (priceHigh(bar) -
> priceClose(bar))), 'open-1/2 entry');
> end
> else
> begin
> if PositionLong(LastPosition) then
> if (priceClose(bar) > priceOpen(bar)) then
> SellAtStop(bar+1, (priceOpen(bar+1) - (priceHigh(bar) -
> priceClose(bar))), LastPosition, 'open-1/2 exit');
>
> if PositionShort(LastPosition) then
> if (priceClose(bar) < priceOpen(bar)) then
> CoverAtStop(bar+1, (priceOpen(bar+1) + (priceClose(bar) -
> priceLow(bar))), LastPosition, 'open+1/2 exit');
> end;
> end;
>
> ********************
>
> Thank you.
>





Sat May 9, 2009 4:38 pm

maxchinaski
Offline Offline
Send Email Send Email

Forward
Message #529 of 538 |
Expand Messages Author Sort by Date

Can someone share a Wealth-Lab script showing how to use TWSLink to send orders from Wealth-Lab to IB? Keep it simple please. I downloaded TWSLink and read...
warrensmith631
Offline Send Email
May 6, 2009
2:22 am

... Hello, well, the wealth-lab sample is kept very simple. i don't know how to provide a smarter introduction as this: INIT REGISTER CONNECT PLACE_ORDER.... ...
maxchinaski
Offline Send Email
May 7, 2009
11:34 pm

Here is a simple WL script. How do I program TWSLink to send orders to IB? ************************* var Bar: integer; for Bar := 2 to BarCount - 2 do begin ...
warrensmith631
Offline Send Email
May 9, 2009
3:46 pm

here is a simple script using TWSLink (from samples dir.) {This sample demonstrates basic Steps to place an Order} var lib: ComVariant; var OpResult:...
maxchinaski
Offline Send Email
May 9, 2009
4:38 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help