Ayano Full System v3

ayano_fx1 · study · 73 行 · 点赞 20 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

//@version=6
indicator("Ayano Full System v3", overlay=true)
 
lenTrend = input.int(200, "Trend SMA (SMA200)", minval=1)
lenEntry = input.int(20, "Entry SMA (SMA20)", minval=1)
tol = input.float(0.0, "Tolerance (price)", step=0.1)
 
useSMA20BodyBreak = input.bool(true, "Signal: SMA20 body break with SMA200 regime")
use2ndBounce = input.bool(true, "Signal: SMA20 2nd bounce (touch and reject)")
useOverExt = input.bool(true, "Signal: Overextension reversal")
useSMA200Cross = input.bool(true, "Signal: SMA200 body cross")
useSMA200Bounce = input.bool(true, "Signal: SMA200 bounce")
 
atrLen = input.int(14, "ATR length", minval=1)
distAtrMult = input.float(2.0, "OverExt threshold", minval=0.1, step=0.1)
 
sma200 = ta.sma(close, lenTrend)
sma20 = ta.sma(close, lenEntry)
atr = ta.atr(atrLen)
 
plot(sma200, color=color.blue, linewidth=2, title="SMA200")
plot(sma20, color=color.orange, linewidth=2, title="SMA20")
 
bodyLow = math.min(open, close)
bodyHigh = math.max(open, close)
bodyLowPrev = math.min(open[1], close[1])
bodyHighPrev = math.max(open[1], close[1])
 
above200 = close > sma200
below200 = close < sma200
 
buyBodyBreak20 = useSMA20BodyBreak and above200 and (bodyHighPrev < sma20 - tol) and (bodyLow > sma20 + tol)
sellBodyBreak20 = useSMA20BodyBreak and below200 and (bodyLowPrev > sma20 + tol) and (bodyHigh < sma20 - tol)
 
buyBounceEvent = above200 and (low <= sma20 - tol) and (close > sma20 + tol)
sellBounceEvent = below200 and (high >= sma20 + tol) and (close < sma20 - tol)
 
var int buyBounceCount = 0
var int sellBounceCount = 0
 
if not above200 or close < sma20
    buyBounceCount := 0
 
if not below200 or close > sma20
    sellBounceCount := 0
 
if buyBounceEvent
    buyBounceCount += 1
 
if sellBounceEvent
    sellBounceCount += 1
 
buy2ndBounce = use2ndBounce and buyBounceEvent and buyBounceCount >= 2
sell2ndBounce = use2ndBounce and sellBounceEvent and sellBounceCount >= 2
 
overExt = math.abs(sma20 - sma200) > atr * distAtrMult
sellReversal = useOverExt and overExt and above200 and (bodyLowPrev > sma20 + tol) and (bodyHigh < sma20 - tol)
buyReversal = useOverExt and overExt and below200 and (bodyHighPrev < sma20 - tol) and (bodyLow > sma20 + tol)
 
longCross200 = useSMA200Cross and (bodyHighPrev < sma200 - tol) and (bodyLow > sma200 + tol)
shortCross200 = useSMA200Cross and (bodyLowPrev > sma200 + tol) and (bodyHigh < sma200 - tol)
 
buyBounce200 = useSMA200Bounce and above200 and (low <= sma200 - tol) and (close > sma200 + tol)
sellBounce200 = useSMA200Bounce and below200 and (high >= sma200 + tol) and (close < sma200 - tol)
 
buySignal = buyBodyBreak20 or buy2ndBounce or buyReversal or longCross200 or buyBounce200
sellSignal = sellBodyBreak20 or sell2ndBounce or sellReversal or shortCross200 or sellBounce200
 
plotshape(buySignal, title="BUY", style=shape.triangleup, location=location.belowbar, color=color.lime, text="BUY", textcolor=color.black, size=size.small)
plotshape(sellSignal, title="SELL", style=shape.triangledown, location=location.abovebar, color=color.red, text="SELL", textcolor=color.white, size=size.small)
 
alertcondition(buySignal, title="BUY Alert", message="BUY signal (Ayano Full System v3)")
alertcondition(sellSignal, title="SELL Alert", message="SELL signal (Ayano Full System v3)")

← 返回列表