jcl
Thanks again for your help, i'm slowly learning how to get the code correct.
I've still not managed to figure out how to basket trade successfully yet, i want to use a basket sl/tp but not managed to get far yet. Is valLong a cash value or in pips?
For completeness here is the Laguerre and ALF code.
Code: Select all
//+------------------------------------------------------------------+
//| AdaptiveLaguerreFilter.mq4
//+------------------------------------------------------------------+
int _LookBack = 20;
int _Median = 5;
//extern int PriceType = PRICE_MEDIAN;
int _Length = 7;
var _alpha0 = 0.5;
var Laguerre(var data, var alpha)
{
vars L0 = series(),L1 = series(),L2 = series(),L3 = series();
L0[0] = alpha*data + (1-alpha)*L0[1];
L1[0] = -(1-alpha)*L0[0] + L0[1] + (1-alpha)*L1[1];
L2[0] = -(1-alpha)*L1[0] + L1[1] + (1-alpha)*L2[1];
L3[0] = -(1-alpha)*L2[0] + L2[1] + (1-alpha)*L3[1];
return (L0[0] + 2*L1[0] + 2*L2[0] + L3[0]) / 6;
}
function run()
{
set(PLOTPRICE+PLOTNOW);
StartDate=20120903;
EndDate=20120904;
PlotBars = 500;
BarPeriod=1;
vars Filt = series();
Filt[0]=Laguerre(price(),_alpha0);
vars ALF = series();
vars Diff = series(abs(price() - Filt[1]));
MinMax(Diff,_LookBack);
vars SortDiff = series((Diff[0] - rMin)/(rMax - rMin));
var alpha = Median(SortDiff,_Median);
ALF[0] = Laguerre(price(),max(alpha,_alpha0));
plot("Laguerre Filter",Filt[0],0,RED);
plot("ALF",ALF[0],0,BLUE);
}
Reagrds
Mike