# Conviction Index and Volume Weighted Conviction Index For ThinkOrSwim

#### Jman831

##### Member
Hey there, new to usethinkscript. I've been coming up with ideas left and right for indicators these last few months and I think I've finally come up with something that might be useful to some. I call it the "Conviction Index". I also came up with a "volume weighted" Conviction Index. They give you an idea of how much conviction is in a move up or down and can give you a heads up of when to get in or out.

Basically what they do is they determine whether a move has conviction or not by combining change in volume from one period to the next with the change in price of each period. If the volume of the current period is greater than the volume of the previous period and the current period's price closes above it's open it's value will equal 2 + 2 * the percentage change of the candle's body. If the volume of the current period is less than the volume of the previous period and the current period's price closes above it's open it's value will equal 1 + 1 * the percentage change of the body. If the volume of the current period is greater than the volume of the previous period and the current period's price closes below it's open it's value will equal -2 + -2 * the percentage change of the body. If the volume of the current period is less than the volume of the previous period and the current period's price closes below it's open it's value will equal -1 + -1 * the percentage change of the body.

Once it gets those values it sums those values of the last so many periods that you specify (Conviction Length) and by default exponentially smooths it out by the number of periods you specify. On the daily chart I set the conviction length to 6 and the smoothing length to 2. I've also used a conviction length of 18 on the 5 minute chart, but I mainly stick to the exponential smoothing length of 2 for faster signals.

I won't get into the details, but the volume weighted conviction index gets it's values based off of the values of the volume change from period to period but works similarly.

I also have an exponentially smoothed typical price tied to the indicator that determines it's colors. When the smoothed typical price and the conviction index are both going up it colors the conviction index green. When the smoothed typical price and the conviction index are both going down it colors it red. When the smoothed typical price and conviction index are out of sync (ones going up, the other down) it colors it yellow.

Conviction Index

Code:
``````declare lower;

input ConvictionLength = 18;
input ExponentialSmoothing = yes;
input ExponentialSmoothingLength = 2;

def range = high - low;
def bodytop = if close > open then close else open;
def bodybottom = if close < open then close else open;
def body = bodytop - bodybottom;
def perbody = body / range;
def rangeper = range / low;
def bodyper = rangeper * perbody;
def bullcon = if close > open and volume() > volume()[1] then 2 + 2 * bodyper else if close > open and volume() < volume()[1] then 1 + 1 * bodyper else 0;
def bearcon = if close < open and volume() > volume()[1] then -2 + -2 * bodyper else if close < open and volume() < volume()[1] then -1 + -1 * bodyper else 0;
def convic = if ExponentialSmoothing == yes then ExpAverage(ExpAverage(ExpAverage(Sum(bullcon, ConvictionLength) + Sum(bearcon, ConvictionLength), ExponentialSmoothingLength), ExponentialSmoothingLength), ExponentialSmoothingLength) else Sum(bullcon, ConvictionLength) + Sum(bearcon, ConvictionLength);
def exptypprice = ExpAverage(ExpAverage(ExpAverage((high + low + close) / 3, 3), 3), 3);

plot Zero = 0;
plot ConvictionIndex = convic;

Zero.SetDefaultColor(Color.CYAN);
ConvictionIndex.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
ConvictionIndex.AssignValueColor(if (exptypprice < exptypprice[1] and ConvictionIndex > ConvictionIndex[1]) or (exptypprice > exptypprice[1] and ConvictionIndex < ConvictionIndex[1]) then Color.YELLOW else if exptypprice < exptypprice[1] and ConvictionIndex < ConvictionIndex[1] then Color.LIGHT_RED else Color.LIGHT_GREEN);``````

Volume Weighted Conviction Index

Code:
``````declare lower;

input ConvictionLength = 18;
input ExponentialSmoothing = yes;
input ExponentialSmoothingLength = 2;

def range = high - low;
def bodytop = if close > open then close else open;
def bodybottom = if close < open then close else open;
def body = bodytop - bodybottom;
def perbody = body / range;
def rangeper = range / low;
def volchnge = volume() - volume()[1];
def bodyper = rangeper * perbody;
def bullcon = if close > open and volume() > volume()[1] then volchnge * 2 + (volchnge * 2) * bodyper else if close > open and volume() < volume()[1] then volchnge + volchnge * bodyper else 0;
def bearcon = if close < open and volume() > volume()[1] then volchnge * -2 + (volchnge * -2) * bodyper else if close < open and volume() < volume()[1] then volchnge * -1 + (volchnge * -1) * bodyper else 0;
def convic = if ExponentialSmoothing == yes then ExpAverage(ExpAverage(ExpAverage(Sum(bullcon, ConvictionLength) + Sum(bearcon, ConvictionLength), ExponentialSmoothingLength), ExponentialSmoothingLength), ExponentialSmoothingLength) else Sum(bullcon, ConvictionLength) + Sum(bearcon, ConvictionLength);
def exptypprice = ExpAverage(ExpAverage(ExpAverage((high + low + close) / 3, 3), 3), 3);

plot Zero = 0;
plot ConvictionIndex = convic;

