Repaints Volume-based Support & Resistance Zones V2 For ThinkOrSwim

Repaints

chienergyflow

New member
Author states: This indicator is based on high volume at fractal lows or fractal highs with the zones based on the size of the wick for that timeframe’s candle.
This helps traders visualize which price levels are of the most significance for either reversals or continuation of the trend when zones are broken and then re-tested.

gNyqLIb.png


The Original Link in Trading View:
https://www.tradingview.com/script/S2ClgBm5-Volume-based-Support-Resistance-Zones/
Find the ThinkOrSwim script below
 
Last edited by a moderator:
Original Link in Trading View:

https://www.tradingview.com/script/S2ClgBm5-Volume-based-Support-Resistance-Zones/

Hello @samer800 ,

Can you have a look at this "Volume Based Support and Resistance Zones" indicator? Is it possible to convert this into thinkscript? I appreciate any help you can provide. Thank you in advance @samer800 .
check the below - Add the indicator multiple times and set each indicator for the timeframe you want.

CSS:
# Indicator for TOS
#// @tommyf1001
#//indicator('Volume-based Support & Resistance Zones V2', shorttitle='Vol S/R Zones V2'
# Converted by Sam4Cok@Samer800    - 08/2024

input extendLastLines = yes;
input selectTimeframe = AggregationPeriod.FIVE_MIN;
input volumeMovAvgLength = 6; #(title='Volume MA - Threshold', d

def na = Double.NaN;
def last = isNaN(close);
def current = GetAggregationPeriod();
def tf1 = Max(selectTimeframe, Current);
def ext = if extendLastLines then yes else if last then no else yes;
#-- Color
DefineGlobalColor("dn", CreateColor(255, 82, 82));
DefineGlobalColor("up", CreateColor(0, 230, 118));
#// TFUp and TFDown Calculations
Script f_tfUp {
input _TF_High = high;
input _TF_Vol = volume;
input _TF_VolMA = volume;
    def f_tfUp = _TF_High[3] > _TF_High[4] and _TF_High[4] > _TF_High[5] and
                 _TF_High[2] < _TF_High[3] and _TF_High[1] < _TF_High[2] and _TF_Vol[3] > _TF_VolMA[3];
    plot out = if isNaN(f_tfUp) then no else f_tfUp;
}
Script f_tfDown {
input _TF_Low = low;
input _TF_Vol = volume;
input _TF_VolMA = volume;
    def f_tfDown = _TF_Low[3] < _TF_Low[4] and _TF_Low[4] < _TF_Low[5] and
                   _TF_Low[2] > _TF_Low[3] and _TF_Low[1] > _TF_Low[2] and _TF_Vol[3] > _TF_VolMA[3];
    plot out = if isNaN(f_tfDown) then 0 else f_tfDown;
}
#// S/R  = Time Frame 1 = TF1
def TF1_Vol = CompoundValue(1,if(volume(Period = tf1), volume(Period = tf1), TF1_Vol[1]), Volume(Period = tf1));
def TF1_VolMA = Average(TF1_Vol, volumeMovAvgLength);
def TF1_High  = CompoundValue(1, if(high(Period = tf1), high(Period = tf1), TF1_High[1]), high(Period = tf1));
def TF1_Low   = CompoundValue(1, if(low(Period = tf1), low(Period = tf1), TF1_Low[1]), low(Period = tf1));
def TF1_Open  = CompoundValue(1, if(open(Period = tf1), open(Period = tf1), TF1_Open[1]), open(Period = tf1));
def TF1_Close = CompoundValue(1, if(close(Period = tf1), close(Period = tf1), TF1_Close[1]), close(Period = tf1));

def TF1_Up = f_tfUp(TF1_High, TF1_Vol, TF1_VolMA);
def TF1_Down = f_tfDown(TF1_Low, TF1_Vol, TF1_VolMA);

