BINANCE:BTCUSDT   Bitcoin / TetherUS
**大资金模型**

市场中的大资金通常被称为鲸鱼。 鲸鱼可以对各种市场的价格走势产生重大影响。 因此,如何监测鲸鱼走势,无论从哪方面都具有重要意义。

**大资金波段主图**
为了更直接地了解大资金,发布了一个大资金模型应用于主图表,作为不同颜色的蜡烛,以及分别以黄色、紫红色和浅绿色显示的短期、中期、长期移动平均线。 大资金模型是由一条快线EMA2,一条慢线EMA42用xsl(close,21))*(20)+close人工曲线拟合而成,其中xsl用于计算数据序列的斜率。 然后,根据黄金交叉和死交叉状态的定义,大资金行为可以提取为绿色蜡烛看涨,红色蜡烛看跌。 同时,一种新型的黄色蜡烛被定义为代表看涨摆动的开始。


**源代码**


// This source code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org/MPL/2.0/
// © blackcat1402
//@version=4

study(" L3 Banker Fund Swing"," L3 Banker Fund Swing", overlay=true, max_bars_back=5000, max_labels_count =500)

xrf(values, length) =>
r_val = float(na)
if length >= 1
for i = 0 to length by 1
if na(r_val) or not na(values)
r_val := values
r_val
r_val

bton(b) =>
b ? 1 : 0


xsa(src, len, wei) =>
sum = 0.0
ma = 0.0
out = 0.0
sum := nz(sum) - nz(src) + src
ma := na(src) ? na : sum / len
//return xsa in tdx
out := na(out) ? ma : (src * wei + out * (len - wei)) / len
out

xsl(src, len) =>
out = 0.0
lrc = linreg(src, len, 0)
lrprev = linreg(src, len, 0)
out := (lrc - lrprev) / timeframe.multiplier
out

ma5 = sma(close,5)
ma10 = sma(close,10)
ma30 = sma(close,30)

plot(ma5, color=color.new(color.yellow,50), linewidth = 2)
plot(ma10, color=color.new(color.fuchsia,50), linewidth = 2)
plot(ma30, color=color.new(color.aqua,50), linewidth = 2)

ma40 = sma(close,40)
ma60 = sma(close,60)
ma120 = sma(close,120)
angel = ema(close,2)
devil = ema((xsl(close,21))*(20)+close,42)

long = crossover(angel,devil)
short = crossunder(angel,devil)

// Plots labels
l = short ?
label.new (bar_index, high, "SELL", color=color.new(color.red,70), textcolor=color.white, style=label.style_labeldown, yloc=yloc.price, size=size.small) :
long ?
label.new (bar_index, low, "BUY", color=color.new(color.green,70), textcolor=color.white, style=label.style_labelup, yloc=yloc.price, size=size.small) :
na

plotcandle(open, high, low, close, title='candle_color', color = (angel>=devil) ? color.green : color.red, wickcolor= (angel>=devil) ? color.green : color.red)
plotcandle(open, high, low, close, title='candle_golden', color = crossover(angel,devil) ? color.yellow : na, wickcolor= crossover(angel,devil) ? color.yellow : na)

rma10 = sma(close,10)
rma20 = sma(close,20)
rma40 = sma(close,40)
rma60 = sma(close,60)
rma120 = sma(close,120)
rangel = ema(close,2)
rdevil = ema((xsl(close,21))*(20)+close,42)
lbuy = cross(angel,devil)

n = input(7, "short term period")
m = input(5, "middle term period")

var1 = (close-lowest(low,60))/(highest(high,60)-lowest(low,60))*100
b = xsa(var1,n,1)
var2 = xsa(b,m,1)
mar1 = (2*close+high+low+open)/5
mar2 = lowest(low,34)
mar3 = highest(high,34)
sk = ema((mar1-mar2)/(mar3-mar2)*100,13)
ldb = b<=10 and sk<=10 and b>xrf(b,1) and sk>xrf(sk,1)

swing_buy = lbuy and ldb
plotcandle(open, high, low, close, title='bullish_swing_start', color = crossover(angel,devil) ? color.yellow : na, wickcolor= crossover(angel,devil) ? color.yellow : na)


**几个效果图**
BTC行情来自TradingView
XAUUSD行情来自TradingView
上证指数行情来自TradingView


Get Access to blackcat1402 blog: www.blackcat1402.blog/

Join blackcat1402 community: discord.com/invite/ZTGpQJq
免责声明

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