Zero.SetDefaultColor(Color.CYAN);
ConvictionIndex.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
ConvictionIndex.AssignValueColor(if (exptypprice < exptypprice[1] and ConvictionIndex > ConvictionIndex[1]) or (exptypprice > exptypprice[1] and ConvictionIndex < ConvictionIndex[1]) then Color.YELLOW else if exptypprice < exptypprice[1] and ConvictionIndex < ConvictionIndex[1] then Color.LIGHT_RED else Color.LIGHT_GREEN);``````

I hope someone finds use for this and/or improves upon it if they have ideas. Let me know if you find use for it.

Update: Made a minor mistake and updated this line for both indicators in the coding above from this...

Code:
``def rangeper = range / low * 100;``

to this...

Code:
``def rangeper = range / low;``

The change has minimal effect on how the indicators are displayed, but it's what I originally intended the calculation to be.

Last edited:
@Jman831 Welcome to useThinkScript...Thanks for posting your Conviction/Volume-Weighted Conviction Index indicators. I look forward to trying them out...As for other ideas you have, post away There are a legion of like-minded traders and thinkscripters here at uTS willing to try out new ideas and indicators...

As far as screenshots go, you can check out the following link with instructions to post your images...If you don't care for submitting images via Imgur (I didn't)...I found another free image service called Postimage that is easier to work with IMO and your viewers don't have to go to an external site to view your images...

@Jman831 Welcome to useThinkScript...Thanks for posting your Conviction/Volume-Weighted Conviction Index indicators. I look forward to trying them out...As for other ideas you have, post away There are a legion of like-minded traders and thinkscripters here at uTS willing to try out new ideas and indicators...

As far as screenshots go, you can check out the following link with instructions to post your images...If you don't care for submitting images via Imgur (I didn't)...I found another free image service called Postimage that is easier to work with IMO and your viewers don't have to go to an external site to view your images...

Thank you, especially for the instructions on posting images, I was hoping someone would point me in the right direction for that.

Welcome to the community. I really love the logic behind each of your scripts.

I was wondering if you had done any additional testing between the volume-weighted script and your standard script and if you could possibly talk a little more about your findings?

Welcome to the community. I really love the logic behind each of your scripts.

I was wondering if you had done any additional testing between the volume-weighted script and your standard script and if you could possibly talk a little more about your findings?

Thank you. I haven't done extensive testing but I've done some testing on each of these scripts, but I've noticed in some cases the volume weighted one tends to have a more bearish bias or it seems like it exaggerates the bearishness sometimes when compared to the standard script. However, I've also found with the volume weighted one, you can turn off exponential smoothing and set the conviction length to 1 and it'll give you the "true conviction" of each bar/candle which could be useful, particularly when looking for a buying or selling climax. See the screenshot below.

Please note also that I updated one line in each script in the original post. The change has minimal effect on the display of the indicators, but they represent a more accurate calculation of what I was intending.

Thank you. I haven't done extensive testing but I've done some testing on each of these scripts, but I've noticed in some cases the volume weighted one tends to have a more bearish bias or it seems like it exaggerates the bearishness sometimes when compared to the standard script. However, I've also found with the volume weighted one, you can turn off exponential smoothing and set the conviction length to 1 and it'll give you the "true conviction" of each bar/candle which could be useful, particularly when looking for a buying or selling climax. See the screenshot below.

Please note also that I updated one line in each script in the original post. The change has minimal effect on the display of the indicators, but they represent a more accurate calculation of what I was intending.
Thank you for the insight on this. I wonder if adding in some sort of standard deviation metric similar to a Z-score would be an effective tool to see where spikes in buying/selling pressure exist.

What is the new line of code that you edited from the original post?

Thank you for the insight on this. I wonder if adding in some sort of standard deviation metric similar to a Z-score would be an effective tool to see where spikes in buying/selling pressure exist.

What is the new line of code that you edited from the original post?

I updated the original post to include the new line of code in both scripts. I also included the line by itself at the bottom of the original post if you're curious to know the exact line of code. As far as deviation bands go, I attempted to add deviation bands to the script, but it doesn't look good with them and it doesn't really offer any added insight as most of the time it doesn't actually point out spikes. I also tried turning the volume weighted one into an oscillator to see if I could get an idea of what's historically high and low, but that changed the whole dynamic of the indicator and didn't offer much insight either.

I updated the original post to include the new line of code in both scripts. I also included the line by itself at the bottom of the original post if you're curious to know the exact line of code. As far as deviation bands go, I attempted to add deviation bands to the script, but it doesn't look good with them and it doesn't really offer any added insight as most of the time it doesn't actually point out spikes. I also tried turning the volume weighted one into an oscillator to see if I could get an idea of what's historically high and low, but that changed the whole dynamic of the indicator and didn't offer much insight either.
That is unfortunate in regards to the deviations.
Have you attempted to aggregate the volume into buying vs selling volume and further edit the formula by adding another layer say 3+3 for if buying vol > selling vol?

That is unfortunate in regards to the deviations.
Have you attempted to aggregate the volume into buying vs selling volume and further edit the formula by adding another layer say 3+3 for if buying vol > selling vol?

These two lines already take that into account with the "close > open" and "close < open" portions of the code.

Code:
``````def bullcon = if close > open and volume() > volume()[1] then 2 + 2 * bodyper else if close > open and volume() < volume()[1] then 1 + 1 * bodyper else 0;
def bearcon = if close < open and volume() > volume()[1] then -2 + -2 * bodyper else if close < open and volume() < volume()[1] then -1 + -1 * bodyper else 0;``````

