本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//BeehiveTrader|Retail Insider -> Feel free to use this indicator.
// Disclaimer: This is not financial advice. make sure that you understand the risks properly before taking any trades.
//@version = 5
indicator('Retail Insider Trend Following (HTF ONLY)', overlay=true)
var table bee = table.new(position.bottom_right, 20, 20)
b = "BEEHIVETRADER"
table.cell(bee, 0, 0, (b), text_color = color.yellow)
// ****************** INPUTS ******************
barcount = input.int(38, title='Enter number of Bars', minval=1)
offset = input.float(5, title='offset (useful for Stoploss/Confirmation, in %', minval =1, maxval =100)
tf1 = input.timeframe(title = "Timeframe for B33", defval = "15")
hh = ta.highest((high), barcount)
ll = ta.lowest((low), barcount)
mp = input.int(38, title = "RMA for bar average") //RMA for bar average (used for B33)
ma_inp = input.int(18, title = "Enter Moving Average filter period")
hh1 = request.security(syminfo.tickerid, tf1, hh, gaps=barmerge.gaps_on) //Highest point TF1
ll1 = request.security(syminfo.tickerid, tf1, ll, gaps=barmerge.gaps_on) //Lowest point TF11
show_ma = input.bool(false, title = "Show MA?")
show_brup= input.bool(true, title = "Show Trend change Breakouts?")
show_brdn= input.bool(true, title = "Show Trend change Breakdowns?")
B33mean = (ta.rma(hh1, mp)+ta.rma(ll1, mp))/2 //B33Mean
B33Offup = (B33mean+(close*(offset/100))) //B33Offset up
B33Offdn = (B33mean-(close*(offset/100))) //B33Offset down
plot(B33mean, color = color.red, linewidth = 3) //----------------------MAIN
plot(B33Offup, color = color.yellow, linewidth = 1) //positive Offset for B33
plot(B33Offdn, color = color.yellow, linewidth = 1) //Negative Offset for B33
trend = ta.ema(close, ma_inp)
plot((show_ma ? trend : na), color = color.fuchsia, linewidth = 4)
// 1 ) Bull Market Breakout/Trend Change
Trend_up = trend>B33Offup
B33Trendup = ta.crossover(trend, B33Offup)
Bull_Breakout = ta.crossover(trend, B33Offup)
if B33Trendup
table.cell(bee, 0, 1, "Current Trend (HTF): UP", text_color = color.lime)
//2 ) Bear Market Breakdown/Trend Change
Trend_dn = trend<B33Offdn
B33Trenddown = ta.crossunder(trend, B33Offdn)
Bear_Breakdown = ta.crossunder(trend, B33Offdn)
if B33Trenddown
table.cell(bee, 0, 1, "Current Trend (HTF): Down", text_color = color.red)
// Plots
plotshape(show_brup?Bull_Breakout:na, text='TREND CHANGE BREAKOUT (+)', title='Bull', style=shape.labelup, color=color.new(color.lime, 0), textcolor=color.new(color.black, 0), location=location.belowbar)
plotshape(show_brdn?Bear_Breakdown:na, text='TREND CHANGE BREAKDOWN (-)', title='Bear', style=shape.labeldown, color=color.new(color.red, 0), textcolor=color.new(color.black, 0), location=location.abovebar)
// Alerts
alertcondition(Bull_Breakout , title="Trend Change Breakout Alert", message="HTF Trend Change alert, 1D and 4H (Bullish): {{ticker}}")
alertcondition(Bear_Breakdown , title="Trend Change Breakdown Alert", message="HTF Trend Change alert, 1D and 4H (Bearish): {{ticker}}")