PureBytes Links
Trading Reference Links
|
I found some code out there that I would like to try in AmiBroker.
Can someone help me re-write this in AFL?
thanks
{Stox Box system}
{based on "How I Made $2,000,000 in the Stock Market" by Nicolas
Darvas}
{Copy and distibute freely - not for sale}
{(C) Copyright 2000, PatternTrader.com}
inputs: setdays(3), fudge(0.1);
variables: avgrange(0), numshare(0), boxtop(0), boxbot(9999);
avgrange=xaverage(truerange,5);
numshare=500/(avgrange*bigpointvalue);
if currentbar>maxbarsback then begin
if h>value1 then begin {an all-time high}
value1=h;
value11=h;
value2=barnumber;
end;
if l<value11 then begin {lowest low since the high}
value11=l;
value22=barnumber;
end;
if currentbar-value2>=setdays and currentbar-value22>=setdays
then begin
boxtop=value1; {the top of the box}
boxbot=value11; {the bottom of the box}
buy numshare shares boxtop+fudge*avgrange stop;
end;
exitlong boxbot-fudge*avgrange stop;
end;
(/* The Stock Farmer New High System */}
inputs: base(15);
variables: lasthigh(0), lasthighbar(0), volthing(0);
{/* detect an important new high */}
if high>lasthigh+0.5 and v>1.50*average(v,50)
then begin
lasthigh=high;
lasthighbar=barnumber;
condition1=TRUE;
end
else
condition1=FALSE;
{/* buy breakout depending on base size */}
if condition1=TRUE and lasthighbar-lasthighbar[1]>base
then begin
if v[1]=0 then volthing=10 else volthing=(v/v[1]); {/* just in
case v[1]=0 */}
buy 100*volthing*(lasthighbar-lasthighbar[1])/c shares tomorrow on
the open;
end;
{/* selling rules */}
value11=0.75*lasthigh;
exitlong currentcontracts shares tomorrow at lowest(l,base)-0.5 stop;
exitlong currentcontracts shares tomorrow at value11 stop;
|