That essentially tells it whether it's buying or selling volume. But, it combines this with the change in volume from the previous bar to the current bar which could be positive or negative regardless of whether it was buying or selling volume. That's where 2 + 2 * bodyper, 1 + 1 * bodyper, -2 + -2 * bodyper, and -1 + -1 * bodyper come in. If the volume is higher than the previous candle (a positive result) and it's buying volume (another positive result) then it uses 2 + 2 * bodyper. If the volume is lower than the previous candle (a negative result) and it's buying volume (a positive result) it uses 1 + 1 * bodyper. If the volume is higher (a positive result) and it's selling volume (a negative result) then -2 + -2 * bodyper. If the volume is lower (a negative result) and it's selling volume (another negative result) then -1 + -1 * bodyper.

Do you see the logic? Basically I want the index to go up when it's either higher buying volume or lower selling volume and I want it to go down when it's higher selling volume or lower buying volume. Then the conviction length sums up those values of each candle to give you an idea of bullishness or bearishness over time. The "bodyper" takes into account the size of the body of the candle, so if it's a small body it has a lesser effect on the index, if it's a large body it has a greater effect on the index.

Ah, I understand it now I had to sit down on my computer to examine your code rather than just looking at it via my phone. I enjoy the code and the feel of this indicator. I will put it up on my charts and continue to watch and report if I can identify anything that is useful. Thank you again for your contribution.

Hey there, new to usethinkscript. I've been coming up with ideas left and right for indicators these last few months and I think I've finally come up with something that might be useful to some. I call it the "Conviction Index". I also came up with a "volume weighted" Conviction Index. They give you an idea of how much conviction is in a move up or down and can give you a heads up of when to get in or out.

Basically what they do is they determine whether a move has conviction or not by combining change in volume from one period to the next with the change in price of each period. If the volume of the current period is greater than the volume of the previous period and the current period's price closes above it's open it's value will equal 2 + 2 * the percentage change of the candle's body. If the volume of the current period is less than the volume of the previous period and the current period's price closes above it's open it's value will equal 1 + 1 * the percentage change of the body. If the volume of the current period is greater than the volume of the previous period and the current period's price closes below it's open it's value will equal -2 + -2 * the percentage change of the body. If the volume of the current period is less than the volume of the previous period and the current period's price closes below it's open it's value will equal -1 + -1 * the percentage change of the body.

Once it gets those values it sums those values of the last so many periods that you specify (Conviction Length) and by default exponentially smooths it out by the number of periods you specify. On the daily chart I set the conviction length to 6 and the smoothing length to 2. I've also used a conviction length of 18 on the 5 minute chart, but I mainly stick to the exponential smoothing length of 2 for faster signals.

I won't get into the details, but the volume weighted conviction index gets it's values based off of the values of the volume change from period to period but works similarly.

I also have an exponentially smoothed typical price tied to the indicator that determines it's colors. When the smoothed typical price and the conviction index are both going up it colors the conviction index green. When the smoothed typical price and the conviction index are both going down it colors it red. When the smoothed typical price and conviction index are out of sync (ones going up, the other down) it colors it yellow.

Conviction Index

Code:
``````declare lower;

input ConvictionLength = 18;
input ExponentialSmoothing = yes;
input ExponentialSmoothingLength = 2;

def range = high - low;
def bodytop = if close > open then close else open;
def bodybottom = if close < open then close else open;
def body = bodytop - bodybottom;
def perbody = body / range;
def rangeper = range / low;
def bodyper = rangeper * perbody;
def bullcon = if close > open and volume() > volume()[1] then 2 + 2 * bodyper else if close > open and volume() < volume()[1] then 1 + 1 * bodyper else 0;
def bearcon = if close < open and volume() > volume()[1] then -2 + -2 * bodyper else if close < open and volume() < volume()[1] then -1 + -1 * bodyper else 0;
def convic = if ExponentialSmoothing == yes then ExpAverage(ExpAverage(ExpAverage(Sum(bullcon, ConvictionLength) + Sum(bearcon, ConvictionLength), ExponentialSmoothingLength), ExponentialSmoothingLength), ExponentialSmoothingLength) else Sum(bullcon, ConvictionLength) + Sum(bearcon, ConvictionLength);
def exptypprice = ExpAverage(ExpAverage(ExpAverage((high + low + close) / 3, 3), 3), 3);

plot Zero = 0;
plot ConvictionIndex = convic;

Zero.SetDefaultColor(Color.CYAN);
ConvictionIndex.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
ConvictionIndex.AssignValueColor(if (exptypprice < exptypprice[1] and ConvictionIndex > ConvictionIndex[1]) or (exptypprice > exptypprice[1] and ConvictionIndex < ConvictionIndex[1]) then Color.YELLOW else if exptypprice < exptypprice[1] and ConvictionIndex < ConvictionIndex[1] then Color.LIGHT_RED else Color.LIGHT_GREEN);``````

Volume Weighted Conviction Index

Code:
``````declare lower;

input ConvictionLength = 18;
input ExponentialSmoothing = yes;
input ExponentialSmoothingLength = 2;

