variable:bj=0;
m:=14;
TR1 : MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW));
ATR : MA(TR1,m);
atr_day1:=ref(atr,todaybar);
c1:=callstock(stklabel,vtclose,6,-1);
o1:=callstock(stklabel,vtopen,6,-1);
if todaybar=1 and c1>=o1 and holding=0 and bj=0 then begin
buy(holding=0,1,limitr,open);
bj:=1;
end
if todaybar=1 and c1<o1 and holding=0 and bj=0 then begin
buyshort(holding=0,1,limitr,open);
bj:=1;
end
if holding>0 and c<=enterprice-2*atr then begin
sell(1,0,marketr);
end
if holding<0 and c>=enterprice+2*atr then begin
sellshort(1,0,marketr);
end
if time=closetime(0) then begin
sell(1,0,marketr);
sellshort(1,0,marketr);
bj:=0;
end