结合 STOCH RSI 和 Macd 进行策略

Combining STOCH RSI and Macd for strategy

我正在尝试为 pine 创建一个策略,它将使用 stoch rsi "k" 而不是 "close" 作为 macd。

如果您在图表上打开 STOCH RSI 指标并单击 3 个点,您可以 select "add indicator on..." 如果您这样做并添加 MACD,它会创建我想要的指标。虽然我无法弄清楚它的脚本,但我希望它是一种策略,其中 buy/sell 信号显示在图表蜡烛上。

如果有的话,我主要需要知道如何让macd像在指标中一样使用stoch rsi。你能为我指出正确的方向吗?或者,如果你知道怎么做,请为我编写脚本。

谢谢 泰勒

如果您想合并指标,请查看编辑器中的 "new" 选项和 select 您尝试合并的指标,以查看它们各自的代码。在您的情况下,您最终会得到以下脚本:

//@version=4
study(title="Stochastic RSI MACD")
src = input(close, title="RSI Source")
//Stoch RSI Settings
smoothK = input(3, minval=1)
lengthRSI = input(14, minval=1),lengthStoch = input(14, minval=1)
//MACD Settings
fastlen = input(12),slowlen = input(26),siglen = input(9)
//----
rsi1 = rsi(src, lengthRSI)
k = sma(stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
[fast,slow,hist] = macd(k,fastlen,slowlen,siglen)
//----
// Plot colors
col_grow_above = #26A69A
col_grow_below = #FFCDD2
col_fall_above = #B2DFDB
col_fall_below = #EF5350
col_macd = #0094ff
col_signal = #ff6a00
//----
plot(hist, title="Histogram", style=plot.style_columns, color=(hist>=0 ? (hist[1] < hist ? col_grow_above : col_fall_above) : 
  (hist[1] < hist ? col_grow_below : col_fall_below) ), transp=0 )
plot(fast, title="MACD", color=col_macd, transp=0)
plot(slow, title="Signal", color=col_signal, transp=0)