
// Code principal : LBA Marmotte DAX M3 1 contrat reinvest
//————————————————————————-
// Règles standard
DEFPARAM CUMULATEORDERS = false
DEFPARAM PRELOADBARS = 10000
////////////////////////////////////////////////////
////// PARAMETRES A RENSEIGNER //////
//////////////////////////////////////////////////
// UN SEUL CONTRAT SANS REINVESTISSEMENT DES GAINS
unseulcontrat=1 //renseigner 1 signifie qu »on de prend qu’un seul contrat
// Dans ce cas, il n’y a pas de reinvestissement des gains
//réinvestissement des gains
//pour prendre le nombre de contrat en fonction du capital, renseigner 0 dans unseulcontrat
//pour prendre un nombre de contrat fixes, saisir le nombre de contrats à prendre
reinv=1 //renseigner 1 signifie qu’on réinvestit les gains
// sinon renseigner 0
//position maxi contient le nombre de contrat au delà duquel on ne souhaite pas aller
positionmaxi=10
//CAPITAL INITIAL
capitalinitial=6000 /// Le capital initial permet de déterminer le nombre de contrats au départ de la statégie
/// et au fur à mesure des gains
//perte historique de la stratégie : Permet de déterminer la taille de la position
//Pensez à adapter la perte maxi si vous mettez un capital conséquent
maxdrawdown=300
//nombre de pertes du drawdoown maximum autorisé
//ajustement automatique du drawdown (commencer fort et réduire le levier lorsque le nombre de contrat devient conséquent)
ajustedd=1 ////// mettre 1 pour un ajustement automatique du levier sinon laisser à zéro
// Avec 0, le nombre de contrat sera proportionnel aux gains
///// (on prend la capital nécessaire + 2 fois le maxdrawdown
// Avec 1, on sera plus agressif au début, puis de plus en plus sécurisé
//SORTIE au dela d’une perte maxi
Pertemaxi=-2*maxdrawdown //modifiez le le -2 par -3 si vous voulez augmenter la perte maxi avant l’arrêt de la stratégie
///////////////////////////// ou augmentez la maxdrawdown
//horaires de cloture en semaine et le vendredi
// si closetime =24000000, la position ne sera clôturée que si le stop ou l’objectif est touché
// ou le vendredi à l’heure de closetimefriday
closetime=240000
closetimefriday=173000
///////FIN DES PARAMETRES A RENSEIGNER
//ARRET DE LA STRATEGIE EN CAS DE PERTEMAXI DEPASSEE
if pertemaxi<>0 then
if strategyprofit<pertemaxi then
quit
endif
endif
//permet de sortir au delà d’un certain nombre de bougies.
limitebougies=140
//calcul de la taille de position
//Capital necessaire pour prendre un contrat
capitalnecessaire=round(close*0.05)
coefmaxdd=2
if ajustedd=1 then
if strategyprofit<maxdrawdown then
coefmaxdd=1
else
if strategyprofit>capitalnecessaire then
coefmaxdd=3
else
coefmaxdd=2
endif
endif
else
coefmaxdd=2
endif
capitalnecessaire=capitalnecessaire+(coefmaxdd*maxdrawdown)
investissement=capitalinitial+strategyprofit
taillesimple =round(capitalinitial/capitalnecessaire)
tailleposition=round(investissement/capitalnecessaire)
taillepositionforte=round(investissement/(capitalnecessaire-maxdrawdown))
if reinv=1 then
if positionperf(1)< 0 then
positionsize=taillepositionforte
else
positionsize=tailleposition
endif
else
positionsize=taillesimple
endif
//positionsize=tailleposition
if unseulcontrat <>0 then
positionsize=unseulcontrat
endif
if positionsize>positionmaxi then
positionsize=positionmaxi
endif
///////CONDITIONS D’ACHAT/VENTE
signalachat, signalvente, sl, pt, ts = CALL « MARMOTTE V2 M3 Fast »
///
If signalachat then
if countoflongshares<1 then
buy positionsize contract at market
endif
endif
// short entry
If signalvente then
if countofshortshares < 1 then
sellshort positionsize contract at market
endif
endif
// MFETrailing
trailingstop = (tradeprice/100)*ts
if not onmarket then
MAXPRICE = 0
MINPRICE = close
priceexit = 0
endif
if longonmarket then
MAXPRICE = MAX(MAXPRICE,close)
if MAXPRICE-tradeprice(1)>=trailingstop*pipsize then
priceexit = MAXPRICE-trailingstop*pipsize
endif
endif
if shortonmarket then
MINPRICE = MIN(MINPRICE,close)
if tradeprice(1)-MINPRICE>=trailingstop*pipsize then
priceexit = MINPRICE+trailingstop*pipsize
endif
endif
If onmarket and priceexit>0 then
sell at market
exitshort at market
endif
// exit at closetime
If onmarket then
if time >= closetime then
sell at market
exitshort at market
endif
endif
// exit friday at set closetime
if onmarket then
if (CurrentDayOfWeek=5 and time>=closetimefriday) then
sell at market
exitshort at market
endif
endif
//sortie après un certain nombre de bougies en cas de plus value.
if onmarket and BarIndex >TradeIndex + limitebougies and close>tradeprice then
sell at market
exitshort at market
endif
// conditions de sorties principales du trade
SET TARGET %PROFIT pt
SET STOP %LOSS sl[/text_block]