Solo MACD, senza DSS - Risultato.
io comunque sui TS almeno all'inizio i trailing stop non li metterei,
Deve essere performante senza.
Il problema sta nell'utilizzo della funzione crossover e crossunder che restituiscono true solo se la condizione si verifica sulla candela corrente. Ho modificato leggermente il codice per farti vedere quando le condizioni macdlong e dsslong sono vere entrambe contemporaneamente: praticamente mai. Spero di aver risposto al tuo dubbio.
//@version=4
strategy(title="DSS + MACD", shorttitle="DSS + MACD")
////////////////////////////
// DSS
PDS = input(10, minval=1)
EMAlen = input(9, minval=1)
TriggerLen = input(5, minval=1)
Overbought = input(80, minval=1)
Oversold = input(20, minval=1)
//hline(Overbought, color=color.green, linestyle=hline.style_solid)
//hline(Oversold, color=color.red, linestyle=hline.style_solid)
xPreCalc = ema(stoch(close, high, low, PDS), EMAlen)
xDSS = ema(stoch(xPreCalc, xPreCalc, xPreCalc, PDS), EMAlen)
//xDSS = stoch(xPreCalc, xPreCalc, xPreCalc, PDS)
////////////////////////////
// MACD
// STANDARD = 12 26 9
// SBIT = 48 72 6
fastLength = input(48)
slowlength = input(72)
MACDLength = input(6)
MACD = ema(close, fastLength) - ema(close, slowlength)
aMACD = ema(MACD, MACDLength)
delta = MACD - aMACD
//////////////////////////////////
// CONDIZIONI MACD
macdlong = crossover(delta, 0)
macdshort = crossunder(delta, 0)
//////////////////////////////////
// CONDIZIONI DSS
dsslong = xDSS <= 10
dssshort = xDSS >= 90
dssexitlong = xDSS >= 80
dssexitshort = xDSS <= 20
//////////////////////////// VIEW
if (dsslong == true and macdlong == true)
strategy.entry("LONG", strategy.long)
if (dssshort == true and macdshort == true)
strategy.entry("SHORT", strategy.short)
if (dssexitlong == true)
strategy.close("LONG")
if (dssexitshort == true)
strategy.close("SHORT")
plot(dsslong ? 1 : 0, color=color.green, title="DSS")
plot(macdlong ? 1 : 0, color=color.yellow, title="DSS")