• Get $40 off VIP by signing up for a free account! Sign Up

help on scans / alerts vScore

jo40788

New member
Plus
Hi
Love the forum and so far have found my way to navigate code which I never have before so thanks for all the tutorials! I have a question on the following which is using the vScore lower and upper scripts (not my code). I use three charts with different strategies this being one of them to help see crossover on the zero lines for both lower and upper. Two questions 1) my bull / bear signals don't seem to be working or aligning correctly 2) I was looking to create a scan on the following to find stocks that have crossed over by some % or x amount. The scans always come back empty. I attached the image as well as the code I am using. Appreciate any help!

I am sure you are familiar but this is the link - https://tosindicators.com/indicators/vscore

TI_vscore_upper



#TOS Indicators - Home of the Volatility Box

#VScore-Upper Study

#Full YouTube Tutorial:

#

#**10/6/19 - Feature Added: Ability for Users to Set Custom Standard Deviation in Label Output



declare upper;

input anchorDate = 20240101;

input barsGoBack = 30;





def postAnchorDate = if GetYYYYMMDD() >= anchorDate then 1 else 0;





def yyyyMmDd = getYyyyMmDd();

def periodIndx = if getAggregationPeriod() < AggregationPeriod.HOUR then yyyyMMDD else postAnchorDate;

def isPeriodRolled = compoundValue(1, periodIndx != periodIndx[1], yes);



def volumeSum;

def volumeVwapSum;

def volumeVwap2Sum;



if (isPeriodRolled) {

volumeSum = volume;

volumeVwapSum = volume * vwap;

volumeVwap2Sum = volume * Sqr(vwap);

} else {

volumeSum = compoundValue(1, volumeSum[1] + volume, volume);

volumeVwapSum = compoundValue(1, volumeVwapSum[1] + volume * vwap, volume * vwap);

volumeVwap2Sum = compoundValue(1, volumeVwap2Sum[1] + volume * Sqr(vwap), volume * Sqr(vwap));

}

def price = volumeVwapSum / volumeSum;

def deviation = Sqrt(Max(volumeVwap2Sum / volumeSum - Sqr(price), 0));



def VScore = if (((price - close)(-1))/deviation) > 5 or (((price - close)(-1))/deviation) < -5 then 0 else (((price - close)*(-1))/(deviation));

plot zero = (0)*(deviation) + (price);

plot one = (1)*(deviation) + (price);

plot two = (2)*(deviation) + (price);

plot three = (3)*(deviation) + (price);

plot negOne = (-1)*(deviation) + (price);

plot negTwo = (-2)*(deviation) + (price);

plot negThree = (-3)*(deviation) + (price);



zero.setDefaultColor(Color.White);

zero.setLineWeight(3);

one.setDefaultColor(Color.Light_Gray);

negOne.setDefaultColor(Color.Light_Gray);

two.setDefaultColor(Color.Light_Green);

negTwo.setDefaultColor(Color.Light_Red);

three.setDefaultColor(Color.Green);

negThree.setDefaultColor(Color.Red);



def zeroAndOne = if VScore > zero and VScore <= one then 1 else 0;

def oneAndTwo = if VScore > one and VScore <= two then 1 else 0;

def twoAndThree = if VScore > two and VScore <= three then 1 else 0;



def negZeroAndOne = if VScore > negOne and VScore < zero then 1 else 0;

def negOneAndTwo = if VScore > negTwo and VScore <= negOne then 1 else 0;

def negTwoAndThree = if VScore > negThree and VScore <= negTwo then 1 else 0;



def counter = if VScore >= 0 then 1 else if VScore < 0 then -1 else 0;

def trend = Sum(counter, barsGoBack);

def positiveTrend = if trend >= 0 then 1 else 0;

def negativeTrend = if trend < 0 then 1 else 0;



plot BullSignal = if positiveTrend and (VScore <= 0.3 and Vscore[1] >0) and CCI() > -100 then 1 else 0;



plot BearSignal = if negativeTrend and (VScore >= 0.3 and Vscore[1] < 0) and CCI() < 100 then 1 else 0;



BullSignal.SetPaintingStrategy(PaintingStrategy.Boolean_Arrow_UP);

BearSignal.SetPaintingStrategy(PaintingStrategy.Boolean_Arrow_DOWN);

BullSignal.SetLineWeight(3);

BearSignal.SetLineWeight(3);



