Bonjour,
dans ce programme de breakout classique, tout fonctionne sauf deux ocurences que j’ai souligné en gras
Si quelqu’un peut y jeter un coup d’oeil, celà me soulagerais.
Merci d’avance.
//On établit trois niveaux à la hausse et à la baisse, on entre 4 lots puis on sort successivement 1 lot sur chaque niveau le dernier étant sorti sur stop suiveur
//parameters :
boxsize = 0.4
//———————— Etablissement du renko —————-
once topprice = high
once bottomprice = low – boxsize*ticksize
if(high > topprice + boxsize) THEN
topprice = high
bottomprice = topprice – boxsize
ELSIF (low < bottomprice – boxsize) THEN
bottomprice = low
topprice = bottomprice + boxsize
ELSE
topprice = topprice
bottomprice = bottomprice
ENDIF
//——————- Canal d’ouverture ——————-
once pH=high
once PB=low
once CA1=high
once CA2=high
once CA3=high
once CV1=low
once CV2=low
once CV3=low
once stopSA=high
once stopSV=low
debut=143000
if time<debut then
cpt=0
PH=topprice
PB=bottomprice
stopSA=topprice
stopSV=bottomprice
elsif topprice<>topprice[1] then
cpt=cpt+1
PH=max(PH,topprice)
PB=min(PB,bottomprice)
if high>CA3 then
stopSA1=max(stopSA,high-2*ecart)
endif
if low<CV3 then
stopSV1=min(stopSV,low+2*ecart)
endif
endif
if cpt>5 then
PH=PH[1]
PB=PB[1]
endif
ecart=PH-PB
CA1=PH+1*ecart
CA2=PH+2*ecart
CA3=pH+3*ecart
CV1=PB-1*ecart
CV2=PB-2*ecart
CV3=PB-3*ecart
//——————-Initialisation ———————
if not onmarket then
etat=0
cptA=0
cptV=0
endif
//————————- Achats ———————
CondAchat1=not longonmarket and time>debut and time<=155000 and topprice[1]<=PH and topprice>PH
CondAchat2=not longonmarket and time>155000 and time<173000 and cptA=0 and topprice[1]<=PH and topprice>PH
if CondAchat1 or CondAchat2 then
buy 4 shares at market
cptA=cptA+1
endif
//———————— Etat0 (4 lots) —————————————-
if longonmarket and etat=0 then
if high[1]<= CA1 and high>=CA1 then
sell 1 share at market
etat=1
elsif bottomprice[1]>=PB and bottomprice<PB then
sell 4 shares at market
etat=0
endif
endif
//———————— Etat1(Reste 3 lots) —————————————-
if longonmarket and etat=1 then
if high[1]<=CA2 and high>=CA2 then
sell 1 share at market
etat=2
elsif topprice[1]>=PH and topprice<PH then // il faut que topprice passe en dessous de PH pour pouvoir reprendre une position à l’achat
sell 3 shares at market
etat=0
endif
endif
//———————— Etat2 (Reste 2 lots)—————————————-
if longonmarket and etat=2 then
if high[1]<=CA3 and high>=CA3 then
sell 1 share at market
etat=3
elsif bottomprice[1]>=CA1 and bottomprice<CA1 then // à cet endroit, il me sort les 2 lots restants
// au lieu d’un seul
sell 1 share at market
etat=4
endif
endif
//———————— Etat3 (Reste 1 lot) —————————————-
if longonmarket and etat=3 then // ici, il ne veut pas prendre mon stop suiveur
if low<stopSA1 then
sell 1 share at market
etat=0
cptA=0
cptV=0
elsif time>214500 then
sell 1 share at market
etat=0
cptA=0
cptV=0
endif
endif
//———————— Etat4 (Reste 1 lot)—————————————-
if longonmarket and etat=4 then
if high<max(tradeprice,high-2*ecart) then
sell 1 share at market
etat=0
cptA=0
cptV=0
elsif time>214500 then
sell 1 share at market
etat=0
cptA=0
cptV=0
endif
endif