Defparam cumulateorders = false
// horaire de trading
CtimeAchat = time >= 080000 and time <= 190000
CtimeVente = time >= 080000 and time <= 190000
// pivot journalier
//cloture=DClose(1)
//pivotJ=(DHigh(1) + DLow(1) + DClose(1))/3
//if OpenDayOfWeek=1 then
//pivotJ=(DHigh(2) + DLow(2) + DClose(2))/3
//cloture=DClose(2)
//endif
// pivot 4H
Int = (OpenTime[1] < 010000 AND OpenTime > 010000) OR (OpenTime[1] < 050000 AND OpenTime > 050000) OR (OpenTime[1] < 090000 AND OpenTime > 090000) OR (OpenTime[1] < 130000 AND OpenTime > 130000) OR (OpenTime[1] < 170000 AND OpenTime > 170000) OR (OpenTime[1] < 210000 AND OpenTime > 210000) OR (Openday <> Openday[1] AND DayOfWeek < DayOfWeek[1])
IF (OpenTime Mod 40000 = 10000) OR Int THEN
myLastHigh = myHigh
myLastLow = myLow
myLastClose = Close[1]
myHigh = High
myLow = Low
ELSE
myHigh = Max(myHigh, High)
myLow = Min(myLow, Low)
ENDIF
// Calcul Points Pivots 4h
PP = (myLastHigh + myLastLow + myLastClose) / 3
// moyennes mobiles
MM100 = ExponentialAverage[100](close)
MM300 = ExponentialAverage[300](close)
// vente
Timeframe(1 minutes)
StochK1mn=Stochastic[11,5](close)
StochD1mn=Stochasticd[11,5,3](close)
c1 = StochK1mn > 75 and StochK1mn crosses under StochD1mn
c2 = MM100 < MM300
c3 = (close < MM100 )
IF c1 and c2 and c3 and CtimeVente and not onmarket THEN
SELLSHORT 1 shares AT MARKET
endif
// STOP ET RACHAT DE LA POSITION
//condition 1 si le cours remonte de 12 c'est le stop loss
set stop ploss 12
//condition 2 deuxiémement, si le cours coupe la MM100 c'est le rachat
if (close > MM100) then
exitshort at market
endif
// condition 3 pour finir, si la ligne K touche la borne 20 du stochastique alors c'est le rachat
if StochK1mn = 20 then
exitshort at market
endif