BINANCE:BTCUSDT.P   Bitcoin / TetherUS PERPETUAL CONTRACT


//@version=5
strategy(title="Peaky Blinders",overlay=true, default_qty_type=strategy.cash, commission_value= 0.05, commission_type=strategy.commission.percent, slippage=1, currency=currency.USDT, default_qty_value= 10000, initial_capital= 10000)

//input
p = input.int(10, minval=1)
x = input.int(1, minval=1)
q = input.int(9, minval=1)
n = input.int(120,title="Basic guides line")
trail_points= input.int(6, minval=1)
trail_offset= input.int(1, minval=1)

// SMA
sma12 = ta.sma(close, 12)
sma16 = ta.sma(close, 16)
sma20 = ta.sma(close, 20)
sma24 = ta.sma(close, 24)
sma28 = ta.sma(close, 28)
sma32 = ta.sma(close, 32)
sma36 = ta.sma(close, 36)
sma40 = ta.sma(close, 40)
sma44 = ta.sma(close, 44)
sma48 = ta.sma(close, 48)
sma52 = ta.sma(close, 52)
sma56 = ta.sma(close, 56)
sma60 = ta.sma(close, 60)
sma64 = ta.sma(close, 64)
sma68 = ta.sma(close, 68)
sma72 = ta.sma(close, 72)
sma76 = ta.sma(close, 76)
sma80 = ta.sma(close, 80)
sma84 = ta.sma(close, 84)
sma88 = ta.sma(close, 88)
sma92 = ta.sma(close, 92)
sma96 = ta.sma(close, 96)
sma100 = ta.sma(close, 100)
sma104 = ta.sma(close, 104)
sma108 = ta.sma(close, 108)
sma112 = ta.sma(close, 112)
sma116 = ta.sma(close, 116)
sma120 = ta.sma(close, 120)

// Bullish and bearish patterns
bullish = sma20 > sma60 and sma60 > sma120
bearish = sma20 < sma60 and sma60 < sma120
color = bullish ? #ADD8E6 : bearish ? #FDBCB4 : #D3D3D3

//plot
//Basic guides can be replaced with other guides
basic_line = ta.ema(close,n)
bias = (close - basic_line) / basic_line * 100
//
first_high_stop = ta.highest(high, p) - x * ta.atr(p)
first_low_stop = ta.lowest(low, p) + x * ta.atr(p)
stop_short = ta.highest(first_high_stop, q)
stop_long = ta.lowest(first_low_stop, q)
plot(stop_long, color=#2962FF)
plot(stop_short, color=#FF6D00)
// Plot SMA
plot(sma12, color=color)
plot(sma16, color=color)
plot(sma20, color=color)
plot(sma24, color=color)
plot(sma28, color=color)
plot(sma32, color=color)
plot(sma36, color=color)
plot(sma40, color=color)
plot(sma44, color=color)
plot(sma48, color=color)
plot(sma52, color=color)
plot(sma56, color=color)
plot(sma60, color=color)
plot(sma64, color=color)
plot(sma68, color=color)
plot(sma72, color=color)
plot(sma76, color=color)
plot(sma80, color=color)
plot(sma84, color=color)
plot(sma88, color=color)
plot(sma92, color=color)
plot(sma96, color=color)
plot(sma100, color=color)
plot(sma104, color=color)
plot(sma108, color=color)
plot(sma112, color=color)
plot(sma116, color=color)
plot(sma120, color=color)


//single
RSI=ta.rsi(close,14)
BUY=sma12>sma16 and sma12>sma20 and sma12>sma24 and sma16>sma20 and sma16>sma24 and ta.rising(close,2) and RSI<65
SELL=sma12<sma16 and sma12<sma20 and sma12<sma24 and sma16<sma20 and sma16<sma24 and ta.falling(close,2) and RSI>31

if not strategy.opentrades
// Long Strategy
if BUY
strategy.entry("Long", strategy.long)
strategy.exit("exit", "Long", stop=stop_long, trail_points=trail_points, trail_offset=trail_offset)

// Short Strategy
if SELL
strategy.entry("Short", strategy.short)
strategy.exit("exit","Short", stop=stop_short, trail_points=trail_points, trail_offset=trail_offset)

评论:
啊啊
免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。