[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to write a trading system ...



PureBytes Links

Trading Reference Links

At 7:01 PM -0200 12/23/01, Eduardo wrote:

>I would like to know how can I write a trading system that I enter a order
>to buy when close cross over the xaverage and exits when the close cross
>under the xaverage and the short order is exactly the inverse. I would make
>this in the same strategy in order to optimize the lenght to be used by both
>strategies.

I assume you want to use different lengths for the long and short cases. If so, this should work. (Not tested)

Bob Fulks

---

Input: Len1(14), Len2(20);

Vars: Avg1(Close), Avg2(Close);

Avg1 = XAverage(Close, Len1);
Avg2 = XAverage(Close, Len2);

if Close crosses over  Avg1 then Buy next bar at market;
if Close crosses under Avg1 then ExitLong next bar at market;

if Close crosses under Avg2 then Sell next bar at market;
if Close crosses over  Avg2 then ExitShort next bar at market;