//Définition des paramètres du code
DEFPARAM CumulateOrders = False // Cumul des positions désactivé
// Empêche le système de placer des ordres pour entrer sur le marché ou augmenter la taille d'une position avant l'heure spécifiée
noEntryBeforeTime = 080000
timeEnterBefore = time >= noEntryBeforeTime
// Empêche le système de placer des ordres pour entrer sur le marché ou augmenter la taille d'une position après l'heure spécifiée
noEntryAfterTime = 180000
timeEnterAfter = time < noEntryAfterTime
// Empêche le système de placer de nouveaux ordres sur les jours de la semaine spécifiés
daysForbiddenEntry = OpenDayOfWeek = 5 OR OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
IF init=not onmarket THEN
step=0
init=1
////highs and lows
if close<sarfast then
ll=min(ll,low)
else
hh=max(hh,high)
endif
if close>sarfast and close[1]<sarfast[1] then //new bullish signal
fibo0=ll
ll=sarslow //reset ll
if close>sarslow then
startbar=barindex
irange=high-fibo0
entry = fibo0+(irange/2)
itarget = fibo0+irange*1.618
istop = fibo0-2*pointsize
if close<sarfast and close[1]>sarfast[1] then //new bearish signal
fibo0=hh
hh=0 //reset hh
if close<sarslow then
startbar=barindex
irange=fibo0-low
entry = fibo0-(irange/2)
itarget = fibo0-irange*1.618
istop = fibo0+2*pointsize
//indicateurs
sarfast=SAR[0.02,0.02,0.2]
sarslow=SAR[0.005,0.005,0.05]
// Conditions pour ouvrir une position acheteuse
c1=close>sarfast and close[1]<sarfast[1]
IF c1 AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THEN
BUY 1 CONTRACT AT MARKET
ENDIF
SET TARGET PROFIT ITARGET
SET STOP PLOSS ISTOP
// Conditions pour ouvrir une position en vente à découvert
c2=close<sarfast and close[1]>sarfast[1]
IF c2 AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
SET TARGET PROFIT ITARGET
SET STOP PLOSS ISTOP
//BREAKEVEN------------------------------------------------------------------------------------------------
startBreakeven0 = BE
PointsToKeep0 = PK
IF NOT ONMARKET THEN
breakevenLevel=0
ENDIF
// BE FOR LONG---------------------------------------------------------------------------------------------
IF longonmarket and step = 0 and close - tradeprice(1) >= StartBreakeven0 * pipsize THEN
BreakevenLevel = tradeprice(1) + PointsToKeep0 * pipsize
step = 1
ENDIF
IF step = 1 THEN
sell 0.5 contracts at market //(avec X le nombre de contrat a cloturer)
step = 2
endif
IF breakevenLevel>0 THEN
sell AT breakevenLevel STOP
ENDIF