Volume Participation Indicator For ThinkOrSwim

antwerks

Well-known member
VIP
VIP Enthusiast
Price Structure plus Volume Participation Module


How I’d read it

Best long setup sequence​

On SPY, the cleaner long sequence is:
  • participation oscillator stops falling
  • yellow early-up dot appears
  • histogram flips positive
  • companion line turns up
  • structure shifts from mixed to bull
  • green up arrow appears
That sequence says:
  • internals improved first
  • then price structure caught up
  • then the move became more trustworthy

Weak bounce / tactical only sequence​

If you get:
  • structure still bear or mixed
  • oscillator turns up
  • histogram improves
  • early dot prints
  • but no confirmed bull alignment
that is usually:
  • bounce potential
  • early repair
  • not yet a clean swing continuation state
That’s the kind of nuance we asked for.

Warning sequence​

If structure still says bull but:
  • oscillator drops below zero
  • histogram weakens
  • labels shift to conflict
that means:
  • price still looks okay on surface
  • participation is no longer backing it
  • next few bars are more vulnerable to stall, fade, or failed continuation

Code:
declare lower;

input price = close;
input fastEMALength = 8;
input slowEMALength = 21;
input structureLookback = 20;
input volumeLength = 20;
input partFastLength = 5;
input partSlowLength = 13;
input normalizeLength = 50;
input signalLength = 5;
input showZeroLine = yes;
input showMarkers = yes;
input showStretchMarkers = yes;
input stretchLength = 20;
input stretchTrigger = 1.5;

def na = Double.NaN;

# -----------------------------
# PRICE STRUCTURE MODULE
# -----------------------------
def fastEMAValue = ExpAverage(price, fastEMALength);
def slowEMAValue = ExpAverage(price, slowEMALength);
def fastEMASlope = fastEMAValue - fastEMAValue[1];

def highestRange = Highest(high, structureLookback);
def lowestRange = Lowest(low, structureLookback);
def structureMid = (highestRange + lowestRange) / 2;

def structureScore =
    (if fastEMAValue > slowEMAValue then 1 else -1) +
    (if fastEMASlope > 0 then 1 else -1) +
    (if price > structureMid then 1 else -1);

def structureBull = structureScore >= 2;
def structureBear = structureScore <= -2;
def structureMixed = !structureBull and !structureBear;

# -----------------------------
# VOLUME PARTICIPATION MODULE
# price change weighted by relative volume
# -----------------------------
def avgVolumeValue = Average(volume, volumeLength);
def relativeVolume = if avgVolumeValue > 0 then volume / avgVolumeValue else 1;

def priceDelta = price - price[1];
def weightedDelta = priceDelta * relativeVolume;

def partFastValue = ExpAverage(weightedDelta, partFastLength);
def partSlowValue = ExpAverage(weightedDelta, partSlowLength);

def rawParticipationOsc = partFastValue - partSlowValue;

def oscMean = Average(rawParticipationOsc, normalizeLength);
def oscStDev = StDev(rawParticipationOsc, normalizeLength);

def participationOsc =
    if oscStDev > 0
    then (rawParticipationOsc - oscMean) / oscStDev
    else 0;

def companionSignal = ExpAverage(participationOsc, signalLength);
def participationHist = participationOsc - companionSignal;

# -----------------------------
# PARTICIPATION STATES
# -----------------------------
def partPositive = participationOsc > 0;
def partNegative = participationOsc < 0;

def partRising = participationOsc > participationOsc[1];
def partFalling = participationOsc < participationOsc[1];

def earlyUpTurn =
    participationOsc > participationOsc[1] and
    participationOsc[1] <= participationOsc[2] and
    participationHist > 0 and
    !structureBull;

def earlyDownTurn =
    participationOsc < participationOsc[1] and
    participationOsc[1] >= participationOsc[2] and
    participationHist < 0 and
    !structureBear;

def confirmedUp =
    structureBull and
    participationOsc > 0 and
    companionSignal > 0 and
    participationHist > 0;

def confirmedDown =
    structureBear and
    participationOsc < 0 and
    companionSignal < 0 and
    participationHist < 0;

# -----------------------------
# SYNTHESIS LOGIC
# explicit precedence
# -----------------------------
def bullConfirmed = confirmedUp;
def bearConfirmed = confirmedDown;

def bullConflict =
    structureBull and
    partNegative;

def bearConflict =
    structureBear and
    partPositive;

def improvingBeforePrice =
    !structureBull and
    partPositive and
    partRising and
    participationHist > 0;

def weakeningBeforePrice =
    !structureBear and
    partNegative and
    partFalling and
    participationHist < 0;

def chopRisk =
    structureMixed or
    (structureBull and partNegative and participationHist >= 0) or
    (structureBear and partPositive and participationHist <= 0);

def nextBarsUpBias =
    bullConfirmed or
    (structureBull and partRising) or
    improvingBeforePrice;

def nextBarsDownBias =
    bearConfirmed or
    (structureBear and partFalling) or
    weakeningBeforePrice;

# -----------------------------
# STRETCH / DEVIATION MODULE
# -----------------------------
def stretchBasis = Average(price, stretchLength);
def stretchStDev = StDev(price, stretchLength);
def stretchZ =
    if stretchStDev > 0
    then (price - stretchBasis) / stretchStDev
    else 0;

def stretchHigh = stretchZ > stretchTrigger;
def stretchLow = stretchZ < -stretchTrigger;

# -----------------------------
# PLOTS
# -----------------------------
plot ZeroLine = if showZeroLine then 0 else na;
ZeroLine.SetDefaultColor(Color.GRAY);
ZeroLine.SetStyle(Curve.SHORT_DASH);

plot ParticipationLine = participationOsc;
ParticipationLine.SetLineWeight(2);
ParticipationLine.AssignValueColor(
    if participationOsc >= 0 and partRising then Color.GREEN
    else if participationOsc >= 0 then Color.DARK_GREEN
    else if participationOsc < 0 and partFalling then Color.RED
    else Color.DARK_RED
);

plot CompanionLine = companionSignal;
CompanionLine.SetDefaultColor(Color.CYAN);
CompanionLine.SetLineWeight(2);

plot Hist = participationHist;
Hist.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Hist.SetLineWeight(3);
Hist.AssignValueColor(
    if participationHist > 0 and participationHist > participationHist[1] then Color.UPTICK
    else if participationHist > 0 then Color.GREEN
    else if participationHist < 0 and participationHist < participationHist[1] then Color.DOWNTICK
    else Color.RED
);

# -----------------------------
# EARLY / LATE MARKERS
# -----------------------------
plot EarlyUpDot = if showMarkers and earlyUpTurn then participationOsc else na;
EarlyUpDot.SetPaintingStrategy(PaintingStrategy.POINTS);
EarlyUpDot.SetDefaultColor(Color.YELLOW);
EarlyUpDot.SetLineWeight(3);

plot EarlyDownDot = if showMarkers and earlyDownTurn then participationOsc else na;
EarlyDownDot.SetPaintingStrategy(PaintingStrategy.POINTS);
EarlyDownDot.SetDefaultColor(Color.ORANGE);
EarlyDownDot.SetLineWeight(3);

plot LateUpArrow = if showMarkers and bullConfirmed then participationOsc else na;
LateUpArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
LateUpArrow.SetDefaultColor(Color.GREEN);
LateUpArrow.SetLineWeight(2);

plot LateDownArrow = if showMarkers and bearConfirmed then participationOsc else na;
LateDownArrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
LateDownArrow.SetDefaultColor(Color.RED);
LateDownArrow.SetLineWeight(2);

# -----------------------------
# STRETCH MARKERS
# -----------------------------
plot StretchHighDot = if showStretchMarkers and stretchHigh and partFalling then participationOsc else na;
StretchHighDot.SetPaintingStrategy(PaintingStrategy.POINTS);
StretchHighDot.SetDefaultColor(Color.MAGENTA);
StretchHighDot.SetLineWeight(2);

plot StretchLowDot = if showStretchMarkers and stretchLow and partRising then participationOsc else na;
StretchLowDot.SetPaintingStrategy(PaintingStrategy.POINTS);
StretchLowDot.SetDefaultColor(Color.CYAN);
StretchLowDot.SetLineWeight(2);

# -----------------------------
# LABELS
# -----------------------------
AddLabel(
    yes,
    if structureBull then "Structure: Bull"
    else if structureBear then "Structure: Bear"
    else "Structure: Mixed",
    if structureBull then Color.GREEN
    else if structureBear then Color.RED
    else Color.GRAY
);

AddLabel(
    yes,
    if partPositive and partRising then "Participation: Positive and Rising"
    else if partPositive then "Participation: Positive but Slowing"
    else if partNegative and partFalling then "Participation: Negative and Falling"
    else if partNegative then "Participation: Negative but Improving"
    else "Participation: Flat",
    if partPositive and partRising then Color.GREEN
    else if partPositive then Color.DARK_GREEN
    else if partNegative and partFalling then Color.RED
    else if partNegative then Color.ORANGE
    else Color.GRAY
);

AddLabel(
    yes,
    if bullConfirmed then "Synthesis: Participation Confirms Price"
    else if bearConfirmed then "Synthesis: Participation Confirms Downside"
    else if bullConflict then "Synthesis: Bull Structure, Participation Not Confirming"
    else if bearConflict then "Synthesis: Bear Structure, Participation Improving"
    else if improvingBeforePrice then "Synthesis: Participation Improving Before Price"
    else if weakeningBeforePrice then "Synthesis: Participation Weakening Before Price"
    else "Synthesis: Mixed or Transitional",
    if bullConfirmed then Color.GREEN
    else if bearConfirmed then Color.RED
    else if improvingBeforePrice then Color.CYAN
    else if weakeningBeforePrice then Color.MAGENTA
    else Color.YELLOW
);

AddLabel(
    yes,
    if nextBarsUpBias and !nextBarsDownBias then "Next Few Bars: Up Bias"
    else if nextBarsDownBias and !nextBarsUpBias then "Next Few Bars: Down Bias"
    else if chopRisk then "Next Few Bars: Stall or Chop Risk"
    else "Next Few Bars: Balanced",
    if nextBarsUpBias and !nextBarsDownBias then Color.GREEN
    else if nextBarsDownBias and !nextBarsUpBias then Color.RED
    else Color.GRAY
);

 
Last edited by a moderator:

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

After inputting the above request to AI,On SPY, participation is no longer backing the next few bars... !
2026-07-20-TOS_CHARTSB.png

# -----------------------------
# VOLUME PARTICIPATION MODULE
# price change weighted by relative volume
# -----------------------------
def avgVolumeValue = Average(volume, volumeLength);
def relativeVolume = if avgVolumeValue > 0 then volume / avgVolumeValue else 1;

def priceDelta = price - price[1];
def weightedDelta = priceDelta * relativeVolume;

def partFastValue = ExpAverage(weightedDelta, partFastLength);
def partSlowValue = ExpAverage(weightedDelta, partSlowLength);

def rawParticipationOsc = partFastValue - partSlowValue;

def oscMean = Average(rawParticipationOsc, normalizeLength);
def oscStDev = StDev(rawParticipationOsc, normalizeLength);

def participationOsc =
if oscStDev > 0
then (rawParticipationOsc - oscMean) / oscStDev
else 0;

def companionSignal = ExpAverage(participationOsc, signalLength);
def participationHist = participationOsc - companionSignal;

# -----------------------------
# PARTICIPATION STATES
# -----------------------------
def partPositive = participationOsc > 0;
def partNegative = participationOsc < 0;

def partRising = participationOsc > participationOsc[1];
def partFalling = participationOsc < participationOsc[1];

def earlyUpTurn =
participationOsc > participationOsc[1] and
participationOsc[1] <= participationOsc[2] and
participationHist > 0 and
!structureBull;

def earlyDownTurn =
participationOsc < participationOsc[1] and
participationOsc[1] >= participationOsc[2] and
participationHist < 0 and
!structureBear;

def confirmedUp =
structureBull and
participationOsc > 0 and
companionSignal > 0 and
participationHist > 0;

def confirmedDown =
structureBear and
participationOsc < 0 and
companionSignal < 0 and
participationHist < 0;

# -----------------------------
# SYNTHESIS LOGIC
# explicit precedence
# -----------------------------
def bullConfirmed = confirmedUp;
def bearConfirmed = confirmedDown;

def bullConflict =
structureBull and
partNegative;

def bearConflict =
structureBear and
partPositive;

def improvingBeforePrice =
!structureBull and
partPositive and
partRising and
participationHist > 0;

def weakeningBeforePrice =
!structureBear and
partNegative and
partFalling and
participationHist < 0;

def chopRisk =
structureMixed or
(structureBull and partNegative and participationHist >= 0) or
(structureBear and partPositive and participationHist <= 0);

def nextBarsUpBias =
bullConfirmed or
(structureBull and partRising) or
improvingBeforePrice;

def nextBarsDownBias =
bearConfirmed or
(structureBear and partFalling) or
weakeningBeforePrice;

# -----------------------------
# STRETCH / DEVIATION MODULE
# -----------------------------
def stretchBasis = Average(price, stretchLength);
def stretchStDev = StDev(price, stretchLength);
def stretchZ =
if stretchStDev > 0
then (price - stretchBasis) / stretchStDev
else 0;

def stretchHigh = stretchZ > stretchTrigger;
def stretchLow = stretchZ < -stretchTrigger;

# -----------------------------
# PLOTS
# -----------------------------
plot ZeroLine = if showZeroLine then 0 else na;
ZeroLine.SetDefaultColor(Color.GRAY);
ZeroLine.SetStyle(Curve.SHORT_DASH);

plot ParticipationLine = participationOsc;
ParticipationLine.SetLineWeight(2);
ParticipationLine.AssignValueColor(
if participationOsc >= 0 and partRising then Color.GREEN
else if participationOsc >= 0 then Color.DARK_GREEN
else if participationOsc < 0 and partFalling then Color.RED
else Color.DARK_RED
);

plot CompanionLine = companionSignal;
CompanionLine.SetDefaultColor(Color.CYAN);
CompanionLine.SetLineWeight(2);

plot Hist = participationHist;
Hist.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Hist.SetLineWeight(3);
Hist.AssignValueColor(
if participationHist > 0 and participationHist > participationHist[1] then Color.UPTICK
else if participationHist > 0 then Color.GREEN
else if participationHist < 0 and participationHist < participationHist[1] then Color.DOWNTICK
else Color.RED
);

# -----------------------------
# EARLY / LATE MARKERS
# -----------------------------
plot EarlyUpDot = if showMarkers and earlyUpTurn then participationOsc else na;
EarlyUpDot.SetPaintingStrategy(PaintingStrategy.POINTS);
EarlyUpDot.SetDefaultColor(Color.YELLOW);
EarlyUpDot.SetLineWeight(3);

plot EarlyDownDot = if showMarkers and earlyDownTurn then participationOsc else na;
EarlyDownDot.SetPaintingStrategy(PaintingStrategy.POINTS);
EarlyDownDot.SetDefaultColor(Color.ORANGE);
EarlyDownDot.SetLineWeight(3);

plot LateUpArrow = if showMarkers and bullConfirmed then participationOsc else na;
LateUpArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
LateUpArrow.SetDefaultColor(Color.GREEN);
LateUpArrow.SetLineWeight(2);

plot LateDownArrow = if showMarkers and bearConfirmed then participationOsc else na;
LateDownArrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
LateDownArrow.SetDefaultColor(Color.RED);
LateDownArrow.SetLineWeight(2);

# -----------------------------
# STRETCH MARKERS
# -----------------------------
plot StretchHighDot = if showStretchMarkers and stretchHigh and partFalling then participationOsc else na;
StretchHighDot.SetPaintingStrategy(PaintingStrategy.POINTS);
StretchHighDot.SetDefaultColor(Color.MAGENTA);
StretchHighDot.SetLineWeight(2);

plot StretchLowDot = if showStretchMarkers and stretchLow and partRising then participationOsc else na;
StretchLowDot.SetPaintingStrategy(PaintingStrategy.POINTS);
StretchLowDot.SetDefaultColor(Color.CYAN);
StretchLowDot.SetLineWeight(2);

# -----------------------------
# LABELS
# -----------------------------
AddLabel(
yes,
if structureBull then "Structure: Bull"
else if structureBear then "Structure: Bear"
else "Structure: Mixed",
if structureBull then Color.GREEN
else if structureBear then Color.RED
else Color.GRAY
);

AddLabel(
yes,
if partPositive and partRising then "Participation: Positive and Rising"
else if partPositive then "Participation: Positive but Slowing"
else if partNegative and partFalling then "Participation: Negative and Falling"
else if partNegative then "Participation: Negative but Improving"
else "Participation: Flat",
if partPositive and partRising then Color.GREEN
else if partPositive then Color.DARK_GREEN
else if partNegative and partFalling then Color.RED
else if partNegative then Color.ORANGE
else Color.GRAY
);

AddLabel(
yes,
if bullConfirmed then "Synthesis: Participation Confirms Price"
else if bearConfirmed then "Synthesis: Participation Confirms Downside"
else if bullConflict then "Synthesis: Bull Structure, Participation Not Confirming"
else if bearConflict then "Synthesis: Bear Structure, Participation Improving"
else if improvingBeforePrice then "Synthesis: Participation Improving Before Price"
else if weakeningBeforePrice then "Synthesis: Participation Weakening Before Price"
else "Synthesis: Mixed or Transitional",
if bullConfirmed then Color.GREEN
else if bearConfirmed then Color.RED
else if improvingBeforePrice then Color.CYAN
else if weakeningBeforePrice then Color.MAGENTA
else Color.YELLOW
);

AddLabel(
yes,
if nextBarsUpBias and !nextBarsDownBias then "Next Few Bars: Up Bias"
else if nextBarsDownBias and !nextBarsUpBias then "Next Few Bars: Down Bias"
else if chopRisk then "Next Few Bars: Stall or Chop Risk"
else "Next Few Bars: Balanced",
if nextBarsUpBias and !nextBarsDownBias then Color.GREEN
else if nextBarsDownBias and !nextBarsUpBias then Color.RED
else Color.GRAY
);[/CODE]

different but true
 
@Adeodatus
It is not much extra work, especially if you want the best possible result.

You may assume that the latest Claude model is the strongest and will catch everything, but try testing a serious script or codebase through ChatGPT 5.6, Codex, or even DeepSeek. They will often find problems that the original model missed. When you paste those findings back into Claude, it may respond with something like, “How did I miss that?”

I use this approach regularly. One model builds the code, while other models test the logic, calculations, edge cases, and possible security issues.

Predicting future market movements is much harder. I created a pattern-recognition system that uses around ten years of historical data, Markov-based analysis, and other methods. It is written in Python and runs inside my custom dashboard, so it does not work directly with Thinkorswim.

You can build and test almost anything, but before using it for live trading, make sure it has undergone thorough testing, historical validation, edge-case testing, and paper trading. AI can help build the system, but it should never replace proper testing.
Could you share your pattern recognition system? Thanks.
 
On the Upper Volume Participation Module there is a lot of red as TOS doesn't support the parameters. Here is a cleanup of the code that is clean but might not be showing what you are looking for. Try this and let me know what parameters you are looking for in a different manner?

Code:
# -----------------------------
#Volume Participation Module
# INPUTS (previously undeclared - caused the red/error lines)
# -----------------------------
input volumeLength = 20;
input partFastLength = 5;
input partSlowLength = 20;
input normalizeLength = 50;
input signalLength = 9;
input stretchLength = 20;
input stretchTrigger = 2.0;
input showZeroLine = yes;
input showMarkers = yes;
input showStretchMarkers = yes;

# price was never assigned anywhere in the original script - defaulting to close
input price = close;

# -----------------------------
# PLACEHOLDER STRUCTURE LOGIC
# structureBull/Bear/Mixed were referenced but never defined anywhere.
# This is a simple MA-cross stand-in so the script compiles -
# replace with your real trend/regime logic if you have one.
# -----------------------------
input structureFastLength = 9;
input structureSlowLength = 21;
def structureFastAvg = Average(price, structureFastLength);
def structureSlowAvg = Average(price, structureSlowLength);
def structureBull = structureFastAvg > structureSlowAvg;
def structureBear = structureFastAvg < structureSlowAvg;
def structureMixed = structureFastAvg == structureSlowAvg;

# -----------------------------
# VOLUME PARTICIPATION MODULE
# price change weighted by relative volume
# -----------------------------
def avgVolumeValue = Average(volume, volumeLength);
def relativeVolume = if avgVolumeValue > 0 then volume / avgVolumeValue else 1;

def priceDelta = price - price[1];
def weightedDelta = priceDelta * relativeVolume;

def partFastValue = ExpAverage(weightedDelta, partFastLength);
def partSlowValue = ExpAverage(weightedDelta, partSlowLength);

def rawParticipationOsc = partFastValue - partSlowValue;

def oscMean = Average(rawParticipationOsc, normalizeLength);
def oscStDev = StDev(rawParticipationOsc, normalizeLength);

def participationOsc =
if oscStDev > 0
then (rawParticipationOsc - oscMean) / oscStDev
else 0;

def companionSignal = ExpAverage(participationOsc, signalLength);
def participationHist = participationOsc - companionSignal;

# -----------------------------
# PARTICIPATION STATES
# -----------------------------
def partPositive = participationOsc > 0;
def partNegative = participationOsc < 0;

def partRising = participationOsc > participationOsc[1];
def partFalling = participationOsc < participationOsc[1];

def earlyUpTurn =
participationOsc > participationOsc[1] and
participationOsc[1] <= participationOsc[2] and
participationHist > 0 and
!structureBull;

def earlyDownTurn =
participationOsc < participationOsc[1] and
participationOsc[1] >= participationOsc[2] and
participationHist < 0 and
!structureBear;

def confirmedUp =
structureBull and
participationOsc > 0 and
companionSignal > 0 and
participationHist > 0;

def confirmedDown =
structureBear and
participationOsc < 0 and
companionSignal < 0 and
participationHist < 0;

# -----------------------------
# SYNTHESIS LOGIC
# explicit precedence
# -----------------------------
def bullConfirmed = confirmedUp;
def bearConfirmed = confirmedDown;

def bullConflict =
structureBull and
partNegative;

def bearConflict =
structureBear and
partPositive;

def improvingBeforePrice =
!structureBull and
partPositive and
partRising and
participationHist > 0;

def weakeningBeforePrice =
!structureBear and
partNegative and
partFalling and
participationHist < 0;

def chopRisk =
structureMixed or
(structureBull and partNegative and participationHist >= 0) or
(structureBear and partPositive and participationHist <= 0);

def nextBarsUpBias =
bullConfirmed or
(structureBull and partRising) or
improvingBeforePrice;

def nextBarsDownBias =
bearConfirmed or
(structureBear and partFalling) or
weakeningBeforePrice;

# -----------------------------
# STRETCH / DEVIATION MODULE
# -----------------------------
def stretchBasis = Average(price, stretchLength);
def stretchStDev = StDev(price, stretchLength);
def stretchZ =
if stretchStDev > 0
then (price - stretchBasis) / stretchStDev
else 0;

def stretchHigh = stretchZ > stretchTrigger;
def stretchLow = stretchZ < -stretchTrigger;

# -----------------------------
# PLOTS
# -----------------------------
plot ZeroLine = if showZeroLine then 0 else Double.NaN;
ZeroLine.SetDefaultColor(Color.GRAY);
ZeroLine.SetStyle(Curve.SHORT_DASH);

plot ParticipationLine = participationOsc;
ParticipationLine.SetLineWeight(2);
ParticipationLine.AssignValueColor(
if participationOsc >= 0 and partRising then Color.GREEN
else if participationOsc >= 0 then Color.DARK_GREEN
else if participationOsc < 0 and partFalling then Color.RED
else Color.DARK_RED
);

plot CompanionLine = companionSignal;
CompanionLine.SetDefaultColor(Color.CYAN);
CompanionLine.SetLineWeight(2);

plot Hist = participationHist;
Hist.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Hist.SetLineWeight(3);
Hist.AssignValueColor(
if participationHist > 0 and participationHist > participationHist[1] then Color.UPTICK
else if participationHist > 0 then Color.GREEN
else if participationHist < 0 and participationHist < participationHist[1] then Color.DOWNTICK
else Color.RED
);

# -----------------------------
# EARLY / LATE MARKERS
# -----------------------------
plot EarlyUpDot = if showMarkers and earlyUpTurn then participationOsc else Double.NaN;
EarlyUpDot.SetPaintingStrategy(PaintingStrategy.POINTS);
EarlyUpDot.SetDefaultColor(Color.YELLOW);
EarlyUpDot.SetLineWeight(3);

plot EarlyDownDot = if showMarkers and earlyDownTurn then participationOsc else Double.NaN;
EarlyDownDot.SetPaintingStrategy(PaintingStrategy.POINTS);
EarlyDownDot.SetDefaultColor(Color.ORANGE);
EarlyDownDot.SetLineWeight(3);

plot LateUpArrow = if showMarkers and bullConfirmed then participationOsc else Double.NaN;
LateUpArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
LateUpArrow.SetDefaultColor(Color.GREEN);
LateUpArrow.SetLineWeight(2);

plot LateDownArrow = if showMarkers and bearConfirmed then participationOsc else Double.NaN;
LateDownArrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
LateDownArrow.SetDefaultColor(Color.RED);
LateDownArrow.SetLineWeight(2);

# -----------------------------
# STRETCH MARKERS
# -----------------------------
plot StretchHighDot = if showStretchMarkers and stretchHigh and partFalling then participationOsc else Double.NaN;
StretchHighDot.SetPaintingStrategy(PaintingStrategy.POINTS);
StretchHighDot.SetDefaultColor(Color.MAGENTA);
StretchHighDot.SetLineWeight(2);

plot StretchLowDot = if showStretchMarkers and stretchLow and partRising then participationOsc else Double.NaN;
StretchLowDot.SetPaintingStrategy(PaintingStrategy.POINTS);
StretchLowDot.SetDefaultColor(Color.CYAN);
StretchLowDot.SetLineWeight(2);

# -----------------------------
# LABELS
# -----------------------------
AddLabel(
yes,
if structureBull then "Structure: Bull"
else if structureBear then "Structure: Bear"
else "Structure: Mixed",
if structureBull then Color.GREEN
else if structureBear then Color.RED
else Color.GRAY
);

AddLabel(
yes,
if partPositive and partRising then "Participation: Positive and Rising"
else if partPositive then "Participation: Positive but Slowing"
else if partNegative and partFalling then "Participation: Negative and Falling"
else if partNegative then "Participation: Negative but Improving"
else "Participation: Flat",
if partPositive and partRising then Color.GREEN
else if partPositive then Color.DARK_GREEN
else if partNegative and partFalling then Color.RED
else if partNegative then Color.ORANGE
else Color.GRAY
);

AddLabel(
yes,
if bullConfirmed then "Synthesis: Participation Confirms Price"
else if bearConfirmed then "Synthesis: Participation Confirms Downside"
else if bullConflict then "Synthesis: Bull Structure, Participation Not Confirming"
else if bearConflict then "Synthesis: Bear Structure, Participation Improving"
else if improvingBeforePrice then "Synthesis: Participation Improving Before Price"
else if weakeningBeforePrice then "Synthesis: Participation Weakening Before Price"
else "Synthesis: Mixed or Transitional",
if bullConfirmed then Color.GREEN
else if bearConfirmed then Color.RED
else if improvingBeforePrice then Color.CYAN
else if weakeningBeforePrice then Color.MAGENTA
else Color.YELLOW
);

AddLabel(
yes,
if nextBarsUpBias and !nextBarsDownBias then "Next Few Bars: Up Bias"
else if nextBarsDownBias and !nextBarsUpBias then "Next Few Bars: Down Bias"
else if chopRisk then "Next Few Bars: Stall or Chop Risk"
else "Next Few Bars: Balanced",
if nextBarsUpBias and !nextBarsDownBias then Color.GREEN
else if nextBarsDownBias and !nextBarsUpBias then Color.RED
else Color.GRAY
);
 
Last edited by a moderator:
Could you share your pattern recognition system? Thanks.
hERE IS A DECENT VOLUME pARTICIPATION oSCILLATOR

Code:
# Volume_Oscillator
# Modified by (Opunui25) useThinkScript.com Member
# Based on KVO-Complete by Mauro Carrizales https://github.com/Mauro-C
# Credit for the initial algorithm goes to Stephen J. Klinger.
# Nov 13 2020
# Displays on Upper
# Plots the KVO (Klinger Volume Oscillator) using high, low, close and volume to create a volume force. This volume force (VF) is then turned into an oscillator by taking a fast EMA (exponential moving average) of VF and subtracting a slow EMA of VF. A Klinger Oscillator Signal line (KOS), which is an EMA of the Klinger Oscillator (KO), is plotted to trigger trading signals. Can be used on any timeframe.
# update antwerks