def range = high - low;
def bodytop = if close > open then close else open;
def bodybottom = if close < open then close else open;
def body = bodytop - bodybottom;
def perbody = body / range;
def rangeper = range / low;
def volchnge = volume() - volume()[1];
def bodyper = rangeper * perbody;
def bullcon = if close > open and volume() > volume()[1] then volchnge * 2 + (volchnge * 2) * bodyper else if close > open and volume() < volume()[1] then volchnge + volchnge * bodyper else 0;
def bearcon = if close < open and volume() > volume()[1] then volchnge * -2 + (volchnge * -2) * bodyper else if close < open and volume() < volume()[1] then volchnge * -1 + (volchnge * -1) * bodyper else 0;
def convic = if ExponentialSmoothing == yes then ExpAverage(ExpAverage(ExpAverage(Sum(bullcon, ConvictionLength) + Sum(bearcon, ConvictionLength), ExponentialSmoothingLength), ExponentialSmoothingLength), ExponentialSmoothingLength) else Sum(bullcon, ConvictionLength) + Sum(bearcon, ConvictionLength);
def exptypprice = ExpAverage(ExpAverage(ExpAverage((high + low + close) / 3, 3), 3), 3);

plot Zero = 0;
plot ConvictionIndex = convic;

Zero.SetDefaultColor(Color.CYAN);
ConvictionIndex.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
ConvictionIndex.AssignValueColor(if (exptypprice < exptypprice[1] and ConvictionIndex > ConvictionIndex[1]) or (exptypprice > exptypprice[1] and ConvictionIndex < ConvictionIndex[1]) then Color.YELLOW else if exptypprice < exptypprice[1] and ConvictionIndex < ConvictionIndex[1] then Color.LIGHT_RED else Color.LIGHT_GREEN);``````

I hope someone finds use for this and/or improves upon it if they have ideas. Let me know if you find use for it.

Update: Made a minor mistake and updated this line for both indicators in the coding above from this...

Code:
``def rangeper = range / low * 100;``

to this...

Code:
``def rangeper = range / low;``

The change has minimal effect on how the indicators are displayed, but it's what I originally intended the calculation to be.
For Jman 831:

Jman831 , Thank you for your work. I find your Your Conviction Index ( I favor the Volume Color Weighted version you created) is elegant and well designed.
I think it has many virtues and believe it to be outstanding work, well thought out and great code execution.
1. It is strongly correlated with short term VWAP price overlays, and acts very much as a confirmation without cluttering the upper Candle/ Price Channel
3. It is strongly correlated with Linear Regression Slope- even short term .
4. It mimics the Algorithmic trading instructions for High Speed Dark pools that are required take larger positions, thereby revealing themselves to the discretionary traders like us that is willing to spend the time observing Price/Volume action.

5. The only suggestion I have, which I am pretty sure you have already thought about is to create a TOS SCAN: for both stocks and Options with the Conviction Index. I would also include in that scan utilizing Conviction Index, an MACD X over strategy from negative to positive and positive to negative for Long and shorts. The intention being to minimize overtrading and get big breakouts that might last from min of day to a swing trade.
Great work, Keep it up!
PS. I don't believe you need the Jacob Bernoulli school of numbers: Standard Deviations, and all the distractions of range bound indicators that other people have mentioned. I think they are the ruination of a herd mentality that always tries to mitigate risk by following rather than monitoring and then quickly pivoting: Most are are prone to mediocrity in their over all results"/

The Conviction Indicator helps discover High probability inflection pts.
As such I will add it to some of my TOS chart styles

Best to All
Quote from George Soros: “The trend is your friend most of the way; remember, trend followers only get hurt at inflection point.... I am a member of a herd; I am on the lookout for inflection points."
Thanks

Last edited by a moderator:
For Jman 831:
Wow, well all I can say is I greatly appreciate your input and I honestly never thought any of my work would come to fruition for anyone, but I'm glad someone found use for it. I'm going to take a look at that strategy you've come up with. I might be able to do a scan if you describe in more detail how the strategy works. What timeframes are you thinking? Daily? Also do you mean when MACD lines cross over simultaneously as the volume conviction index is crossing above or below zero?

Last edited by a moderator:
Here is a binary form of the Conviction Index based on 12 different lengths, 6 Short term & 6 long Term, Lighter colors are for the short term and the darker colors are for the longer term lengths
Code:
``````declare lower;
input period1 = 3;
input period2 = 5;
input period3 = 8;
input period4 = 10;
input period5 = 12;
input period6 = 15;
input period7 = 30;
input period8 = 35;
input period9 = 40;
input period10 = 45;
input period11 = 50;
input period12 = 60;
input ExponentialSmoothing = yes;
input SLength = 2;
input Dotsize = 3;
def range = high - low;
def bodytop = if close > open then close else open;
def bodybottom = if close < open then close else open;
def body = bodytop - bodybottom;
def perbody = body / range;
def rangeper = range / low * 100;
def bodyper = rangeper * perbody;
def bullcon = if close > open and volume() > volume()[1] then 2 + 2 * bodyper else if close > open and volume() < volume()[1] then 1 + 1 * bodyper else 0;
def bearcon = if close < open and volume() > volume()[1] then -2 + -2 * bodyper else if close < open and volume() < volume()[1] then -1 + -1 * bodyper else 0;
def exptypprice = ExpAverage(ExpAverage(ExpAverage((high + low + close) / 3, 3), 3), 3);
def convicA = if ExponentialSmoothing == yes then ExpAverage(ExpAverage(ExpAverage(Sum(bullcon, period1) + Sum(bearcon, period1), SLength), SLength), SLength) else Sum(bullcon, period1) + Sum(bearcon, period1);
def convicB = if ExponentialSmoothing == yes then ExpAverage(ExpAverage(ExpAverage(Sum(bullcon, period2) + Sum(bearcon, period2), SLength), SLength), SLength) else Sum(bullcon, period2) + Sum(bearcon, period2);
def convicC = if ExponentialSmoothing == yes then ExpAverage(ExpAverage(ExpAverage(Sum(bullcon, period3) + Sum(bearcon, period3), SLength), SLength), SLength) else Sum(bullcon, period3) + Sum(bearcon, period3);
def convicD = if ExponentialSmoothing == yes then ExpAverage(ExpAverage(ExpAverage(Sum(bullcon, period4) + Sum(bearcon, period4), SLength), SLength), SLength) else Sum(bullcon, period4) + Sum(bearcon, period4);
def convicE = if ExponentialSmoothing == yes then ExpAverage(ExpAverage(ExpAverage(Sum(bullcon, period5) + Sum(bearcon, period5), SLength), SLength), SLength) else Sum(bullcon, period5) + Sum(bearcon, period5);
def convicF = if ExponentialSmoothing == yes then ExpAverage(ExpAverage(ExpAverage(Sum(bullcon, period6) + Sum(bearcon, period6), SLength), SLength), SLength) else Sum(bullcon, period6) + Sum(bearcon, period6);
def convicG = if ExponentialSmoothing == yes then ExpAverage(ExpAverage(ExpAverage(Sum(bullcon, period7) + Sum(bearcon, period7), SLength), SLength), SLength) else Sum(bullcon, period7) + Sum(bearcon, period7);
def convicH = if ExponentialSmoothing == yes then ExpAverage(ExpAverage(ExpAverage(Sum(bullcon, period8) + Sum(bearcon, period8), SLength), SLength), SLength) else Sum(bullcon, period8) + Sum(bearcon, period8);
def convicI = if ExponentialSmoothing == yes then ExpAverage(ExpAverage(ExpAverage(Sum(bullcon, period9) + Sum(bearcon, period9), SLength), SLength), SLength) else Sum(bullcon, period9) + Sum(bearcon, period9);
def convicJ = if ExponentialSmoothing == yes then ExpAverage(ExpAverage(ExpAverage(Sum(bullcon, period10) + Sum(bearcon, period10), SLength), SLength), SLength) else Sum(bullcon, period10) + Sum(bearcon, period10);
def convicK = if ExponentialSmoothing == yes then ExpAverage(ExpAverage(ExpAverage(Sum(bullcon, period11) + Sum(bearcon, period11), SLength), SLength), SLength) else Sum(bullcon, period11) + Sum(bearcon, period11);
def convicL = if ExponentialSmoothing == yes then ExpAverage(ExpAverage(ExpAverage(Sum(bullcon, period12) + Sum(bearcon, period12), SLength), SLength), SLength) else Sum(bullcon, period12) + Sum(bearcon, period12);

plot A1_Dot = if IsNaN(close) then Double.NaN else 1;
A1_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A1_Dot.SetLineWeight(DotSize);
A1_Dot.AssignValueColor(if (exptypprice < exptypprice[1] and ConvicA > ConvicA[1]) or (exptypprice > exptypprice[1] and ConvicA < ConvicA[1]) then Color.YELLOW else if exptypprice < exptypprice[1] and ConvicA < ConvicA[1] then Color.LIGHT_RED else Color.LIGHT_GREEN);
plot A2_Dot = if IsNaN(close) then Double.NaN else 2;
A2_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A2_Dot.SetLineWeight(DotSize);
A2_Dot.AssignValueColor(if (exptypprice < exptypprice[1] and convicB > convicB[1]) or (exptypprice > exptypprice[1] and convicB < convicB[1]) then Color.YELLOW else if exptypprice < exptypprice[1] and convicB < convicB[1] then Color.LIGHT_RED else Color.LIGHT_GREEN);
plot A3_Dot = if IsNaN(close) then Double.NaN else 3;
A3_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A3_Dot.SetLineWeight(DotSize);
A3_Dot.AssignValueColor(if (exptypprice < exptypprice[1] and convicC > convicC[1]) or (exptypprice > exptypprice[1] and convicC < convicC[1]) then Color.YELLOW else if exptypprice < exptypprice[1] and convicC < convicC[1] then Color.LIGHT_RED else Color.LIGHT_GREEN);
plot A4_Dot = if IsNaN(close) then Double.NaN else 4;
A4_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A4_Dot.SetLineWeight(DotSize);
A4_Dot.AssignValueColor(if (exptypprice < exptypprice[1] and convicD > convicD[1]) or (exptypprice > exptypprice[1] and convicD < convicD[1]) then Color.YELLOW else if exptypprice < exptypprice[1] and convicD < convicD[1] then Color.LIGHT_RED else Color.LIGHT_GREEN);
plot A5_Dot = if IsNaN(close) then Double.NaN else 5;
A5_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A5_Dot.SetLineWeight(DotSize);
A5_Dot.AssignValueColor(if (exptypprice < exptypprice[1] and convicE > convicE[1]) or (exptypprice > exptypprice[1] and convicE < convicE[1]) then Color.YELLOW else if exptypprice < exptypprice[1] and convicE < convicE[1] then Color.LIGHT_RED else Color.LIGHT_GREEN);
plot A6_Dot = if IsNaN(close) then Double.NaN else 6;
A6_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A6_Dot.SetLineWeight(DotSize);
A6_Dot.AssignValueColor(if (exptypprice < exptypprice[1] and convicF > convicF[1]) or (exptypprice > exptypprice[1] and convicF < convicF[1]) then Color.YELLOW else if exptypprice < exptypprice[1] and convicF < convicF[1] then Color.LIGHT_RED else Color.LIGHT_GREEN);
plot A7_Dot = if IsNaN(close) then Double.NaN else 7;
A7_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A7_Dot.SetLineWeight(DotSize);
A7_Dot.AssignValueColor(if (exptypprice < exptypprice[1] and convicG > convicG[1]) or (exptypprice > exptypprice[1] and convicG < convicG[1]) then Color.Orange else if exptypprice < exptypprice[1] and convicG < convicG[1] then Color.Dark_RED else Color.Dark_GREEN);
plot A8_Dot = if IsNaN(close) then Double.NaN else 8;
A8_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A8_Dot.SetLineWeight(DotSize);
A8_Dot.AssignValueColor(if (exptypprice < exptypprice[1] and convicH > convicH[1]) or (exptypprice > exptypprice[1] and convicH < convicH[1]) then Color.Orange else if exptypprice < exptypprice[1] and convicH < convicH[1] then Color.Dark_RED else Color.Dark_GREEN);
plot A9_Dot = if IsNaN(close) then Double.NaN else 9;
A9_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A9_Dot.SetLineWeight(DotSize);
A9_Dot.AssignValueColor(if (exptypprice < exptypprice[1] and convicI > convicI[1]) or (exptypprice > exptypprice[1] and convicI < convicI[1]) then Color.Orange else if exptypprice < exptypprice[1] and convicI < convicI[1] then Color.DarK_RED else Color.Dark_GREEN);
plot A10_Dot = if IsNaN(close) then Double.NaN else 10;
A10_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A10_Dot.SetLineWeight(DotSize);
A10_Dot.AssignValueColor(if (exptypprice < exptypprice[1] and convicJ > convicJ[1]) or (exptypprice > exptypprice[1] and convicJ < convicJ[1]) then Color.Orange else if exptypprice < exptypprice[1] and convicJ < convicJ[1] then Color.Dark_RED else Color.Dark_GREEN);
plot A11_Dot = if IsNaN(close) then Double.NaN else 11;
A11_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A11_Dot.SetLineWeight(DotSize);
A11_Dot.AssignValueColor(if (exptypprice < exptypprice[1] and convicK > convicK[1]) or (exptypprice > exptypprice[1] and convicK < convicK[1]) then Color.Orange else if exptypprice < exptypprice[1] and convicK < convicK[1] then Color.Dark_RED else Color.Dark_GREEN);
plot A12_Dot = if IsNaN(close) then Double.NaN else 12;
A12_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A12_Dot.SetLineWeight(DotSize);
A12_Dot.AssignValueColor(if (exptypprice < exptypprice[1] and convicL > convicL[1]) or (exptypprice > exptypprice[1] and convicL < convicL[1]) then Color.Orange else if exptypprice < exptypprice[1] and convicL < convicL[1] then Color.Dark_RED else Color.Dark_GREEN);``````

