You are on page 1of 2

//@version=4

study("[INICIA CRYPTO] TREDS DETECTORES DE BALEIAS", overlay=false)

//functions
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[i])
r_val := values[i]
r_val
r_val

xsa(src,len,wei) =>
sumf = 0.0
ma = 0.0
out = 0.0
sumf := nz(sumf[1]) - nz(src[len]) + src
ma := na(src[len]) ? na : sumf/len
out := na(out[1]) ? ma : (src*wei+out[1]*(len-wei))/len
out

//trend follower algorithm


var2 = xrf(low,1)
var3 = xsa(abs(low-var2),3,1)/xsa(max(low-var2,0),3,1)*100
var4 = ema(iff(close*1.2,var3*10,var3/10),3)
var5 = lowest(low,30)
var6 = highest(var4,30)
var7 = iff(lowest(low,58),1,0)
var8 = ema(iff(low<=var5,(var4+var6*2)/2,0),3)/618*var7
var9 = iff(var8>100,100,var8)
var5x = lowest(low,75)
var6x = highest(high,75)
var7x = (var6x-var5x)/100
var8x = xsa((close-var5x)-var7x,20,1)
vara = 3*var8x-2*xsa(var8x,15,1)
var26 = (close-lowest(low,27))/(highest(high,27)-lowest(low,27))*100
var28 = xsa(var26,3,1)
trendfollower = alma((close-sma(close,40))/sma(close,40)*100,5,0.85,6)*10
pf = plot(trendfollower,color=color.white,linewidth=1)
ps = plot(trendfollower[2],color=color.yellow,linewidth=1)
fill(pf,ps,color=trendfollower>trendfollower[2]?color.yellow:color.fuchsia,transp=0)

//whale pump detector


plotcandle(0,var8,0,var8,color=var8>0?color.yellow:na)
//crossunder zero zone for sell in red
plotcandle(-5,5,-5,5,color=crossunder(trendfollower,16.5)?color.red:na)
plotcandle(-5,5,-5,5,color=crossunder(trendfollower,40)?color.red:na)
plotcandle(-5,5,-5,5,color=crossunder(trendfollower,20)?color.red:na)
//crossover zero zone for buy in green
plotcandle(-5,5,-5,5,color=crossover(trendfollower,16.5)?color.green:na)
plotcandle(-5,5,-5,5,color=crossover(trendfollower,40)?color.green:na)
plotcandle(-5,5,-5,5,color=crossover(trendfollower,20)?color.green:na)

You might also like