Trend Flow Profile [AlgoAlpha] for ThinkOrSwim

samer800

Moderator - Expert
VIP
Lifetime
vQyslA3.png


Author Message:
The "Trend Flow Profile" indicator is a powerful tool designed to analyze and interpret the underlying trends and reversals in a financial market. It combines the concepts of Order Flow and Rate of Change (ROC) to provide valuable insights into market dynamics, momentum, and potential trade opportunities. By integrating these two components, the indicator offers a comprehensive view of market sentiment and price movements, facilitating informed trading decisions.

CODE:

CSS:
#// https://www.tradingview.com/v/ui5VLe7A/
#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © AlgoAlpha X © Sushiboi77
#indicator('Trend Flow Profile [AlgoAlpha]', 'AlgoAlpha - ? Trend Flow Profile '
# Converted by Sam4Cok@Samer800    - 01/2024
declare lower;
#// Inputs
input colorBars = yes;
input timeframe = {Default "Chart", "Custom"};
input customTimeframe = AggregationPeriod.FIFTEEN_MIN;
input trendFlowPeriod = 12;         # 'Trend Flow Period'
input showEmaLine = yes;            # "Show EMA band?"
input emaLength = 8;                # "EMA Length"
input rocLength = 14;               # "ROC Length"

def na = Double.NaN;
def chart = timeframe==timeframe."Chart";
DefineGlobalColor("ln"  , CreateColor(240, 192, 0));
DefineGlobalColor("up2" , CreateColor(0,255,187));
DefineGlobalColor("up1" , CreateColor(0,177,129));
DefineGlobalColor("up3" , CreateColor(0,98,72));
DefineGlobalColor("dn2" , CreateColor(255,17,0));
DefineGlobalColor("dn1" , CreateColor(177,12,0));
DefineGlobalColor("dn3" , CreateColor(98,7,0));

def cHT = close(Period = customTimeframe);
def vHT = volume(Period = customTimeframe);
def c = if chart then close else cHT;
def v = if chart then volume else vHT;
#// Calculations
def trend = if c > c[1] then  v else
            if c < c[1] then -v else 0;
def volFlow = Sum(trend, trendFlowPeriod) / 1000;
def priceROC = RateOfChange(Price = c,Length = rocLength);
def tfIndicator = (priceROC + volFlow) / 2;
def emaTrend = ExpAverage(tfIndicator, emaLength);

#// Color Logic
def Col = if tfIndicator > 0 then
          if tfIndicator > tfIndicator[1] then  2 else  1 else
          if tfIndicator < tfIndicator[1] then -2 else -1;
def volVol = volFlow > 0;

#// Plots
plot avgTrend = if showEmaLine then emaTrend else na;    # 'EMA Trend Line'
plot TrendFlow = tfIndicator;    # 'Trend Flow'
plot VolumeFlow = volFlow;       # 'Volume Flow'
avgTrend.SetDefaultColor(GlobalColor("ln"));
TrendFlow.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
TrendFlow.AssignValueColor(if Col== 2 then GlobalColor("up2") else
                           if Col== 1 then GlobalColor("up1") else
                           if Col==-2 then GlobalColor("dn2") else
                           if Col==-1 then GlobalColor("dn1") else Color.GRAY);
VolumeFlow.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
VolumeFlow.AssignValueColor(if volVol then GlobalColor("up3") else GlobalColor("dn3"));

AssignPriceColor(if !colorBars then Color.CURRENT else
                 if Col== 2 then GlobalColor("up2") else
                 if Col== 1 then GlobalColor("up1") else
                 if Col==-2 then GlobalColor("dn2") else
                 if Col==-1 then GlobalColor("dn1") else Color.GRAY);

#-- END of CODE
 
Samer love all work and I put them all on my chart to try them out. One thing I ask is to put a way to scan the whole market. some work and the last sentinels didn't. It gave errors in the stock scanner. I look to scanner and then record how they do . again thank you for all you do and happy new year :)
 
Thank you, looks great. Does it repaint?

If you are using the MTF option; yes, all MTF indicators repaint until the higher timeframe candle closes.
If you are using the default chart aggregation, then no, there is no repainting calculations in this script.

It should be noted that the current candle of this, and most indicators on this forum, updates every tick until the candle closes. This is not considered repainting.
more about repainting: https://usethinkscript.com/threads/answers-to-commonly-asked-questions.6006/
 
Hello all, had to step away for a few weeks. I will be renewing shortly. In the meantime, I typically trade on the MTFs of M/W/D/H. What length should the flow, ema and roc be? Or do they need to be changed?
 

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