patrickestarian

Trend, Stoch, Price Action or in short: TSP

Combining the three most important factors that a trader usually needs in a single indicator.

Red = Trend
Blue = Stoch
Orange = Price Action

开源脚本

本着真正的TradingView精神,该脚本的作者将其开源发布,以便交易者可以理解和验证它。为作者喝彩!您可以免费使用它,但在出版物中重复使用此代码受网站规则的约束。 您可以收藏它以在图表上使用。

免责声明

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

想在图表上使用此脚本?
study(title="Trend, Stoch, Price Action", shorttitle="TSP")

len1 = input(200)

lenStoch = input(14)
lenK = input(3)

hb = input(75)
lb = input(-75)

len2 = len1 / 4
len3 = len2 / 2
len4 = len3 /2
len5 = len4 / 2
len6 = len5 / 2

hline(lb)
hline(0)
hline(hb)

o = open
h = high
l = low
c = close
m = (l + h) / 2
r = h - l
v = volume

hhll_ = (l-l[1]) / r[1] + (h-h[1]) / r[1]
hhll = (hhll_ > 1) ? 1 : (hhll_ < -1) ? -1 : hhll_
// expand / contract
exct = (c > o) ? abs(r / r[1]) : -abs(r / r[1])
// close vs range
cvsr = (c - m) / r * 2
// close vs open
cvso = (c-o)/r
t1 = (hhll + exct + cvsr + cvso) / 4

plot(sma(t1*50, lenK), color=orange)

ma1 = sma(c, len1)
ma2 = sma(c, len2)
ma3 = ema(c, len3)
ma4 = ema(c, len4)

p1 = (ma1 > ma1[1]) ? 1 : (ma1 < ma1[1]) ? -1 : 0
p2 = (ma2 > ma2[1]) ? 1 : (ma2 < ma2[1]) ? -1 : 0
p3 = (ma3 > ma3[1]) ? 1 : (ma3 < ma3[1]) ? -1 : 0

pma1 = (ma2 > ma1) ? 1 : (ma2 < ma1) ? -1 : 0
pma2 = (ma3 > ma2) ? 1 : (ma3 < ma2) ? -1 : 0

pu1 = (p1 > 0 and l > ma1) ? 1 : (p1 > 0 and c > ma1) ? 0.5 : 0
pd1 = (p1 < 0 and h < ma1) ? -1 : (p1 < 0 and c < ma1) ? -0.5 : 0

pu2 = (p2 > 0 and l > ma2) ? 1 : (p2 > 0 and c > ma2) ? 0.5 : 0
pd2 = (p2 < 0 and h < ma2) ? -1 : (p2 < 0 and c < ma2) ? -0.5 : 0

pu3 = (p3 > 0 and l > ma3) ? 1 : (p3 > 0 and c > ma3) ? 0.5 : 0
pd3 = (p3 < 0 and h < ma3) ? -1 : (p3 < 0 and c < ma3) ? -0.5 : 0

tma1 = p1 + pu1 + pd1
tma2 = p2 + pu2 + pd2
tma3 = p3 + pu3 + pd3

t2 = (tma1 + tma2 + tma3 + pma1 + pma2) / 5

obv = (c > o) ? v : -v
//obv = sum(volpn, len)
vl = lowest(obv, len5)
vh = highest(obv, len5)
t3 = nz((obv-vl) / (vh - vl) * 0.5)

t = t1*2 + t2 + t3*0

ta = ema(ema(t, len5), len6) * 30
talr = linreg(ta, len5, 0)

tclr = (talr > talr[1]) ? green : red 


ll = lowest(l, lenStoch)
hh = highest(h, lenStoch)
st = (c-ll) / (hh - ll) * 200 - 100
k = linreg(sma(st, lenK), lenK, 0)
//k = sma(st, lenK)

//sclr = (k > k[1]) ? green : red
//clr = (talr>talr[1] and lowest(k, len5)<lb) ? green : ((talr<0 and talr[1]>0) or (highest(k, len5)>hb and k<hb)) ? red : white
//plot(0, color=clr, style=circles, linewidth=2)

plot(talr, color=red)
plot(k, color=navy)