Momentum Bias Index [AlgoAlpha] For ThinkOrSwim

doogster7

New member
Plus
Author states: is designed to provide traders with a powerful tool for assessing market momentum bias. The indicator calculates the positive and negative bias of momentum to gauge which one is greater to determine the trend.

onKmVpl.png


Here is the original Tradingview code:
https://www.tradingview.com/script/oMZKratR-Momentum-Bias-Index-AlgoAlpha/

For the new ThinkOrSwim code, you must scroll down to the next post
 
Last edited by a moderator:

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

Inquiring to see if anyone has code for a Momentum Bias Index Indicator?
https://www.tradingview.com/script/oMZKratR-Momentum-Bias-Index-AlgoAlpha/

Thank you for consideration. doogster7

Tried the Pine script from the webpage address noted in the initial post for this indicator in ThinkorSwim but unsuccessful. The indicator was not able to be displayed on a chart. Is there a way to convert Pine Script to a TOS format so the indicator will show up on a chart? Thanks
Here is the code converted to TOS:
Ruby:
# -------------------------------------
# Momentum Bias Index (Algo Alpha)
# Converted to TOS by TraderSam
# 09/03/25
# -------------------------------------

declare lower;

# === inputs ===
input source = close;
input momentumLength = 10;
input biasLength = 5;
input smoothLength = 10;
input impulseBoundaryLength = 30;
input stdevMultiplier = 3;
input smoothIndicator = yes;
input PaintCandles = yes;

# === Basic Def ===
def momentum = source - source[momentumLength];
def StDev = momentum / (ExpAverage(high - low, momentumLength)) * 100;
def momentumUp = Max(StDev, 0);
def momentumDown = Min(StDev, 0);
def momentumUpBias = if smoothIndicator then Max(HullMovingAvg(Sum(momentumUp, biasLength), smoothLength), 0) else Sum(momentumUp, biasLength);
def momentumDownBias = if smoothIndicator then Max(HullMovingAvg(-Sum(momentumDown, biasLength), smoothLength), 0) else Sum(momentumDown, biasLength);
def averageBias = (momentumDownBias + momentumUpBias) / 2;

# === deviations ===
def chg1 = momentumUpBias * 0.80;
def chg2 = momentumUpBias * 0.60;
def chg3 = momentumUpBias * 0.40;
def chg4 = momentumUpBias * 0.20;
def chg1a = momentumDownBias * 0.80;
def chg2a = momentumDownBias * 0.60;
def chg3a = momentumDownBias * 0.40;
def chg4a = momentumDownBias * 0.20;

def boundary = ExpAverage(averageBias, impulseBoundaryLength) + stdev(averageBias, impulseBoundaryLength) * stdevMultiplier;

# === bullish and bearish signals ===
def bullishSignal = momentumDownBias[1] > momentumDownBias and momentumDownBias > boundary and momentumDownBias > momentumUpBias;
def bearishSignal = momentumUpBias[1] > momentumUpBias and momentumUpBias > boundary and momentumUpBias > momentumDownBias;

# === Candle Color (Optional) ===
AssignPriceColor(if PaintCandles then if momentumUpBias > momentumDownBias then Color.GREEN else if momentumUpBias < momentumDownBias then Color.RED else Color.GRAY
else Color.current);

# === plots ===
# Upward Momentum
plot UpBiasUp = if momentumUpBias > momentumUpBias[1] then momentumUpBias else Double.NaN;
UpBiasUp.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
UpBiasUp.SetDefaultColor(Color.GREEN);

plot UpBiasDown = if momentumUpBias < momentumUpBias[1] then momentumUpBias else Double.NaN;
UpBiasDown.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
UpBiasDown.SetDefaultColor(Color.DARK_GREEN);
UpBiasDown.SetLineWeight(4);

plot UpBiasChg1 = if momentumUpBias < momentumUpBias[1] then chg1 else Double.NaN;
UpBiasChg1.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
UpBiasChg1.SetDefaultColor(Color.DARK_GREEN);
UpBiasChg1.SetLineWeight(4);

plot UpBiasChg2 = if momentumUpBias < momentumUpBias[1] then chg2 else Double.NaN;
UpBiasChg2.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
UpBiasChg2.SetDefaultColor(Color.DARK_GREEN);
UpBiasChg2.SetLineWeight(4);

plot UpBiasChg3 = if momentumUpBias < momentumUpBias[1] then chg3 else Double.NaN;
UpBiasChg3.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
UpBiasChg3.SetDefaultColor(Color.DARK_GREEN);
UpBiasChg3.SetLineWeight(4);

plot UpBiasChg4 = if momentumUpBias < momentumUpBias[1] then chg4 else Double.NaN;
UpBiasChg4.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
UpBiasChg4.SetDefaultColor(Color.DARK_GREEN);
UpBiasChg4.SetLineWeight(4);

plot UpBiasLine = if momentumUpBias < momentumUpBias[1] then momentumUpBias else Double.NaN;
UpBiasLine.SetDefaultColor(Color.GREEN);
UpBiasLine.SetLineWeight(2);

# Downward Momentum
plot DownBiasUp = if momentumDownBias > momentumDownBias[1] then momentumDownBias else Double.NaN;
DownBiasUp.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
DownBiasUp.SetDefaultColor(Color.RED);

plot DownBiasDown = if momentumDownBias < momentumDownBias[1] then momentumDownBias else Double.NaN;
DownBiasDown.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
DownBiasDown.SetDefaultColor(Color.DARK_RED);
DownBiasDown.SetLineWeight(4);

plot DownBiasChg1 = if momentumDownBias < momentumDownBias[1] then chg1a else Double.NaN;
DownBiasChg1.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
DownBiasChg1.SetDefaultColor(Color.DARK_RED);
DownBiasChg1.SetLineWeight(4);

plot DownBiasChg2 = if momentumDownBias < momentumDownBias[1] then chg2a else Double.NaN;
DownBiasChg2.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
DownBiasChg2.SetDefaultColor(Color.DARK_RED);
DownBiasChg2.SetLineWeight(4);

plot DownBiasChg3 = if momentumDownBias < momentumDownBias[1] then chg3a else Double.NaN;
DownBiasChg3.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
DownBiasChg3.SetDefaultColor(Color.DARK_RED);
DownBiasChg3.SetLineWeight(4);

plot DownBiasChg4 = if momentumDownBias < momentumDownBias[1] then chg4a else Double.NaN;
DownBiasChg4.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
DownBiasChg4.SetDefaultColor(Color.DARK_RED);
DownBiasChg4.SetLineWeight(4);

plot DownBiasLine = if momentumDownBias < momentumDownBias[1] then momentumDownBias else Double.NaN;
DownBiasLine.SetDefaultColor(Color.RED);
DownBiasLine.SetLineWeight(2);

# Boundary Plot
plot BoundaryLine = boundary;
BoundaryLine.SetPaintingStrategy(PaintingStrategy.POINTS);
BoundaryLine.SetDefaultColor(Color.GRAY);
BoundaryLine.SetLineWeight(2);
Screenshot 2025-09-04 at 2.21.49 PM.png
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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