This ProOrder code (strategy) implements a trend tracking system based on a crossing of the price with Bollinger-type bands and a dynamic trailing stop. It is designed to work on the CAC 40 (Spread) in a 3-minute timeframe, with hourly/daily filtering rules and risk management via stop loss and target.
The logic calculates an envelope around the average (implicit simple moving average via average) using the standard deviation (std):
A trend state (trend) and a trailing stop level (ts) are initialized on the first signal:
The trailing stop is then updated to follow the trend (max in uptrend, min in downtrend). A reversal is detected when the price crosses the trailing stop. The code also contains a time filter (stopv) to avoid certain time slots/days.
Important: in the extract provided, the variable sale is initialized to 0 and is never set to 1, while only purchase is set to 1 during a reversal (trend=1 then crossing below ts). In addition, the order executed is a SELLSHORT conditioned by sale=1. As it stands, the strategy may therefore not trigger any trades. This documentation describes the calculation as written, but it is advisable to check/complete the entry conditions.
REM CAC 40 SPREAD 1
DEFPARAM cumulateOrders = FALSE
defparam preloadbars= 10000
timeframe (3 MINUTE)
if time<090000 or time>173000 then
journee=0
else
journee=1
endif
SignalPeriod = 28
ArrowPeriod = 2
achat=0
vente=0
bbup = average[signalperiod]+std[signalperiod]*arrowperiod
bbdn = average[signalperiod]-std[signalperiod]*arrowperiod
if ts=0 then
if close crosses over bbup then
ts=bbdn
trend=1
elsif close crosses under bbdn then
ts=bbup
trend=-1
endif
endif
if trend=1 then
ts=max(ts,bbdn)
elsif trend=-1 then
ts=min(ts,bbup)
endif
if trend=1 and close crosses under ts then
trend=-1
ts=bbup
r=255
g=0
achat=1
endif
if ((dayofweek=3 or dayofweek=5) and time<093500) or (dayofweek=5 and time>105000 and time<120000)or (dayofweek=1 and time>150000 and time<153000) then
stopa=0
else
stopa=1
endif
if journee=1 and achat=1 and stopa=1 then
buy 1 contract at market
endif
if trend=-1 and close crosses over ts then
trend=1
ts=bbdn
r=0
g=255
vente=1
endif
if (time>130100 and time<143000) or (time>105500 and time<120000) or (time>145500 and time<151500) or (dayofweek=5 and time<090500) then
stopv=0
else
stopv=1
endif
if journee=1 and vente=1 and stopv=1 then
sellshort at market
endif
set target profit 9
set stop loss 70
You must be logged in to post a comment.
Ok, je reposte car la copie de l'écran n'a pas l'air d'être accepté.
Le résultat était peut-être bon de Aout 2025 à Févr 2026 mais depuis c'est retour à la base départ.
En gros sur la période testée, Résultat = -1529,10€ malgré 77% de trades gagnants. Le problème est que le gain moyen est de 8,58€ pour une perte moyenne de -35,14. Le ratio Gais/Pertes est très bas à 0,84
Dommage que je ne puisse pas joindre à mon commentaire les copies d'écran de résultat
REM CAC 40 SPREAD 1 Timeframe prooder 5 secondes
DEFPARAM cumulateOrders = FALSE
defparam preloadbars= 10000
timeframe (3 minute)
if time<090000 or time>173000 then
journee=0
else
journee=1
endif
SignalPeriod = 30
ArrowPeriod = 2
achat=0
vente=0
capital=1000
capital2=capital+STRATEGYPROFIT[0]
taille=(capital2/(close*5.75/100))
n=taille
timeframe (21 minute)
if supertrend[3,10]>close then
trend21m=0
else
trend21m=1
endif
timeframe (3 minute)
bbup = average[signalperiod]+std[signalperiod]*arrowperiod
bbdn = average[signalperiod]-std[signalperiod]*arrowperiod
if ts=0 then
if close crosses over bbup then
ts=bbdn
trend=1
elsif close crosses under bbdn then
ts=bbup
trend=-1
endif
endif
if trend=1 then
ts=max(ts,bbdn)
elsif trend=-1 then
ts=min(ts,bbup)
endif
if trend=1 and close crosses under ts then
trend=-1
ts=bbup
r=255
g=0
achat=1
endif
if ((dayofweek=3 or dayofweek=5) and time<093500) or (dayofweek=5 and time>105000 and time<120000)or (dayofweek=1 and time>150000 and time<153000) or close>highest[100][1]-14 or (dayofweek=4 and trend21m=0 and time>130000 and time<140000) then
stopa=0
else
stopa=1
endif
if journee=1 and achat=1 and stopa=1 then
buy n contract at market
endif
if trend=-1 and close crosses over ts then
trend=1
ts=bbdn
r=0
g=255
vente=1
endif
if (time>130100 and time<143000) or (time>105500 and time<120000) or (time>145500 and time<151500) or (dayofweek=5 and time<090500) or close<lowest[2][1]+3 then
stopv=0
else
stopv=1
endif
if journee=1 and vente=1 and stopv=1 then
sellshort n contract at market
endif
set target profit 9
set stop loss 70
Short78
Too bad I can't attach to my comment the screenshots of the result
It's because this Thread is in the Library (you may know this).
You would have to raise a Topic in the Forum for Strategies in order to be able to attach images etc.