# Convert Metastock to AFL Need Help

#### jlmalhotra

##### Active Member
Hi,

Can someone convert this Metastock Formula to afl.

Cn:=Sum((H-L)<=1.62*Ref(Mov(H-L,20,S),-1),10)=10 OR Sum(H>L,10)<8;

BoxH:=ValueWhen(1,Cn,HHV(H,20));
BoxL:=ValueWhen(1,Cn,LLV(L,20));
BoxH ;
BoxL

#### govind1209

##### New Member
Cn= Sum((H-L)<=1.62*Ref(MA(H-L,20),-1),10)==10 OR Sum(H>L,10)<8;

BoxH=ValueWhen(Cn,HHV(H,20),1);
BoxL=ValueWhen(Cn,LLV(L,20),1);
Plot(BoxH,"",colorAqua,styleLine);
Plot(BoxL,"",colorRed,styleLine);
Plot(Close,"",IIf(O>C,colorRed,colorLime),styleCandle);

But very frankly didnt understand this condition in the first line Sum(H>L,10)<8; I mean H>L always isnt it and that sum will always be 10 so less than 8 always

#### jlmalhotra

##### Active Member
I agree but this is what it is Have copied and pasted the formula. Not much of a computer literate. Any help will be appreciated
This is how it looks like.

#### govind1209

##### New Member
_SECTION_BEGIN("DBOX");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Cn= Sum((H-L)<=1.62*Ref(MA(H-L,20),-1),10)==10 OR Sum(H>L,10)<8;

BoxH=ValueWhen(Cn,HHV(H,20),1);
BoxL=ValueWhen(Cn,LLV(L,20),1);
Plot(BoxH,"",colorAqua,styleLine);
Plot(BoxL,"",colorRed,styleLine);
Plot(Close,"",IIf(O>C,colorRed,colorLime),styleCandle);
_SECTION_END();

#### jlmalhotra

##### Active Member
_SECTION_BEGIN("DBOX");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Cn= Sum((H-L)<=1.62*Ref(MA(H-L,20),-1),10)==10 OR Sum(H>L,10)<8;

BoxH=ValueWhen(Cn,HHV(H,20),1);
BoxL=ValueWhen(Cn,LLV(L,20),1);
Plot(BoxH,"",colorAqua,styleLine);
Plot(BoxL,"",colorRed,styleLine);
Plot(Close,"",IIf(O>C,colorRed,colorLime),styleCandle);
_SECTION_END();

Thank you