runmode:=0;
input:breakthroughperiod(28,8,40,1);
input:nmin(15,5,30,1);
input:q(13,1,85,1);
input:k1(14,1,60,2);
input:k2(140,80,260,5);
input:g(54,40,80,2);
input:multiratio1(1.5,1,10,0.1);
input:multiratio2(1.6,1,6,0.1);
input:multiratio3(2,1,10,1);
input:multiratio4(1,1,10,1);
input:reference(1300,270,86400,270);
input:entertime(15,10,100,1)
input:n(0.998,0.995,1.000,0.001);
variable:maxc=0;
variable:cashposition=1;
variable:bfb=40;
variable:tradeswitch1=1;
variable:tradeswitch2=0;
variable:longswitch=0;
variable:shortswitch=0;
bars:=barpos;
onedayatr:=((high-low)+abs(h-o));
dayatr:=ref(ma(onedayatr,reference),1);
roundatr:=rounds(dayatr*multiratio1,1);
stoproundatr:=rounds(dayatr*multiratio2,1);
tworoundatr:=rounds(dayatr*multiratio3,1);
oneroundatr:=rounds(dayatr*multiratio4,1);
if openminutes(time)<=breakthroughperiod then
replaceperiod1:=openminutes(time);
else
replaceperiod1:=breakthroughperiod;
upbreakthroughline:=llv(l,replaceperiod1);
k3:=upbreakthroughline;
downbreakthroughline:=hhv(h,replaceperiod1);
k4:=downbreakthroughline;
rc:=ref(c,1)/ref(c,43);
arc1:=sma(ref(rc,1),43,1);
DMZ:=IF((H+L)<=(REF(H,1)+REF(L,1)),0,MAX(ABS(H-REF(H,1)),ABS(L-REF(L,1))));
DMF:=IF((H+L)>=(REF(H,1)+REF(L,1)),0,MAX(ABS(H-REF(H,1)),ABS(L-REF(L,1))));
DIZ:=SUM(DMZ,15)/(SUM(DMZ,15)+SUM(DMF,15));
DIF:=SUM(DMF,15)/(SUM(DMF,15)+SUM(DMZ,15));
DDI:=DIZ-DIF,COLORSTICK;
ADDI:=SMA(DDI,30,29);
AD:=MA(ADDI,4);
jc:=addi>ad;
sc:=ad>addi;
atr1:=ma(tr,11);
bias:=(o-ma(close,30))/ma(o,30)*100;
mabias:=ma(bias,10);
x:=mabias*0.05;
up:=hhv(h,29)-2.4*atr1;
bsx1:=up+x*atr1;
down:=llv(l,15)+2.4*atr1;
bsx2:=down+x*atr1;
LC := REF(h,1);
RSI:=SMA(MAX(h-LC,0),q,1)/SMA(ABS(h-LC),q,1)*100;
cyc:=barslast(date<>ref(date,1))+1;
tr1:= sum(max(max(high-low,abs(high-ref(o,1))),abs(low-ref(o,1))),11);
hd := high-ref(high,1);
ld := ref(low,1)-low;
dmp:= sum(if(hd>0 and hd>ld,hd,0),9);
dmm:= sum(if(ld>0 and ld>hd,ld,0),9);
pdi:= dmp*100/tr1;
mdi:= dmm*100/tr1;
adx:=ma(abs(mdi-pdi)/(mdi+pdi)*100,6);
adxr:=(adx+ref(adx,6))/2;
上轨1:ref(hhv(h,k1),1),linethick2,coloryellow;
下轨1:ref(llv(l,k1),1),linethick2,colorred;
上轨2:=ref(hhv(h,k2),1);
下轨2:=ref(llv(l,k2),1);
t1:=time>opentime(1) and time<143000 ;
t2:=time>=145500;
开多条件:=h>=upbreakthroughline+roundatr and adxr>g and holding=0 ;
开空条件:=l<=downbreakthroughline-roundatr and adxr>g and holding=0 ;