TI_vscore_lower



#TOS Indicators - Home of the Volatility Box

#Full YouTube Tutorial:

#

#**10/6/19 - Feature Added: Ability for Users to Set Custom Standard Deviation in Label Output



declare lower;

input anchorDate = 20210101;

input barsGoBack = 90;

input showStopLabel = yes;

input devStop = {default One, Two, Three, Zero, NegOne, NegTwo, NegThree, Custom};

input customDev = 0.15;

def chosenDev;

switch(devStop){

case One:

chosenDev = 1;

case Two:

chosenDev = 2;

case Three:

chosenDev = 3;

case Zero:

chosenDev = 0;

case NegOne:

chosenDev = -1;

case NegTwo:

chosenDev = -2;

case NegThree:

chosenDev = -3;

case Custom:

chosenDev = customDev;

}







def postAnchorDate = if GetYYYYMMDD() >= anchorDate then 1 else 0;





def yyyyMmDd = getYyyyMmDd();

def periodIndx = if getAggregationPeriod() < AggregationPeriod.HOUR then yyyyMMDD else postAnchorDate;

def isPeriodRolled = compoundValue(1, periodIndx != periodIndx[1], yes);



def volumeSum;

def volumeVwapSum;

def volumeVwap2Sum;



if (isPeriodRolled) {

volumeSum = volume;

volumeVwapSum = volume * vwap;

volumeVwap2Sum = volume * Sqr(vwap);

} else {

volumeSum = compoundValue(1, volumeSum[1] + volume, volume);

volumeVwapSum = compoundValue(1, volumeVwapSum[1] + volume * vwap, volume * vwap);

volumeVwap2Sum = compoundValue(1, volumeVwap2Sum[1] + volume * Sqr(vwap), volume * Sqr(vwap));

}

def price = volumeVwapSum / volumeSum;

def deviation = Sqrt(Max(volumeVwap2Sum / volumeSum - Sqr(price), 0));



plot VScore = if (((price - close)(-1))/deviation) > 5 or (((price - close)(-1))/deviation) < -5 then 0 else (((price - close)*(-1))/(deviation));

plot zero = 0;

zero.setLineWeight(3);

plot one = 1;

one.setDefaultColor(Color.Light_Gray);

plot two = 2;

two.setDefaultColor(Color.light_Green);

plot three = 3;

three.setDefaultColor(Color.Green);

plot negOne = -1;

negOne.setDefaultColor(Color.Light_Gray);

plot negTwo = -2;

negTwo.setDefaultColor(Color.pink);

plot negThree = -3;

negThree.setDefaultColor(Color.light_red);

plot posInt = 0.3;

posInt.setDefaultColor(Color.cyan);

plot negInt = -0.3;

negInt.setDefaultColor(Color.cyan);

def stopPrice = (chosenDev)*(deviation) + (price);

AddLabel(showStopLabel, "Price at ["+chosenDev+"] SD: "+AsPrice(Round(stopPrice,2)),color.white);

def zeroAndOne = if VScore > zero and VScore <= one then 1 else 0;

def oneAndTwo = if VScore > one and VScore <= two then 1 else 0;

def twoAndThree = if VScore > two and VScore <= three then 1 else 0;



def negZeroAndOne = if VScore > negOne and VScore < zero then 1 else 0;

def negOneAndTwo = if VScore > negTwo and VScore <= negOne then 1 else 0;

def negTwoAndThree = if VScore > negThree and VScore <= negTwo then 1 else 0;



def cloud1;

def cloud2;

if Sum(zeroAndOne, barsGoBack) > Sum(OneAndTwo,barsGoBack) and Sum(zeroAndOne, barsGoBack) > Sum(twoAndThree,barsGoBack) and Sum(zeroAndOne, barsGoBack) > Sum(negZeroAndOne,barsGoBack) and Sum(zeroAndOne, barsGoBack) > Sum(negoneAndTwo,barsGoBack) and Sum(zeroAndOne, barsGoBack) > Sum(negtwoAndThree,barsGoBack){

cloud1 = zero;

cloud2 = one;

}

else if Sum(OneAndTwo, barsGoBack) > Sum(zeroAndOne,barsGoBack) and Sum(OneAndTwo, barsGoBack) > Sum(twoAndThree,barsGoBack) and Sum(OneAndTwo, barsGoBack) > Sum(negZeroAndOne,barsGoBack) and Sum(OneAndTwo, barsGoBack) > Sum(negoneAndTwo,barsGoBack) and Sum(OneAndTwo, barsGoBack) > Sum(negtwoAndThree,barsGoBack){

cloud1 = one;

cloud2 = two;

}

