Reversal indicator

Fun_Trades · study · 45 行 · 点赞 2,219 · TradingView 原页

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

Pine Script

// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © FunStriker
 
//@version=6
indicator("Reversal Indicator", shorttitle = "Reversal", overlay = true)
 
// GET USEER INPUT
    // SMA INPUT 
sma_Length      = input.int(50, "Higher Timeframe SMA Length")
higher_Tf       = input.timeframe(defval = "60" , title = "Higher Timeframe for SMA")
show_higher_Tf_sma = input.bool(true, "Show SMA")
    // RSI INPUT 
rsi_Length      = input.int(14, "RSI Length")
lower_Tf        = input.timeframe(defval = "5" , title = "Lower Timeframe for RSI")
rsi_overbought  = input.float(70.0, "Overbought level RSI")
rsi_oversold    = input.float(30.0, "Oversold level RSI")
 
// HIGHER TIMEFRAME SMA 
higher_Tf_sma  = request.security(syminfo.tickerid, higher_Tf, ta.sma(close, sma_Length))
 
// Lower Tf rsi but hidden 
lower_Tf_rsi  = request.security(syminfo.tickerid, lower_Tf, ta.rsi(close, rsi_Length))
 
 
// FURTHER CONFLUATION 
is_oversold     = lower_Tf_rsi < rsi_oversold
is_overbought   = lower_Tf_rsi > rsi_overbought
bullish_Engulf  = low[2] > low[1] and low[1] < low and close[1] > open[1] and close > high[2]
bearish_Engulf  = high[2] < high[1] and high[1] > high and close[1] < open[1] and close < low[2]
above_sma       = close[1] > higher_Tf_sma
below_sma       = close[1] < higher_Tf_sma
 
// Signals
bullish_Signal = is_oversold and bullish_Engulf and below_sma
bearish_Signal = is_overbought and bearish_Engulf and above_sma 
 
// PLOT 
plot(show_higher_Tf_sma ? higher_Tf_sma : na, "Higher TF SMA", linewidth = 2, color = color.white, force_overlay = true)
// Plot 
plotshape(bullish_Signal, "Bullish Pattern", shape.triangleup, size = size.small, offset = -1, location = location.belowbar, color = color.green)
plotshape(bearish_Signal, "Bearish Pattern", shape.triangledown, size = size.small, offset = -1, location = location.abovebar, color = color.red)
 
// ALERTS 
alertcondition(bullish_Signal, "Bullish Signal detected")
alertcondition(bearish_Signal, "Bearish Signal detected")

← 返回列表