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")