zelibobla

Keltner bounce from border. No repaint. (by Zelibobla)

WARNING: despite of strategy doesn't use future data (not repaints) it doesn't consider broker`s commissions, which can be harmful for real life high frequency trading.
Strategy works well on ES futures short bars like 1min.
สคริปต์โอเพนซอร์ซ

ด้วยจิตวิญญาณของ TradingView อย่างแท้จริง ผู้เขียนสคริปต์นี้ได้เผยแพร่เป็นโอเพนซอร์ส เพื่อให้ผู้ค้าสามารถเข้าใจและตรวจสอบได้ ไชโยให้กับผู้เขียน! คุณสามารถใช้ได้ฟรี แต่การใช้รหัสนี้ซ้ำในสิ่งพิมพ์อยู่ภายใต้กฎระเบียบการใช้งาน คุณสามารถตั้งเป็นรายการโปรดเพื่อใช้บนชาร์ตได้

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมที่ เงื่อนไขการใช้บริการ

ต้องการที่จะใช้สคริปต์นี้บนชาร์ตใช่ไหม?
//@version=2
strategy("Keltner bounce from border. No repaint. (by Zelibobla)", shorttitle="Keltner border bounce", overlay=true)

price = open

// build Keltner
keltnerLength = input(defval=20, minval=1, title="Keltner EMA Period Length")
keltnerDeviation = input(defval=2, minval=1, maxval=5, title="Keltner band width (in ATRs)")
closeOnEMATouch = input(type=bool, defval=false, title="Close trade on EMA touch? (less drawdown, but less profit and higher commissions impact)")
EMA = sma(price, keltnerLength)
ATR = atr(keltnerLength)
top = EMA + ATR * keltnerDeviation
bottom = EMA - ATR * keltnerDeviation

buyEntry = crossover(price, bottom)
sellEntry = crossunder(price, top)
plot(EMA, color=aqua,title="EMA")
p1 = plot(top, color=silver,title="Keltner top")
p2 = plot(bottom, color=silver,title="Keltner bottom")
fill(p1, p2)

if ( crossover(price, bottom))
    strategy.entry("BUY", strategy.long, stop=bottom, oca_type=strategy.oca.cancel, comment="BUY")

if( crossover(price,EMA) and closeOnEMATouch )
    strategy.close("BUY")
    
if ( crossunder(price, top))
    strategy.entry("SELL", strategy.short, stop=top, oca_type=strategy.oca.cancel, comment="SELL")
if( crossunder(price, EMA) and  closeOnEMATouch )
    strategy.close("SELL")