cette strategie simple de TradingView , basée sur le croisement de 2 lignes donne des resultats backtests assez interessants que je souhaite utiliser sur PRT
Code TradingView
//@version=4
strategy(“SSL Channel Cross”, overlay=true)
period=input(title=”Period”, defval=10)
len=input(title=”Period”, defval=10)
smaHigh=sma(high, len)
smaLow=sma(low, len)
Hlv = 0
Hlv := close > smaHigh ? 1 : close < smaLow ? -1 : Hlv[1]
sslDown = Hlv < 0 ? smaHigh: smaLow
sslUp = Hlv < 0 ? smaLow : smaHigh
plot(sslDown, linewidth=2, color=color.red)
plot(sslUp, linewidth=2, color=color.lime)
longCondition = crossover(sslUp, sslDown)
shortCondition = crossunder(sslUp, sslDown)
if (longCondition)
strategy.close("Short", strategy.long)
strategy.entry("Long", strategy.long)
if (shortCondition)
strategy.close("Long", strategy.long)
strategy.entry("Short", strategy.short)
Merci d'avance
Il s’agit d’une stratégie basé sur un ‘activator’, genre cette indicateur : https://www.prorealcode.com/prorealtime-indicators/gann-hilo-activator/
Si le Close croise la ligne du dessus, alors on est en tendance haussière et vice versa, on peut créer ces lignes avec beaucoup d’autres choses (exemple un Donchian: https://www.prorealcode.com/prorealtime-indicators/donchian-channel-activator-factor/ ou des Bandes de Bollinger: https://www.prorealcode.com/prorealtime-indicators/bbands-stop/), ici ce sont des MA calculés sur les High et Low sur les X dernières périodes.
Ci-dessous la stratégie.
defparam cumulateorders=false
len=10//input(title="Period", defval=10)
smaHigh=average[len](high)//sma(high, len)
smaLow=average[len](low)//sma(low, len)
Hlv = 0
//Hlv :=
if close > smaHigh then
hlv= 1
elsif close < smaLow then
hlv= -1
else
hlv = Hlv[1]
endif
//sslDown
if Hlv < 0 then
ssldown= smahigh
else
ssldown=smalow
endif
//sslUp
if Hlv < 0 then
sslup = smaLow
else
sslup = smaHigh
endif
longCondition = sslup crosses over sslDown
shortCondition = sslup crosses under sslDown
if longCondition then
buy at market
endif
if shortCondition then
sellshort at market
endif
graphonprice ssldown coloured("red")
graphonprice sslup coloured("green")