Clean Buy Sell Pro [v6]

JohnsonForexTrader · study · 97 行 · 点赞 141 · 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/
// © JohnsonForexTrader
 
//@version=6
indicator("Clean Buy Sell Pro [v6]", shorttitle="CBSP v6", overlay=true)
 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// SETTINGS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
groupTrend = "Trend Settings"
 
fastLength = input.int(20, "Fast EMA", minval=2, group=groupTrend)
slowLength = input.int(50, "Slow EMA", minval=5, group=groupTrend)
 
groupSignal = "Signal Settings"
 
useRSI = input.bool(true, "Use RSI Confirmation", group=groupSignal)
rsiLength = input.int(14, "RSI Length", minval=2, group=groupSignal)
 
showLabels = input.bool(true, "Show BUY / SELL", group=groupSignal)
 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// EMA TREND
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
fastEMA = ta.ema(close, fastLength)
slowEMA = ta.ema(close, slowLength)
 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// RSI
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
rsiValue = ta.rsi(close, rsiLength)
 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// BUY / SELL CONDITIONS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
bullTrend = fastEMA > slowEMA
bearTrend = fastEMA < slowEMA
 
bullMomentum = rsiValue > 50
bearMomentum = rsiValue < 50
 
buyCondition = bullTrend and close > fastEMA
 
sellCondition = bearTrend and close < fastEMA
 
if useRSI
    buyCondition := bullTrend and close > fastEMA and bullMomentum
    sellCondition := bearTrend and close < fastEMA and bearMomentum
 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// ONLY NEW SIGNAL
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
buySignal = buyCondition and not buyCondition[1]
sellSignal = sellCondition and not sellCondition[1]
 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// CLEAN CHART SIGNALS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
plotshape(
     showLabels and buySignal,
     title="BUY",
     style=shape.labelup,
     location=location.belowbar,
     color=color.lime,
     text="BUY",
     textcolor=color.black,
     size=size.tiny)
 
plotshape(
     showLabels and sellSignal,
     title="SELL",
     style=shape.labeldown,
     location=location.abovebar,
     color=color.red,
     text="SELL",
     textcolor=color.white,
     size=size.tiny)
 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// ALERTS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
alertcondition(
     buySignal,
     title="BUY Signal",
     message="Clean Buy Sell Pro: BUY signal detected.")
 
alertcondition(
     sellSignal,
     title="SELL Signal",
     message="Clean Buy Sell Pro: SELL signal detected.")

← 返回列表