MRM Histogram For ThinkOrSwim

Ajordan930

Member
VIP
Multi Momentum lower indicator w/AGAIG signal

This is something I created that focuses on the MACD, RSI, and MFI thus the MRM name.

Its looking increasing or decreasing values in those 3 indicators and when 2 of the 3 are increasing it will plot a 1/2 bar and when all three are present a full bar. Also it has 3 configurable ema's that will plot a label when they are stacked with a bar count as well.

Also A+ conditions are considered price is above last, all three momentum indicators are aligned higher, and above VWAP. Reverse that for puts. Also I embedded AGAIG from @csricksdds into the mix as well. I use this for scalping and have it on my 5, 3, and 1.

1771028151854.png


1 minute chart after hours
1771028382120.png

Code:
# =========================================================
# === MOMENTUM INDICATOR USING MCAD RSI AND MONEY FLOW INDEX
# === ALSO CONTAINS AS GOOD AS IT GETS AGAIG FROM @csricksdds CODE FOR REVERSALS
# =========================================================


declare lower;
declare real_size;

# =========================================================
# === USER INPUTS (EMA CONTROL)
# =========================================================
input fastLength = 5;
input shortLength = 9;
input midLength = 21;

# =========================================================
# === AS GOOD AS IT GETS – ZIGZAG REVERSALS
# =========================================================
input atrReversal = 2.0;
input useAlerts = no;

def priceH = ExpAverage(high, 10);
def priceL = ExpAverage(low, 10);

def zigLow = ZigZagHighLow(
"price h" = priceH,
"price l" = priceL,
"percentage reversal" = 0.01,
"absolute reversal" = 0.05,
"atr length" = 5,
"atr reversal" = atrReversal
).lastL;

def zigHigh = ZigZagHighLow(
"price h" = priceH,
"price l" = priceL,
"percentage reversal" = 0.01,
"absolute reversal" = 0.05,
"atr length" = 5,
"atr reversal" = atrReversal
).lastH;

def zigLong = !IsNaN(zigLow);
def zigShort = !IsNaN(zigHigh);

AddVerticalLine(zigLong, "LONG", Color.GREEN, Curve.LONG_DASH);
AddVerticalLine(zigShort, "SHORT", Color.RED, Curve.LONG_DASH);

Alert(useAlerts and zigLong[1], "ZigZag LONG", Alert.BAR, Sound.Ding);
Alert(useAlerts and zigShort[1], "ZigZag SHORT", Alert.BAR, Sound.Ding);

# =========================================================
# === EMA DEFINITIONS (DYNAMIC)
# =========================================================
def emaFast = ExpAverage(close, fastLength);
def emaShort = ExpAverage(close, shortLength);
def emaMid = ExpAverage(close, midLength);

def bullFastShort = emaFast > emaShort;
def bearFastShort = emaFast < emaShort;

def bullStack = emaFast > emaShort and emaShort > emaMid;
def bearStack = emaFast < emaShort and emaShort < emaMid;

# =========================================================
# === VWAP
# =========================================================
def vwapValue = VWAP();
def aboveVWAP = close > vwapValue;
def belowVWAP = close < vwapValue;

# =========================================================
# === INDICATORS
# =========================================================
def macdValue = MACD()."Value";
def rsiValue = RSI()."RSI";
def mfiValue = MoneyFlowIndex()."MoneyFlowIndex";

# =========================================================
# === MOMENTUM CONDITIONS
# =========================================================
def macdBull = macdValue > macdValue[1];
def rsiBull = rsiValue > rsiValue[1];
def mfiBull = mfiValue > mfiValue[1];

def macdBear = macdValue < macdValue[1];
def rsiBear = rsiValue < rsiValue[1];
def mfiBear = mfiValue < mfiValue[1];

# =========================================================
# === CONDITION COUNTS (OUT OF 3)
# =========================================================
def bullCount =
(if macdBull then 1 else 0) +
(if rsiBull then 1 else 0) +
(if mfiBull then 1 else 0);

def bearCount =
(if macdBear then 1 else 0) +
(if rsiBear then 1 else 0) +
(if mfiBear then 1 else 0);

# =========================================================
# === A+ CONDITIONS
# =========================================================
def priceBull = close > close[1];
def priceBear = close < close[1];

def aPlusBull =
macdBull and rsiBull and mfiBull and priceBull and bullFastShort and aboveVWAP;

def aPlusBear =
macdBear and rsiBear and mfiBear and priceBear and bearFastShort and belowVWAP;

# =========================================================
# === 2 OF 3 STATES
# =========================================================
def bull2of3 =
bullCount == 2 and
bullFastShort and
!aPlusBull;

def bear2of3 =
bearCount == 2 and
bearFastShort and
!aPlusBear;

# =========================================================
# === EMA ALIGNMENT RUN COUNTS
# =========================================================
def bullRunFastShort =
if bullFastShort then
if !bullFastShort[1] then 1
else bullRunFastShort[1] + 1
else 0;

def bearRunFastShort =
if bearFastShort then
if !bearFastShort[1] then 1
else bearRunFastShort[1] + 1
else 0;

def bullRunStack =
if bullStack then
if !bullStack[1] then 1
else bullRunStack[1] + 1
else 0;

def bearRunStack =
if bearStack then
if !bearStack[1] then 1
else bearRunStack[1] + 1
else 0;

# =========================================================
# === HISTOGRAM OUTPUT (4 STATES)
# =========================================================
def histValue =
if aPlusBull then 2
else if bull2of3 then 1
else if bear2of3 then -1
else if aPlusBear then -2
else 0;

plot MomoHist = histValue;
MomoHist.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
MomoHist.SetLineWeight(4);

MomoHist.AssignValueColor(
if histValue == 2 then Color.GREEN
else if histValue == 1 then Color.DARK_GREEN
else if histValue == -1 then Color.DARK_RED
else if histValue == -2 then Color.RED
else Color.DARK_GRAY
);

plot ZeroLine = 0;
ZeroLine.SetDefaultColor(Color.GRAY);
ZeroLine.SetLineWeight(1);

# =========================================================
# === LABELS (AUTO-UPDATE WITH EMA INPUTS)
# =========================================================
AddLabel(aPlusBull, "A+ LONG", Color.GREEN);
AddLabel(aPlusBear, "A+ SHORT", Color.RED);

AddLabel(bull2of3, "BULL 2 OF 3", Color.DARK_GREEN);
AddLabel(bear2of3, "BEAR 2 OF 3", Color.DARK_RED);

AddLabel(
bullRunFastShort > 0,
"EMA " + fastLength + "x" + shortLength + " BULL: " + bullRunFastShort,
Color.GREEN
);

AddLabel(
bearRunFastShort > 0,
"EMA " + fastLength + "x" + shortLength + " BEAR: " + bearRunFastShort,
Color.RED
);

AddLabel(
bullRunStack > 0,
"EMA " + fastLength + "x" + shortLength + "x" + midLength + " BULL: " + bullRunStack,
Color.DARK_GREEN
);

AddLabel(
bearRunStack > 0,
"EMA " + fastLength + "x" + shortLength + "x" + midLength + " BEAR: " + bearRunStack,
Color.DARK_RED
);
 
Last edited by a moderator:

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
2011 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