Last edited by a moderator:
Here is the Volume weighted version
Code:
``````declare lower;
input period1 = 3;
input period2 = 5;
input period3 = 8;
input period4 = 10;
input period5 = 12;
input period6 = 15;
input period7 = 30;
input period8 = 35;
input period9 = 40;
input period10 = 45;
input period11 = 50;
input period12 = 60;
input ExponentialSmoothing = yes;
input SLength = 2;
input Dotsize = 3;
def range = high - low;
def bodytop = if close > open then close else open;
def bodybottom = if close < open then close else open;
def body = bodytop - bodybottom;
def perbody = body / range;
def rangeper = range / low * 100;
def volchnge = volume() - volume()[1];
def bodyper = rangeper * perbody;
def bullcon = if close > open and volume() > volume()[1] then volchnge * 2 + (volchnge * 2) * bodyper else if close > open and volume() < volume()[1] then volchnge + volchnge * bodyper else 0;
def bearcon = if close < open and volume() > volume()[1] then volchnge * -2 + (volchnge * -2) * bodyper else if close < open and volume() < volume()[1] then volchnge * -1 + (volchnge * -1) * bodyper else 0;
def exptypprice = ExpAverage(ExpAverage(ExpAverage((high + low + close) / 3, 3), 3), 3);
def convicA = if ExponentialSmoothing == yes then ExpAverage(ExpAverage(ExpAverage(Sum(bullcon, period1) + Sum(bearcon, period1), SLength), SLength), SLength) else Sum(bullcon, period1) + Sum(bearcon, period1);
def convicB = if ExponentialSmoothing == yes then ExpAverage(ExpAverage(ExpAverage(Sum(bullcon, period2) + Sum(bearcon, period2), SLength), SLength), SLength) else Sum(bullcon, period2) + Sum(bearcon, period2);
def convicC = if ExponentialSmoothing == yes then ExpAverage(ExpAverage(ExpAverage(Sum(bullcon, period3) + Sum(bearcon, period3), SLength), SLength), SLength) else Sum(bullcon, period3) + Sum(bearcon, period3);
def convicD = if ExponentialSmoothing == yes then ExpAverage(ExpAverage(ExpAverage(Sum(bullcon, period4) + Sum(bearcon, period4), SLength), SLength), SLength) else Sum(bullcon, period4) + Sum(bearcon, period4);
def convicE = if ExponentialSmoothing == yes then ExpAverage(ExpAverage(ExpAverage(Sum(bullcon, period5) + Sum(bearcon, period5), SLength), SLength), SLength) else Sum(bullcon, period5) + Sum(bearcon, period5);
def convicF = if ExponentialSmoothing == yes then ExpAverage(ExpAverage(ExpAverage(Sum(bullcon, period6) + Sum(bearcon, period6), SLength), SLength), SLength) else Sum(bullcon, period6) + Sum(bearcon, period6);
def convicG = if ExponentialSmoothing == yes then ExpAverage(ExpAverage(ExpAverage(Sum(bullcon, period7) + Sum(bearcon, period7), SLength), SLength), SLength) else Sum(bullcon, period7) + Sum(bearcon, period7);
def convicH = if ExponentialSmoothing == yes then ExpAverage(ExpAverage(ExpAverage(Sum(bullcon, period8) + Sum(bearcon, period8), SLength), SLength), SLength) else Sum(bullcon, period8) + Sum(bearcon, period8);
def convicI = if ExponentialSmoothing == yes then ExpAverage(ExpAverage(ExpAverage(Sum(bullcon, period9) + Sum(bearcon, period9), SLength), SLength), SLength) else Sum(bullcon, period9) + Sum(bearcon, period9);
def convicJ = if ExponentialSmoothing == yes then ExpAverage(ExpAverage(ExpAverage(Sum(bullcon, period10) + Sum(bearcon, period10), SLength), SLength), SLength) else Sum(bullcon, period10) + Sum(bearcon, period10);
def convicK = if ExponentialSmoothing == yes then ExpAverage(ExpAverage(ExpAverage(Sum(bullcon, period11) + Sum(bearcon, period11), SLength), SLength), SLength) else Sum(bullcon, period11) + Sum(bearcon, period11);
def convicL = if ExponentialSmoothing == yes then ExpAverage(ExpAverage(ExpAverage(Sum(bullcon, period12) + Sum(bearcon, period12), SLength), SLength), SLength) else Sum(bullcon, period12) + Sum(bearcon, period12);

