input:m(3,3,10,1),n(3,3,10,1);
hh1:=hhv(h,m);
ll1:=llv(l,m);
hh2:=if(c<ref(ll1,1),hh1,0);
hh:=VALUEWHEN(hh2<>0,hh2);
ll2:=if(c>ref(hh1,1),ll1,0);
ll:=VALUEWHEN(ll2<>0,ll2);
hhcon:=ref(c,1)<ref(hh,1) and c>hh;
llcon:=ref(c,1)>ref(ll,1) and c<ll;
hlsig:=VALUEWHEN(hhcon or llcon,if(hhcon,1,0));
stophl:if(hlsig=1,ll,hh),colorred,linethick2;
if cross(c,stophl) then begin
sellshort(1,0,marketr);
buy(holding=0,1,marketr);
end
if cross(stophl,c) then begin
sell(1,0,marketr);
buyshort(holding=0,1,marketr);
end
input:m(3,3,10,1),n(3,3,10,1);
hh1:=hhv(h,m);//m周期最高价
ll1:=llv(l,m);//m周期最低价
hh2:=if(c<ref(ll1,1),hh1,0);//当c小于上一周期ll1时,hh2值为hh1,否则为0
hh:=VALUEWHEN(hh2<>0,hh2);//hh为当hh2不等于0时hh2的值
ll2:=if(c>ref(hh1,1),ll1,0);//当c大于上一周期hh1时,ll2值为ll1,否则为0
ll:=VALUEWHEN(ll2<>0,ll2);//ll为当ll2不等于0时ll2的值
hhcon:=ref(c,1)<ref(hh,1) and c>hh;//判断条件1
llcon:=ref(c,1)>ref(ll,1) and c<ll;//判断条件2
hlsig:=VALUEWHEN(hhcon or llcon,if(hhcon,1,0));//hlsig为条件1或者条件2成立时hhcon的值,hhcon为判断条件,成立值为1,不成立值为0
stophl:if(hlsig=1,ll,hh),colorred,linethick2;//stophl为hlsig值为是1时ll的值,或者为hlsig值不为1时,hh的值