TradeStation Tools compatible product  line

 


  

TradeStation TOOLS

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


 

 

 

 

 

 

 

 

 

Equity Curve

TRADING THE EQUITY CURVE"

  • This piece of code is called from Easy Language inside any trading system, and generates the Equity Curve BEFORE THE TRADE , takes in account transaction costs, works with buy stop and sell stop orders, may close the position at the end of the day, from any trading (setup) signal that you are able to write in Easy Language.
  • Of course, when you use the DLL that simulates the trading system, you do not write first orders that may be triggered by TradeStation.
  • The next step is to treat the Equity curve as a price curve, and then detect when the curve is climbing (or falling).
  • If it's the case, you may then write your real orders and allow TradeStation to trade when the system performs well.
  • An other use is to cut position when the Equity Curve falls.

Var: prof_loss(0),init(1),xpos(0),ordre(0);

inputs:

eod(0), Close or not at the end of the day
frais(0.5), Commission + slippage
stp(1); Stop measurement

First, you write the logic of your trading system:

value2=price-linearregvalue(price,len,-2);
value3=waverage(value2,7);
value4=average(value3,3);

Next step is to generate the Equity Curve (as if you had really placed the orders according to that above logic)
if value3>value4 and value4<0 then ordre=+1;
if value3<value4 and value4>0 then ordre=-1;

This is the DLL definition

definedllfunc:"ts_bal1.dll",int,"balou_1",
long,lpfloat,lpfloat,lpfloat,lpfloat,lpfloat,
long,long,lpfloat,lpfloat,long,long,
lpfloat,lpfloat;

And the values that you will pass to the DLL function:

value7=eod;
value8=frais;
value9=stp;

Value10=open;
value11=high;
value12=low;
value13=close;

The DLL function calculates the Equity Curve:
balou_1(barnumber,&init,&value10,&value11,&value12,&value13,
ordre,eod,&value8,&value9,sess1endtime,time,
&prof_loss,&xpos);
The Current position is stored in xpos variable (depend if your stops have been triggered), and the Equity curve is stored in the "Prof_loss" variable
Then you may apply a trading logic to the Equity Curve (here below, a simple difference between the Equity Curve and its 20 bars moving average)
.
value20=prof_loss-average(prof_loss,20);

After that you may decide what you do.

for example;

if value20>0 then begin (the Equity Curve is above its average)
if order =1 then buy
if order=-1 then sell
end else begin (the Equity Curve is below its average)
exitlong
exitshort
end;


 
 
 

 
Previous ] Up ]