Version 11, last updated by pracplay-support2 at 16 May 18:48 UTC
BridgeExampleTradestation
These examples are provided as a help but are not comprehensive examples, nor are they guaranteed to work on every machine.
If you have problems, you should still consult the BridgeReference and BridgeTroubleshooting guides.
BASICS
- start up software
- broker software (if needed)
- broker connector
- bridge
- open tradestation.
- create new easy language strategy, copy/paste one of the examples below (realistic or test).
- open a chart and apply strategy you created.
- Orders should queue in the Bridge window
- Select order and click accept or reject
- If you click 'auto-accept' future orders will be sent automatically.
- You can then test other information via the Bridge command reference guide.
TRADESTATION (Realistic)
[IntraBarOrderGeneration = false;] inputs: mydate(1101223); vars: offsetflag(0), Orders(0), stpamt(0), flg(0), mp(0), barindex(0), sentflag(0), cflag(0), shrtlimit(0), sentsize(0), BEstop(0), realMP(0), mylimit(0), mytime(0), nowtime(0), myrsi(0), price(0), size(0), mycancel(0) // sym("") // for holding current Symbol ; ONCE sentflag = 0; external: "c:\Program Files\Bridge\BridgeHelper.dll", int, "TSL_SENDORDER",string,bool,int,double,double,int,string,string; external: "c:\Program Files\Bridge\BridgeHelper.dll", double, "TSL_POSPRICE",string; external: "c:\program files\Bridge\BridgeHelper.dll", int, "TSL_POSSIZE",string; external: "c:\program files\Bridge\BridgeHelper.dll", int, "TSL_SENDCANCEL", int; external: "c:\program files\Bridge\BridgeHelper.dll", int, "TSL_SETOFFSET",string,double, double, double , double; external: "c:\program files\Bridge\BridgeHelper.dll", int, "TSL_SETSLOFFSET",string,double, double, double ,string, string; external: "c:\program files\Bridge\BridgeHelper.dll", int, "TSL_CANCELOFFSETS",string; external: "c:\program files\Bridge\BridgeHelper.dll", int, "TSL_SENDCANCELALL", string; external: "c:\program files\Bridge\BridgeHelper.dll", int, "TSL_SENTSIZE", int; external: "c:\program files\Bridge\BridgeHelper.dll", int, "TSL_LASTUPDATETIME"; external: "c:\program files\Bridge\BridgeHelper.dll", int, "TSL_ISCANCELED", int; external: "c:\program files\Bridge\BridgeHelper.dll", int, "TSL_NEXTORDERID" ;
// alternative example using a variable for symbol // sym = GetSymbolName; // size = TSL_POSSIZE(sym); size = TSL_POSSIZE("SPY"); sentsize = TSL_SENTSIZE(orders); mylimit = average(c,2) ; mp = marketposition; price = TSL_POSPRICE("SPY"); if size = 0 then offsetflag = 0; if size = 0 then BEstop = 0; if date = mydate and time > 1230 and time < 1450 and size = 0 and xxx and xxx then begin value0=TSL_SENDCANCELALL("SPY"); orders=TSL_NEXTORDERID(); value1= TSL_SENDORDER("SPY",true,500,mylimit,0,orders,"Account","EDGX"); end; if size > 0 and offsetflag = 0 and c < price + .2 then begin value3 = TSL_SETOFFSET("SPY",.15,.30,.6,1); offsetflag = 1; end; if size > 0 and c >= price + .2 and BEstop = 0 then begin value4 = TSL_CANCELOFFSETS("SPY"); value5 = TSL_SETOFFSET("SPY",.25,-.05,.5,1); BEstop = 1; end; {if size < 0 and offsetflag = 0 and c > price - .2 then begin value3 = TSL_SETOFFSET("SPY",.1,.30,.6,1); offsetflag = 1; end; if size < 0 and c <= price - .2 and BEstop = 0 then begin value4 = TSL_CANCELOFFSETS("SPY"); value5 = TSL_SETOFFSET("SPY",.25,-.05,.5,1); BEstop = 1; end; } if time = 1558 then begin if size > 0 then begin orders=TSL_NEXTORDERID(); value6 = TSL_SENDORDER("MDY",false,size,0,0,orders,"Account","EDGX"); value7 = TSL_CANCELOFFSETS("MDY"); end; if size < 0 then begin orders=TSL_NEXTORDERID(); value6 = TSL_SENDORDER("MDY",true,size,0,0,orders,"Account","EDGX"); value7 = TSL_CANCELOFFSETS("MDY"); end; end;
TRADESTATION (Test)
Variable : error(0),orders(1),maxorders(2),price(0),size(0),pegorderid(0),setoffsets(1);external: "c:\program files\Bridge\BridgeHelper.dll",
int, "TSL_SENDORDER",string,bool,int,double,double,int,string,string;
external: "c:\program files\Bridge\BridgeHelper.dll",
double, "TSL_POSPRICE",string;
external: "c:\program files\Bridge\BridgeHelper.dll",
int, "TSL_POSSIZE",string;
external: "c:\program files\Bridge\BridgeHelper.dll",
int, "TSL_SENDCANCEL", int;
// automatic stop and profit protection whenever a position is taken
if setoffsets==1 then
begin
TSL_SETOFFSET("IBM",1,1,1,.5);
setoffsets = 0;
end;
// tradestation SendOrder examples
if (orders<maxorders) then
begin// get price of position
price = TSL_POSPRICE("IBM");// get size of position (-200 is short 200)
size = TSL_POSSIZE("IBM");// buy limit 200 shares at $70
error = TSL_SENDORDER("IBM",true,200,70,0,TSL_NEXTORDERIDSMALL(),"","");print(price);
print(size);
orders = orders + 1;
end;// rest of examples
// sell market 100 shares
// error = TSL_SENDORDER("IBM",false, 100,0,0, TSL_NEXTORDERIDSMALL() ,"","");// buy stop for 500 shares at $200 price, with a variable for order id
nextorder = TSL_NEXTORDERIDSMALL() ;
// error = TSL_SENDORDER("LVS",true,500,0,200, ,"","");
// tradestation cancel example
// TSL_SENDCANCEL(nextorder); // cancel the buy stop sent above
// quick and easy restricting of maximum orders
// if barnumber>barindex then TSL_SENDORDER_MAX(1); // ensure only one order sent per symbol per bar
// barindex = barnumber;
// peg an single order's price or size to changing variables (should only use per bar)
price = 100
size = 100
sym = GetSymbolName; // using variables to set symbol name
if pegorderid==0 then pegorderid = TSL_NEXTORDERIDSMALL();
// TSL_UPDATEORDER(sym,true, size,price,0,pegorderid,"","");