簡體   English   中英

使用更高時間范圍的 RSI 過濾警報

[英]Filtering alerts using higher timeframe RSI

我試圖弄清楚是否可以用現有的 pine 腳本做一些事情。

使用 15 分鍾圖表,我希望僅在 4 小時 RSI 高於 45 且 8 小時 RSI 低於 60 時生成買入/賣出信號。

這可能嗎?

在此先感謝您的幫助:)

study(title="8EMA", shorttitle="8EMA", overlay = true)

EMA1 = input(8, minval=1, title="EMA1")
EMA2 = input(13, minval=1, title="EMA2"),
EMA3 = input(21, minval=1, title="EMA3")
EMA4 = input(34, minval=1, title="EMA4"),
EMA5 = input(55, minval=1, title="EMA5")
EMA6 = input(89, minval=1, title="EMA6")
EMA7 = input(144, minval=1, title="EMA7")
EMA8 = input(233, minval=1, title="EMA8")

plot(ema(close, EMA1), color=green, linewidth=2)
plot(ema(close, EMA2), color=white, linewidth=2)
plot(ema(close, EMA3), color=gray, linewidth=2)
plot(ema(close, EMA4), color=blue, linewidth=2)
plot(ema(close, EMA5), color=red, linewidth=2)
plot(ema(close, EMA6), color=orange, linewidth=2)
plot(ema(close, EMA7), color=yellow, linewidth=2)
plot(ema(close, EMA8), color=purple, linewidth=2)

leftBars = input(4)
rightBars = input(2)

swh = pivothigh(leftBars, rightBars)
swl = pivotlow(leftBars, rightBars)

swh_cond = not na(swh)

hprice = 0.0
hprice := swh_cond ? swh : hprice[1]

le = false
le := swh_cond ? true : (le[1] and high > hprice ? false : le[1])

swl_cond = not na(swl)

lprice = 0.0
lprice := swl_cond ? swl : lprice[1]


se = false
se := swl_cond ? true : (se[1] and low < lprice ? false : se[1])

// Filter out signals if opposite signal is also on
se_filtered = se and not le
le_filtered = le and not se

// Filter consecutive entries 
prev = 0
prev := se_filtered ? 1 : le_filtered ? -1 : prev[1]

se_final = se_filtered and prev[1] == -1
le_final = le_filtered and prev[1] == 1

plotshape(se_final, color=green, text = "BUY", style=shape.triangleup,location=location.belowbar)
plotshape(le_final, color=red, text = "SELL", style=shape.triangledown,location=location.abovebar)

alertcondition(se_final, "BUY-Autoview", "")
alertcondition(le_final, "SELL-Autoview", "")```

您可以使用security()函數從其他時間范圍請求數據。

//@version=5
indicator("request.security")
expr = ta.rsi(close, 14)
s1 = request.security(syminfo.tickerid, "240", expr) // 240 Minutes
plot(s1)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM