Money Flow MFI For ThinkOrSwim

CoffeeKiller

New member
I trade almost totally on mobile and I was trying to make a simple money flow index that would plot points above or bellow the candles on the 74 and up for overbought and 26 and lower for oversold any help would be appreciated.

Code:
# Money Flow Index with Overbought and Oversold Points for Mobile

input length = 14;
input overbought = 74;
input oversold = 26;

def typicalPrice = (high + low + close) / 3;
def moneyFlow = typicalPrice * volume;

def moneyFlowRatio = if Sum(volume, length) != 0 then Sum(if typicalPrice > typicalPrice[1] then moneyFlow else if typicalPrice < typicalPrice[1] then -moneyFlow else 0, length) / Sum(if typicalPrice > typicalPrice[1] then volume else if typicalPrice < typicalPrice[1] then -volume else 0, length) else 0;

def mfi = 100 - (100 / (1 + moneyFlowRatio));

plot MFI = mfi;
plot Overbought = overbought;
plot Oversold = oversold;

MFI.AssignValueColor(if mfi >= overbought then Color.RED else if mfi <= oversold then Color.GREEN else Color.BLUE);
Overbought.SetDefaultColor(Color.RED);
Oversold.SetDefaultColor(Color.GREEN);

plot UpArrow = if  mfi crosses above overbought then low else double.NaN ;
UpArrow .SetPaintingStrategy(PaintingStrategy.POINTS);
UpArrow .SetLineWeight(5);
UpArrow .SetDefaultColor(color.blue) ;

plot DownArrow = if  mfi crosses below oversold then high else double.NaN ;
DownArrow  .SetPaintingStrategy(PaintingStrategy.POINTS);
DownArrow  .SetLineWeight(5);
DownArrow  .SetDefaultColor(color.magenta) ;

#AddChartBubble(MFI crosses above Overbought, Overbought, "Overbought", Color.WHITE, no);
#AddChartBubble(MFI crosses below Oversold, Oversold, "Oversold", Color.WHITE, yes);
 
Dear Community

currently i have script available for MFI visual graphic

def mfi = if volume > 0 then (high - low) / volume * 100 else 0;
plot MktFacilIdx = mfi;
MktFacilIdx.DefineColor("MFI UP, Vol UP", Color.GREEN);
MktFacilIdx.DefineColor("MFI DN, Vol DN", Color.DARK_RED);
MktFacilIdx.DefineColor("MFI UP, Vol DN", Color.BLUE);
MktFacilIdx.DefineColor("MFI DN, Vol UP", Color.PINK);
MktFacilIdx.AssignValueColor(if MktFacilIdx > MktFacilIdx[1] and volume > volume[1] then MktFacilIdx.Color("MFI UP, Vol UP") else
if MktFacilIdx < MktFacilIdx[1] and volume < volume[1] then MktFacilIdx.Color("MFI DN, Vol DN") else
if MktFacilIdx > MktFacilIdx[1] and volume < volume[1] then MktFacilIdx.Color("MFI UP, Vol DN") else
if MktFacilIdx < MktFacilIdx[1] and volume > volume[1] then MktFacilIdx.Color("MFI DN, Vol UP") else Color.CURRENT);
MktFacilIdx.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

as reflected above indicator produces bars in chart with certain color. my strategy is based on looking for stocks which will produce defined sequence (critical): green and pink bar for certain time frame 1H or 1D. So I need to refine this into study which will allow me to automate selection of tickers which will produce this combination: green and pink bar for example within last 10 or user defined bars. thank you, currently trying to rewrite script but no luck.
 
Code:
def mfi = if volume > 0 then (high - low) / volume * 100 else 0;
def green = mfi > mfi[1] and volume > volume[1];
def pink = mfi < mfi[1] and volume > volume[1];
plot Scan = green[1] and pink;
 
Thank you, Sir this solution works pretty well, please advise how can i limit search for certain number of bars backwards?
for example, I need to see list of stocks where green/pink appeared within last 10 days. Really appreciate your input.

found solution: input barsago = 10;
 
Last edited:

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