defparam CUMULATEORDERS=true
defparam PRELOADBARS=0
upp2=333292
upp=333263
//
dnn=32699
dnn2=32660
stopup=33340
stopdn=32500
//
tp=10
trailingstop = 10
set stop ploss 150
once goupp=1
once goupp2=1
once godnn=1
once godnn2=1
///////////// short/////////////////
//entrée short
if high<upp and goupp=1 and goupp2=1 and countofposition=0 and high>upp-50 then
sellshort 1 contract at upp limit
endif
//sécurisation pour n'y aller qu'une fois sur premiere upp
if high crosses over upp or shortonmarket then
goupp=0
endif
//short 2eme barriere
if countofposition=-1 and goupp2=1and high>upp2-50 then
sellshort 1 contract at upp2 limit
endif
//sécurisation pour n'y aller qu'une fois sur premiere upp
if high crosses over upp2 or countofposition<-1 then
goupp2=0
endif
//collect des gain
if countofposition=-1 then
exitshort at positionprice-tp limit
endif
//sortie flat
if countofposition<-1 then
exitshort at positionprice limit
endif
if countofposition<-1 then
exitshort at stopup stop
endif
///////////// long/////////
//entrée long
//and godnn=1
if low>dnn and godnn=1 and godnn2=1 and countofposition=0 and low<dnn+50 then
buy 1 contract at dnn limit
endif
//sécurisation pour n'y aller qu'une fois sur premiere upp
if low crosses under dnn or longonmarket then
godnn=0
endif
//short 2eme barriere
if countofposition=1 and godnn2=1 and low<dnn2+50 then
buy 1 contract at dnn2 limit
endif
//sécurisation pour n'y aller qu'une fois sur premiere upp
if low crosses under dnn2 or countofposition>1 then
godnn2=0
endif
//collect des gain
if countofposition=1 then
sell at positionprice+tp limit
endif
//sortie flat
if countofposition>1 then
sell at positionprice limit
endif
if countofposition>1 then
sell at stopdn stop
endif