plot A1_Dot = if IsNaN(close) then Double.NaN else 1;
A1_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A1_Dot.SetLineWeight(DotSize);
A1_Dot.AssignValueColor(if (exptypprice < exptypprice[1] and ConvicA > ConvicA[1]) or (exptypprice > exptypprice[1] and ConvicA < ConvicA[1]) then Color.YELLOW else if exptypprice < exptypprice[1] and ConvicA < ConvicA[1] then Color.LIGHT_RED else Color.LIGHT_GREEN);
plot A2_Dot = if IsNaN(close) then Double.NaN else 2;
A2_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A2_Dot.SetLineWeight(DotSize);
A2_Dot.AssignValueColor(if (exptypprice < exptypprice[1] and convicB > convicB[1]) or (exptypprice > exptypprice[1] and convicB < convicB[1]) then Color.YELLOW else if exptypprice < exptypprice[1] and convicB < convicB[1] then Color.LIGHT_RED else Color.LIGHT_GREEN);
plot A3_Dot = if IsNaN(close) then Double.NaN else 3;
A3_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A3_Dot.SetLineWeight(DotSize);
A3_Dot.AssignValueColor(if (exptypprice < exptypprice[1] and convicC > convicC[1]) or (exptypprice > exptypprice[1] and convicC < convicC[1]) then Color.YELLOW else if exptypprice < exptypprice[1] and convicC < convicC[1] then Color.LIGHT_RED else Color.LIGHT_GREEN);
plot A4_Dot = if IsNaN(close) then Double.NaN else 4;
A4_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A4_Dot.SetLineWeight(DotSize);
A4_Dot.AssignValueColor(if (exptypprice < exptypprice[1] and convicD > convicD[1]) or (exptypprice > exptypprice[1] and convicD < convicD[1]) then Color.YELLOW else if exptypprice < exptypprice[1] and convicD < convicD[1] then Color.LIGHT_RED else Color.LIGHT_GREEN);
plot A5_Dot = if IsNaN(close) then Double.NaN else 5;
A5_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A5_Dot.SetLineWeight(DotSize);
A5_Dot.AssignValueColor(if (exptypprice < exptypprice[1] and convicE > convicE[1]) or (exptypprice > exptypprice[1] and convicE < convicE[1]) then Color.YELLOW else if exptypprice < exptypprice[1] and convicE < convicE[1] then Color.LIGHT_RED else Color.LIGHT_GREEN);
plot A6_Dot = if IsNaN(close) then Double.NaN else 6;
A6_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A6_Dot.SetLineWeight(DotSize);
A6_Dot.AssignValueColor(if (exptypprice < exptypprice[1] and convicF > convicF[1]) or (exptypprice > exptypprice[1] and convicF < convicF[1]) then Color.YELLOW else if exptypprice < exptypprice[1] and convicF < convicF[1] then Color.LIGHT_RED else Color.LIGHT_GREEN);
plot A7_Dot = if IsNaN(close) then Double.NaN else 7;
A7_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A7_Dot.SetLineWeight(DotSize);
A7_Dot.AssignValueColor(if (exptypprice < exptypprice[1] and convicG > convicG[1]) or (exptypprice > exptypprice[1] and convicG < convicG[1]) then Color.Orange else if exptypprice < exptypprice[1] and convicG < convicG[1] then Color.Dark_RED else Color.Dark_GREEN);
plot A8_Dot = if IsNaN(close) then Double.NaN else 8;
A8_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A8_Dot.SetLineWeight(DotSize);
A8_Dot.AssignValueColor(if (exptypprice < exptypprice[1] and convicH > convicH[1]) or (exptypprice > exptypprice[1] and convicH < convicH[1]) then Color.Orange else if exptypprice < exptypprice[1] and convicH < convicH[1] then Color.Dark_RED else Color.Dark_GREEN);
plot A9_Dot = if IsNaN(close) then Double.NaN else 9;
A9_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A9_Dot.SetLineWeight(DotSize);
A9_Dot.AssignValueColor(if (exptypprice < exptypprice[1] and convicI > convicI[1]) or (exptypprice > exptypprice[1] and convicI < convicI[1]) then Color.Orange else if exptypprice < exptypprice[1] and convicI < convicI[1] then Color.DarK_RED else Color.Dark_GREEN);
plot A10_Dot = if IsNaN(close) then Double.NaN else 10;
A10_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A10_Dot.SetLineWeight(DotSize);
A10_Dot.AssignValueColor(if (exptypprice < exptypprice[1] and convicJ > convicJ[1]) or (exptypprice > exptypprice[1] and convicJ < convicJ[1]) then Color.Orange else if exptypprice < exptypprice[1] and convicJ < convicJ[1] then Color.Dark_RED else Color.Dark_GREEN);
plot A11_Dot = if IsNaN(close) then Double.NaN else 11;
A11_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A11_Dot.SetLineWeight(DotSize);
A11_Dot.AssignValueColor(if (exptypprice < exptypprice[1] and convicK > convicK[1]) or (exptypprice > exptypprice[1] and convicK < convicK[1]) then Color.Orange else if exptypprice < exptypprice[1] and convicK < convicK[1] then Color.Dark_RED else Color.Dark_GREEN);
plot A12_Dot = if IsNaN(close) then Double.NaN else 12;
A12_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A12_Dot.SetLineWeight(DotSize);
A12_Dot.AssignValueColor(if (exptypprice < exptypprice[1] and convicL > convicL[1]) or (exptypprice > exptypprice[1] and convicL < convicL[1]) then Color.Orange else if exptypprice < exptypprice[1] and convicL < convicL[1] then Color.Dark_RED else Color.Dark_GREEN);``````

Last edited by a moderator:
Wow, well all I can say is I greatly appreciate your input and I honestly never thought any of my work would come to fruition for anyone, but I'm glad someone found use for it. I'm going to take a look at that strategy you've come up with. I might be able to do a scan if you describe in more detail how the strategy works. What timeframes are you thinking? Daily? Also do you mean when MACD lines cross over simultaneously as the volume conviction index is crossing above or below zero?
Hi Jman. Read into your script and I agree it seems like it could be quite helpful as a TOS scan. Wondering if you were able to adapt it as such? Further, if we were to use it as a scan for short timeframes - 5 minute - I assume maintaining the conviction length at 18 would be proper?

Hi Jman. Read into your script and I agree it seems like it could be quite helpful as a TOS scan. Wondering if you were able to adapt it as such? Further, if we were to use it as a scan for short timeframes - 5 minute - I assume maintaining the conviction length at 18 would be proper?
I've yet to put in any effort into creating a scan unfortunately. I'm not quite sure where to start, I'm waiting on help from someone else to give an example of what they're looking for exactly in the scan. As far as a length of 18 goes, I came upon that length from creating another study I call a "Cycle Tuner" that finds the average length of bars from trough to trough. Basically it counts the amount of bars from one bottom to the next for so many bars and gives you an average of those counts. Using it mostly on the daily timeframe, it returned 16-18 bars with most securities. 18 was coming up a little more often. I tune most of my indicators to multiples of 18 or a half or 3rds of 18. Any indicator I use, I mess around with multiples/halves/3rds of 18 until I find what I'm looking for. The stock market is also almost fractal in a sense so I don't see why it wouldn't work on a 5 minute or 1 minute timeframe, but I wouldn't just keep it at 18 if it were me, I'd mess around with it a little and see if I notice anything interesting. Try 12 (2/3rds of 18), try 9 (half of 18), try 6 (1/3rd of 18). My longer term moving averages for example are set to 108 (10 x 18) and 216 (20 x 18). Hope that's helpful enough.

87k+ Posts
196 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?