else if Sum(twoAndThree, barsGoBack) > Sum(zeroAndOne,barsGoBack) and Sum(twoAndThree, barsGoBack) > Sum(oneAndTwo,barsGoBack) and Sum(twoAndThree, barsGoBack) > Sum(negZeroAndOne,barsGoBack) and Sum(twoAndThree, barsGoBack) > Sum(negoneAndTwo,barsGoBack) and Sum(twoAndThree, barsGoBack) > Sum(negtwoAndThree,barsGoBack){

cloud1 = two;

cloud2 = three;

}

else if Sum(negZeroAndOne, barsGoBack) > Sum(zeroAndOne,barsGoBack) and Sum(negZeroAndOne, barsGoBack) > Sum(oneAndTwo,barsGoBack) and Sum(negZeroAndOne, barsGoBack) > Sum(twoAndThree,barsGoBack) and Sum(negZeroAndOne, barsGoBack) > Sum(negoneAndTwo,barsGoBack) and Sum(negZeroAndOne, barsGoBack) > Sum(negtwoAndThree,barsGoBack){

cloud1 = zero;

cloud2 = negOne;

}

else if Sum(negoneAndTwo, barsGoBack) > Sum(zeroAndOne,barsGoBack) and Sum(negoneAndTwo, barsGoBack) > Sum(oneAndTwo,barsGoBack) and Sum(negoneAndTwo, barsGoBack) > Sum(twoAndThree,barsGoBack) and Sum(negoneAndTwo, barsGoBack) > Sum(negZeroAndOne,barsGoBack) and Sum(negoneAndTwo, barsGoBack) > Sum(negtwoAndThree,barsGoBack){

cloud1 = negOne;

cloud2 = negTwo;

}

else if Sum(negtwoAndThree, barsGoBack) > Sum(zeroAndOne,barsGoBack) and Sum(negtwoAndThree, barsGoBack) > Sum(oneAndTwo,barsGoBack) and Sum(negtwoAndThree, barsGoBack) > Sum(twoAndThree,barsGoBack) and Sum(negtwoAndThree, barsGoBack) > Sum(negZeroAndOne,barsGoBack) and Sum(negtwoAndThree, barsGoBack) > Sum(negOneAndTwo,barsGoBack){

cloud1 = negTwo;

cloud2 = negThree;

}

else {

cloud1 = Double.nan;

cloud2 = Double.nan;

}

AddCloud(cloud1, cloud2, color.light_red, color.light_green);





plot BullSignal = if (cloud1 == one or cloud2 == one or cloud1 == two or cloud2 == two or cloud1 == three or cloud2 ==three) and (VScore <= 0.3 and Vscore[1] >0) and CCI() > -100 then -2 else Double.nan;



plot BearSignal = if (cloud1 == negOne or cloud2 == negOne or cloud1 == negTwo or cloud2 == negTwo or cloud1 == negThree or cloud2 ==negThree) and (VScore >= 0.3 and Vscore[1] < 0) and CCI() < 100 then 2 else Double.nan;



BullSignal.SetPaintingStrategy(PaintingStrategy.Arrow_UP);

BearSignal.SetPaintingStrategy(PaintingStrategy.Arrow_DOWN);

BullSignal.SetLineWeight(3);

BearSignal.SetLineWeight(3);



input soundAlertsOn = no;

Alert((cloud1 == one or cloud2 == one or cloud1 == two or cloud2 == two or cloud1 == three or cloud2 == three) and (VScore <= 0 and VScore[1] > 0) and (SoundAlertsOn), "Bullish VScore Entry", Alert.BAR);

Alert((cloud1 == negOne or cloud2 == negone or cloud1 == negtwo or cloud2 == negtwo or cloud1 == negthree or cloud2 == negthree) and (VScore >= 0 and VScore[1] < 0)and (SoundAlertsOn), "Bearish VScore Entry", Alert.BAR);
 

Attachments

  • Screenshot 2024-05-12 at 10.29.46 AM.png
    Screenshot 2024-05-12 at 10.29.46 AM.png
    130.5 KB · Views: 47

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
366 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top