// Définition des paramètres du code
DEFPARAM CumulateOrders = False // Cumul des positions désactivé
DEFPARAM Preloadbars = 100000
//Alphatrend
ap = 14
Coeff = 1.5
if (MoneyFlowIndex[ap]>=50) then
magic=Low[0]-AverageTrueRange[ap](close)*coeff
endif
if (MoneyFlowIndex[ap]<=50) then
magic=High[0]+AverageTrueRange[ap](close)*coeff
endif
if (MoneyFlowIndex[ap]>=50 and magic<magic[1]) then
magic=magic[1]
endif
if (MoneyFlowIndex[ap]<=50 and magic>magic[1]) then
magic=magic[1]
endif
if magic>magic[1] then
couleur=1
elsif magic<magic[1]then
couleur=-1
endif
//PGO
SMA = Average[22](close)
ATR = TR(close)
MMe = ExponentialAverage[22](ATR)
PGO=(close-SMA)/(MMe)
indicator1 = PGO
indicator2 = couleur
// Conditions pour ouvrir une position acheteuse
c1 = (indicator1 CROSSES OVER(-2))
c2 = (indicator2 = 1)
IF c1 and c2 THEN
BUY 0.5 CONTRACT AT MARKET
Set Stop ploss 100
Set Target profit 45
ENDIF
// Conditions pour fermer une position acheteuse
c4 = (indicator1 CROSSES UNDER 2)
IF longonmarket and c4 THEN
SELL AT MARKET
ENDIF
// Conditions pour ouvrir une position vendeuse
c5 = (indicator1 CROSSES UNDER 2)
c6 = (indicator2 = -1)
IF c5 and c6 THEN
SELLSHORT 0.5 CONTRACT AT MARKET
Set Stop ploss 87
Set Target profit 97
ENDIF
// Conditions pour fermer une position vendeuse
c7 = (indicator1 CROSSES OVER(-2))
IF shortonmarket and c7 THEN
EXITSHORT AT MARKET
ENDIF