Bonjour, voici un début de projet qui achète ou vends le France 40 en base timeframe 40 secondes mais qui est en MTF , le but est qu’il réalise entre 4 et + de trades par jour avec des petits gains
defparam cumulateorders=false
DEFPARAM FLATafter=220500
defparam preloadbars=200000
REM MONEY MANAGEMENT
MM = 1
if MM = 0 then
positionsize=3.2
ENDIF
if MM = 1 then
ONCE startpositionsize =2.4
ONCE factor = 1
ONCE factor2 = 2
ONCE margin = (close*.08)
ONCE margin2 = (close*.08)
ONCE tier1 = 200
ONCE maxpositionsize = 2000
ONCE minpositionsize = 1
IF Not OnMarket THEN
positionsize = startpositionsize + Strategyprofit/(factor*margin)
ENDIF
IF Not OnMarket THEN
IF startpositionsize + Strategyprofit/(factor*margin) > tier1 then
positionsize = (((startpositionsize + (Strategyprofit/(factor*margin))-tier1)*(factor*margin))/(factor2*margin2)) + tier1
ENDIF
IF Not OnMarket THEN
if startpositionsize + Strategyprofit/(factor*margin) < minpositionsize THEN
positionsize = minpositionsize
ENDIF
IF (((startpositionsize + (Strategyprofit/(factor*margin))-tier1)*(factor*margin))/(factor2*margin2)) + tier1 > maxpositionsize then
positionsize = maxpositionsize
ENDIF
ENDIF
ENDIF
ENDIF
n=positionsize
REM PLAGES HORAIRES
if time<074000 or time>205000 then
journee=0
else
journee=1
endif
REM ON SUIT LA TENDANCE 10MIN A L'ACHAT
timeframe (10 minutes)
if supertrend[8,1]>close then
stopa=1
else
stopa=0
endif
REM ON VERIFIE L'ECART ENTRE CLOSE ET CLOTURE DE LA VEILLE A 17H30
timeframe (40 second)
delai=((time+160000)/100*1.5)
if (close[delai]-close)>25 then
stopv2=1
else
stopv2=0
endif
if (close-(close[delai])>112) then
stopa2=1
else
stopa2=0
endif
REM INTERDICTIONS DE JOUER LES EXTREMES
timeframe (2 MINUTES)
if (close>=(dhigh(0)) and time<082500) or (close>=(dhigh(0)-15) and time>=082500 and time<091000)or ((close>(dhigh(0)-3) and time>=160000)) or (time>113000 and time<=133000) or (close>=(highest[5][1]) and time>=090000 and time<195000) or (dayofweek=1 and time>163000) or ((close-close[43])>15) or (dayofweek=4 and time>092000 and time<110000) or (time>150000 and time<163000) then
haltea=1
else
haltea=0
endif
REM LIGNE ACHAT
if stopa2=0 and stopa=0 and haltea=0 and journee= 1 and not onmarket and supertrend[1,1]<close and (open[2]<close[8] or open[22]>close[6]) then
buy n share at market
endif
REM INTERDICTION DE JOUER LES EXTREMES
if (close<(dlow(0)+11)) or dayofweek=4 or (dayofweek=5 and time>113000) or time>=210000 or ((dayofweek=2 ) and time>113000) or (time>113000 and time<=133000) then
haltev=1
else
haltev=0
endif
REM LIGNE VENTE
timeframe (4 minute)
if stopv2=0 and haltev=0 and journee=1 and not onmarket and supertrend[4,1]>close and (close[10]<open[2] or close[0]>open[26]) then
sellshort n share at market
endif
REM PERTES ET PROFITS
timeframe (40 SECOND)
if longonmarket then
set target profit 4.5
set stop loss 61
endif
if shortonmarket then
set target profit 8
set stop loss 19
endif
REM CI SA TRAINE ON EST MOINS AMBITIEUX
if longonmarket and (barindex-tradeindex)>99 then
set target profit 3.6
endif
if shortonmarket and (barindex-tradeindex)>98 then
set target profit 8
endif
Bonjour,
Intéressant ce code, cependant je n’arrive pas à comprendre ce bloc:
REM ON VERIFIE L’ECART ENTRE CLOSE ET CLOTURE DE LA VEILLE A 17H30
timeframe (40 second)
delai=((time+160000)/100*1.5)
if (close[delai]-close)>25 then
stopv2=1
else
stopv2=0
endif
if (close-(close[delai])>112) then
stopa2=1
else
stopa2=0
endif
Pourrez-tu STP expliquer ce que renvoie le close[delai] ?
Merci
Bonsoir, il s’agit d’une erreur, je voulais faire comparaitre le cours du moment au cours de clôture
car le cours de cloture dclose dans proorder est le cours à minuit
L’idéal est de prendre le temps du moment par exemple 10 heures du matin, on y rajoute 6,5 heures ( le temps de 17h30 à 24h00)
soit (time+063000) et on obtient 163000
on divise par 10 000 pour isoler les heures et on supprime les décimales avec instruction round , soit 16 et on multiplie par 60 ( pour passer en minutes ) puis par 1,5 pour passer en nombre de fois 40 secondes car en 10 minutes, il y a 15 fois 40 secondes et on fait pareil avec les minutes puis les secondes pour aller chercher le close correspondant à la cloture de 17h30
sinon il y a plus simple c’est de mettre une variable
if time=173000 then
coursdecloture=close
endif
mais dans ce cas au premier démarrage faut mettre un once coursdecloture=6540 par exemple car la variable n’aura pas été remplie de la veille à 17h30
Voilà, à ta disposition