JBI

Strategy Backtest Kit

34
Strategy Backtest Kit. You have just to define your own entry / exit setups. The strategy I have coded into this is : BUY when MACD > 0 / SELL when MACD < 0. Always in position.
Follow JBI for his daily analyses!
Script open-source

Dans le véritable esprit de TradingView, l'auteur de ce script l'a publié en open-source, afin que les traders puissent le comprendre et le vérifier. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais la réutilisation de ce code dans une publication est régie par le règlement. Vous pouvez le mettre en favori pour l'utiliser sur un graphique.

Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.

Vous voulez utiliser ce script sur un graphique ?
study(title = "Strategy Backtest Kit", overlay = false)

/// PROGRAMMED BY JBI FOR TRADINGVIEW


percentual = input(true, title = "Percentual Income")
testlen = input(100, title = "Test Length")
show = input(true, title = "Show W/L ratio?")
// DEFINE ENTRY TO LONG POSITION
entryUP = ema(close, 12) > ema(close, 26)
// DEFINE ENTRY TO SHORT POSITION
entryDOWN = not entryUP

// DEFINE EXIT FROM LONG POSITION
exitUP = entryDOWN
// DEFINE EXIT FROM SHORT POSITION
exitDOWN = entryUP



///// Do not change this

entry1 = entryUP and not entryUP[1] ? 1 : 0
entry2 = entryDOWN and not entryDOWN[1] ? 1 : 0

exit1 = exitUP ? 1 : 0
exit2 = exitDOWN ? 1 : 0


up = entry1 ? close : exit1 and up[1] != -111 ? -111 : up[1]
down = entry2 ? close : exit2 and down[1] != -111 ? -111 : down[1]

output1 = exit1 and up[1] != -111 and percentual ? ((close - up[1]) / up[1]) : exit1 and up[1] != -111 and not percentual ? (close - up[1]) : 0
output2 = exit2 and down[1] != -111 and percentual ? ((down[1] - close) / down[1]) : exit2 and down[1] != -111 and not percentual ? (down[1] - close) : 0

otpt = output1 + output2

wlr = otpt != 0 and otpt > 0 ? 1 : 0


output = sum((otpt), testlen)
entries = sum((entry1 + entry2), testlen)
wlrf = sum((wlr), testlen)

///// Do not change this


wlrfinal = show ? wlrf / entries : na

plot(wlrfinal, title = "Percent of winning trades")
plot(output, title = "Brutto Income")