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

Re: [amibroker] Fw: Metastock's formula into AFL



PureBytes Links

Trading Reference Links

//Optimize:
OPT1=Optimize("OPT1",5,5,50,5);
OPT2=Optimize("OPT2",5,5,50,5);
OPT3=Optimize("OPT3",5,5,50,5);


datarray=LinRegSlope(C ,OPT3) ;
periods=50;

//linearReg
LinearReg=(periods * Sum(Cum(1) * datarray,periods) - Sum(Cum
(1),periods)* Sum(datarray,periods)) /
(periods * Sum((Cum(1)^2),periods) - (Sum(Cum(1),periods)^2)) *
Cum(1) + (MA(datarray,periods) - MA(Cum(1),periods) *
(periods * Sum(Cum(1) * datarray,periods) - Sum(Cum(1),periods) * Sum
(datarray,periods)) /
(periods * Sum((Cum(1)^2),periods) - Sum(Cum(1),periods)^2));

/***************************************/




//ENTER LONG:
Buy= C>MA(C,OPT1) AND LinRegSlope(C,OPT2)>LinearReg;

// Close LONG:
Sell= C<MA(C,OPT1) OR LinRegSlope(C,OPT2)<LinearReg;

//ENTER Short:
Short= C<MA(C,OPT1) AND LinRegSlope(C,OPT2)<LinearReg;

// Close Short:
Cover= C>MA(C,OPT1) OR LinRegSlope(C,OPT2)>LinearReg;

Buy=ExRem(Buy,Sell); Sell=ExRem(Sell,Buy);
Short=ExRem(Short,Cover);Cover=ExRem(Cover,Short);

Filter=1;
AddColumn(Buy,"buy");AddColumn(Sell,"sell");
AddColumn(Short,"short");AddColumn(Cover,"cover");


/*Initial Equity: Any amount.
positions: Long AND Short
Trade Price: Close
Trade delay: 0*/

Anthony

Inwind wrote:

> Can someone please convert this Metastock's formula into AFL - Thanks
>

ENTER LONG:
C>Mov(C,OPT1,S) AND
LinRegSlope(C,OPT2)>LinearReg(LinRegSlope(C ,OPT3),50)

CLOSE LONG:
C<Mov(C,OPT1,S) OR
LinRegSlope(C,OPT2)<LinearReg(LinRegSlope(C ,OPT3),50)

ENTER SHORT:
C<Mov(C,OPT1,S) AND
LinRegSlope(C,OPT2)<LinearReg(LinRegSlope(C ,OPT3),50)

CLOSE SHORT:
C>Mov(C,OPT1,S) OR
LinRegSlope(C,OPT2)>LinearReg(LinRegSlope(C ,OPT3),50)
>
> * OPTIMIZE:
> OPT1: Minimum 5 Maximum 50 Step 5
> OPT2: Minimum 5 Maximum 50 Step 5
> OPT3: Minimum 5 Maximum 50 Step 5
> * Initial Equity: Any amount.
> * Positions: Long and Short
> * Trade Price: Close
> * Trade delay: 0
>
> ThanksPeter
>
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.