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!
סקריפט קוד פתוח

ברוח TradingView אמיתית, מחבר הסקריפט הזה פרסם אותו בקוד פתוח, כך שסוחרים יכולים להבין ולאמת אותו. כל הכבוד למחבר! אתה יכול להשתמש בו בחינם, אך שימוש חוזר בקוד זה בפרסום כפוף לכללי הבית. אתה יכול להכניס אותו למועדפים כדי להשתמש בו בגרף.

כתב ויתור

המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.

רוצה להשתמש בסקריפ זה בגרף?
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")