declare lower;

#Inputs
input MALength = 20;
input PaintBars = no;
input ShowLabels = yes;
#Variables
def DM = high - low;
def Trend = if hlc3 > hlc3[1] then 1 else -1;
def CM = DM + if Trend == Trend[1] then CM[1] else DM[1];
def VForce = if CM != 0 then Trend * 100 * volume * AbsValue(2 * DM / CM - 1) else VForce[1];

#Plots
plot KOS = ExpAverage(VForce, 34) - ExpAverage(VForce, 55);
plot TriggerLine = Average(KOS, MALength);
plot ZeroLine = 0;
plot KVOH = KOS - Average(KOS, MALength);

#Painting
KVOH.DefineColor("Positive", Color.UPTICK);
KVOH.DefineColor("Negative", Color.DOWNTICK);
KVOH.AssignValueColor(if KVOH >= 0 then KVOH.color("Positive") else KVOH.color("Negative"));
KVOH.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
KVOH.SetLineWeight(3);

KOS.SetDefaultColor(GetColor(6));

TriggerLine.SetDefaultColor(GetColor(1));

ZeroLine.SetDefaultColor(GetColor(5));

#This option is controled by the PaintBars input and will allow you to change the color of the candles to reflect the current VF direction
AssignPriceColor(if KOS >= TriggerLine and PaintBars == yes then KVOH.color("Positive") else if KOS <= TriggerLine and PaintBars == yes then KVOH.color("Negative") else Color.CURRENT);

#===========================================================
# PLAIN-ENGLISH VOLUME PRESSURE LABELS
#===========================================================

def BullishPressure = KOS > TriggerLine;
def BearishPressure = KOS < TriggerLine;

def PressureStrengthening =
    AbsValue(KVOH) > AbsValue(KVOH[1]);

def PressureWeakening =
    AbsValue(KVOH) < AbsValue(KVOH[1]);

AddLabel(
    ShowLabels,
    if BullishPressure and KOS > 0 and PressureStrengthening then
        "VOLUME PRESSURE: STRONG BULLISH - upward volume momentum is expanding"
    else if BullishPressure and PressureStrengthening then
        "VOLUME PRESSURE: TURNING BULLISH - upward volume momentum is improving"
    else if BullishPressure and PressureWeakening then
        "VOLUME PRESSURE: BULLISH BUT WEAKENING"
    else if BearishPressure and KOS < 0 and PressureStrengthening then
        "VOLUME PRESSURE: STRONG BEARISH - downward volume momentum is expanding"
    else if BearishPressure and PressureStrengthening then
        "VOLUME PRESSURE: TURNING BEARISH - downward volume momentum is increasing"
    else if BearishPressure and PressureWeakening then
        "VOLUME PRESSURE: BEARISH BUT IMPROVING"
    else
        "VOLUME PRESSURE: NEUTRAL OR TRANSITIONING",

    if BullishPressure and PressureStrengthening then Color.GREEN
    else if BearishPressure and PressureStrengthening then Color.RED
    else Color.YELLOW
);

AddLabel(
    ShowLabels,
    if KVOH < 0 and KVOH > KVOH[1] then
        "WATCH NEXT: bearish pressure is fading - possible bullish trigger cross"
    else if KVOH > 0 and KVOH < KVOH[1] then
        "WATCH NEXT: bullish pressure is fading - possible bearish trigger cross"
    else if KVOH > 0 and KVOH >= KVOH[1] then
        "WATCH NEXT: bullish volume direction remains supported"
    else if KVOH < 0 and KVOH <= KVOH[1] then
        "WATCH NEXT: bearish volume direction remains supported"
    else
        "WATCH NEXT: wait for a clearer volume shift",

    if KVOH < 0 and KVOH > KVOH[1] then Color.LIGHT_GREEN
    else if KVOH > 0 and KVOH < KVOH[1] then Color.YELLOW
    else if KVOH > 0 then Color.GREEN
    else if KVOH < 0 then Color.RED
    else Color.GRAY
);
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
1386 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