Kindly convert above metastock formula in to amibroker AFL.

#1
{sell channel}
nd:= 2;
stobuy:=Cross(Stoch(5,3),20);
stosel:=Cross(80,Stoch(5,3));

c1:= Cum(1);
end:= LastValue(ValueWhen(1,stosel,c1));
date:= c1 = end;
time:= LastValue(end -
ValueWhen(1, date, ValueWhen(1, stobuy, ValueWhen(1, stosel, c1))))+1;
pt:=LastValue(ValueWhen(1,date,LinearReg(C,time)));
slope:=LastValue(ValueWhen(1,date,LinRegSlope(C,time)));
start:=BarsSince(Cum(1)>=end-(time-1));
center:=If(start=0,pt - (slope*(end-Cum(1))),0);
dis:= nd*LastValue(ValueWhen(1,date,STE( C, time)));
center+dis;
center;
center-dis



{buy channel}
nd:= 2;
stobuy:=Cross(Stoch(5,3),20);
stosel:=Cross(80,Stoch(5,3));

c1:= Cum(1);
end:= LastValue(ValueWhen(1,stobuy,c1));
date:= c1 = end;
time:= LastValue(end -
ValueWhen(1, date, ValueWhen(1, stosel, ValueWhen(1, stobuy, c1))))+1;
pt:=LastValue(ValueWhen(1,date,LinearReg(C,time)));
slope:=LastValue(ValueWhen(1,date,LinRegSlope(C,time)));
start:=BarsSince(Cum(1)>=end-(time-1));
center:=If(start=0,pt - (slope*(end-Cum(1))),0);
dis:= nd*LastValue(ValueWhen(1,date,STE( C, time)));
center+dis;
center;
center-dis:):):)
 

rkkarnani

Well-Known Member
#2
{sell channel}
nd:= 2;
stobuy:=Cross(Stoch(5,3),20);
stosel:=Cross(80,Stoch(5,3));

c1:= Cum(1);
end:= LastValue(ValueWhen(1,stosel,c1));
date:= c1 = end;
time:= LastValue(end -
ValueWhen(1, date, ValueWhen(1, stobuy, ValueWhen(1, stosel, c1))))+1;
pt:=LastValue(ValueWhen(1,date,LinearReg(C,time)));
slope:=LastValue(ValueWhen(1,date,LinRegSlope(C,time)));
start:=BarsSince(Cum(1)>=end-(time-1));
center:=If(start=0,pt - (slope*(end-Cum(1))),0);
dis:= nd*LastValue(ValueWhen(1,date,STE( C, time)));
center+dis;
center;
center-dis



{buy channel}
nd:= 2;
stobuy:=Cross(Stoch(5,3),20);
stosel:=Cross(80,Stoch(5,3));

c1:= Cum(1);
end:= LastValue(ValueWhen(1,stobuy,c1));
date:= c1 = end;
time:= LastValue(end -
ValueWhen(1, date, ValueWhen(1, stosel, ValueWhen(1, stobuy, c1))))+1;
pt:=LastValue(ValueWhen(1,date,LinearReg(C,time)));
slope:=LastValue(ValueWhen(1,date,LinRegSlope(C,time)));
start:=BarsSince(Cum(1)>=end-(time-1));
center:=If(start=0,pt - (slope*(end-Cum(1))),0);
dis:= nd*LastValue(ValueWhen(1,date,STE( C, time)));
center+dis;
center;
center-dis:):):)
Hi, How about posting a chart with this Expert applied !?? :D
 

Similar threads