VSA Screener recognizing patterns and SOSBar and SOWBar bars.
1 = SOSBar bars upward strength
2 = SOWBar bars or signs of downward strength.
All bullish or bearish move has to be confirmed by the next bar indicator and signals you can find in this page: TAC VSA BAR SIGNALS V1.1.
//defparam calculateonlastbars=2000
Subasta=0
vol=volume/10
If Subasta=1 then
b=close > low and volume > high
ce=close < high and volume > low
if b or ce then
v=volume
else
v=0
endif
endif
if Subasta=0 then
v=volume
endif
MediaVol=60
volAvg=average[MediaVol](v)
TLL = LinearRegressionSlope[40](close)
//============================================= EURO =======================================
// =
// =
//===========================================================================================
if vol>(4*volAvg) then
Volpos=1
elsif v>(3*volAvg) then
Volpos=1
elsif v>(volAvg) then
Volpos=2
Volpos=3
elsif v<(volAvg) then
Volpos=4
elsif v<(volAvg)*0.5 then
Volpos=5
else
Volpos=0
endif
//============================================= END VOLUME =================================
// =
// =
//===========================================================================================
spread = (high-low)
avgSpread = average[40](spread)[1]
widerangebar= (spread >avgSpread*1.8)
widerangebarmid= (spread >avgSpread*1.5)
narrowrangebar= spread < AvgSpread*0.7
upbar = close>close[1]
downbar= close<close[1]
//upclose = close>=((spread*0.7)+low)// close is above 70% of the bar
//downclose = close<=((spread*0.3)+low)// close is below the 30% of the bar
//aboveclose = close>((spread*0.5)+low)// close is between 50% and 70% of the bar
//belowclose = close<((spread*0.5)+low)// close is between 50% and 30% of the bar
//midclose = close>((spread*0.3)+low) and close<((spread*0.7)+l)// close is between 30% and 70% of the bar
upclose = close>=((spread*0.7)+low)// close is above 70% of the bar
downclose = close<=((spread*0.3)+low)// close is below the 30% of the bar
midclose = close>=((spread*0.3)+low) and close<=((spread*0.7)+low)// close is between 30% and 70% of the bar
if close<=((spread*0.2)+low) then
ClosePos =1
elsif close<=((spread*0.4)+low)then
ClosePos =2
elsif close<=((spread*0.6)+low)then
ClosePos =3
elsif close<=((spread*0.8)+low)then
ClosePos =4
ClosePos =5
else
ClosePos =0
endif
//========================trend estimation =========================
//minpRWIs = 1
//maxpRWIs = 5
RWIHi=0
RWILo=0
i=5
//RWIHi=(high-low[i])/((averagetruerange[i](close[0]))*SQRT(i))/RWIHi=MAX((high-low[i])/((averagetruerange[i](close[0]))*SQRT(i)),RWIHi)
//RWILo=(high[i]-low)/((averagetruerange[i](close[0]))*sqrt(i))/RWILo=MAX((high[i]-low)/((averagetruerange[i](close[0]))*sqrt(i)),RWILo)
RWIHi=(high-low[i])/((averagetruerange[i](close[0]))/SQRT(i))
RWILo=(high[i]-low)/((averagetruerange[i](close[0]))/sqrt(i))
RWIHi=Max(RWIHi,RWIHi)
RWILo=Max(RWILo,RWILo)
//k = RWIHi- RWILo
ground = RWIHi
//minpRWIl = 1
//maxpRWIl = 20
ix=25
//RWIHi=(high-low[i])/((averagetruerange[i](close[0]))*SQRT(i))/RWIHi=MAX((high-low[i])/((averagetruerange[i](close[0]))*SQRT(i)),RWIHi)
//RWILo=(high[i]-low)/((averagetruerange[i](close[0]))*sqrt(i))/RWILo=MAX((high[i]-low)/((averagetruerange[i](close[0]))*sqrt(i)),RWILo)
RWIHi=(high-low[ix])/((averagetruerange[ix](close[0]))/SQRT(ix))
RWILo=(high[ix]-low)/((averagetruerange[ix](close[0]))/sqrt(ix))
RWIHi=Max(RWIHi,RWIHi)
RWILo=Max(RWILo,RWILo)
j = RWIHi-RWILo
j2 = RWIHi
If ground > 1 then
upimd=1
else
upimd=0
endif
If j>1 then
upmajor = 1
elsIf j<1 then
upmajor =-1
else
upmajor=0
endif
If j2>1 then
upminor=1
else
upminor=-1
endif
//======================================================================|
// VSA Signal generation |
//======================================================================|
upthrustbar = ( wideRangeBar and (ClosePos=1 or ClosePos=2) and upminor>0 and high>high[1] and (upimd>0 or upmajor>0)and Volpos <4)
upthrustbartrue = wideRangeBar and ClosePos=1 and upmajor>0 and high>high[1] and Volpos <4
upthrustcond1 = upthrustbar[1] and downbar and not narrowrangebar
upThrustCond2 =upThrustBar[1] and downBar and Volpos = 2
upThrustCond3 =upThrustBar and Volpos =1
sellcond1 = (upthrustcond1 or upthrustcond2 or upthrustcond3)
sellCond2 =sellCond1[1]=0
sellcond = sellcond1 and sellcond2
strengthdown = volpos<4 and downbar[1] and upbar and closepos>3 and upimd<=0 and upminor<0// strength after a down trend
strengthdown1 = upmajor<0 and v>(volavg*1.5) and downbar[1] and upbar and closepos>3 and upminor<0 and upimd<=0//strength after downtrend . high v
buycond1 = strengthdown or strengthdown1
buycond = upbar and buycond1[1]
stopv =low=lowest[5](low) and (upClose or midClose) and v>4*volAvg and tll<0 and widerangebarmid and downbar
STOPPINGVOLUME=( downbar and low=lowest[20](low) and (widerangebar) and (midclose or upclose) and Volpos<3 )
revupthrust = tll<0 and upbar and upclose and v>v[1] and v>volavg and widerangebar and downbar[1] and downclose[1] and upminor<0
effortup =upbar and upclose and (widerangebar) and (Volpos<4 ) and close>=((high-low)*0.7+low) //and (coratio > midbodyratio) // checking for close near high
effortDown =( downbar and downclose and (widerangebar) and (Volpos<5) and low=lowest[5](low) )//and (coratio > midbodyratio) // checking for open near high
if Effortup or stopv or STOPPINGVOLUME or revupthrust or buycond then
x=1
elsif effortDown or upthrustbar or upthrustbartrue or sellcond then
x=2
else
x=0
endif
SCREENER[x](x AS "1=SOSBar,2=SOWBar,0=NoSignal")