def TF1_FractalUp = CompoundValue(1, if TF1_Up then TF1_High[3] else TF1_FractalUp[1], TF1_High);
def TF1_FractalDn = CompoundValue(1, if TF1_Down then TF1_Low[3] else TF1_FractalDn[1], TF1_Low);

def TF1_ResZone = CompoundValue(1, if TF1_Up and TF1_Close[3] >= TF1_Open[3] then TF1_Close[3] else
                  if TF1_Up and TF1_Close[3] < TF1_Open[3] then TF1_Open[3] else TF1_ResZone[1], TF1_Close[3]);
def TF1_SupZone = CompoundValue(1, if TF1_Down and TF1_Close[3] >= TF1_Open[3] then TF1_Open[3] else
                  if TF1_Down and TF1_Close[3] < TF1_Open[3] then TF1_Close[3] else TF1_SupZone[1], TF1_Close[3]);

def ResTop1 = CompoundValue(1,if(TF1_FractalUp!=TF1_FractalUp[1],TF1_FractalUp,ResTop1[1]),TF1_FractalUp);
def ResBot1 = CompoundValue(1,if TF1_FractalUp!=TF1_FractalUp[1] then TF1_ResZone else ResBot1[1], TF1_ResZone);
def SupTop1 = CompoundValue(1,if TF1_FractalDn!=TF1_FractalDn[1] then TF1_SupZone else SupTop1[1], TF1_SupZone);
def SupBot1 = CompoundValue(1,if(TF1_FractalDn!=TF1_FractalDn[1],TF1_FractalDn,SupBot1[1]), TF1_FractalDn);
def ResTop = if last then ResTop1[1] else ResTop1;
def ResBot = if last then ResBot1[1] else ResBot1;
def SupTop = if last then SupTop1[1] else SupTop1;
def SupBot = if last then SupBot1[1] else SupBot1;
def n = -((tf1 / current) * 2);

plot ResTopLine = if !ext then na else if ResTop[n] then ResTop[n] else na;
plot ResBotLine = if !ext then na else if ResBot[n] then ResBot[n] else na;

plot SupTopLine = if !ext then na else if SupTop[n] then SupTop[n] else na;
plot SupBotLine = if !ext then na else if SupBot[n] then SupBot[n] else na;

ResTopLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ResBotLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SupTopLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SupBotLine.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
ResTopLine.SetDefaultColor(GlobalColor("dn"));
ResBotLine.SetDefaultColor(GlobalColor("dn"));
SupTopLine.SetDefaultColor(GlobalColor("up"));
SupBotLine.SetDefaultColor(GlobalColor("up"));

#-- Cloud

AddCloud(if ResTopLine==ResTopLine[1] then ResTopLine else na, ResBotLine, Color.DARK_RED);
AddCloud(if SupTopLine==SupTopLine[1] then SupTopLine else na, SupBotLine, Color.DARK_GREEN);

def timeInMin = if tf1 < AggregationPeriod.HOUR then tf1 / AggregationPeriod.MIN else
                if tf1 < AggregationPeriod.DAY then tf1 / AggregationPeriod.HOUR else
                if tf1 < AggregationPeriod.WEEK then tf1 / AggregationPeriod.DAY else
                if tf1 < AggregationPeriod.MONTH then tf1 / AggregationPeriod.WEEK else
                tf1 / AggregationPeriod.MONTH;
def txt = if tf1 < AggregationPeriod.HOUR then 1 else
          if tf1 < AggregationPeriod.DAY then 2 else
          if tf1 < AggregationPeriod.WEEK then 3 else
          if tf1 < AggregationPeriod.MONTH then 4 else 5;

AddLabel(1, Round(timeInMin, 0) + (if txt == 1 then "Min" else
                         if txt == 2 then "H" else
                         if txt == 3 then "D" else
                         if txt == 4 then "W" else "M"), Color.WHITE);

#-- END of CODE
 

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