Supply and Demand Zone Confirmation for ThinkOrSwim

samer800

Moderator - Expert
VIP
Lifetime
LoYyzE5.png

Author Message:
mixing RSI and CCI in different timeframe. You can use this indicator in various ways, however the best possible way I would recommend you to use it is to combine it with price action. I would suggest to play with, so you can decide if it works the best for you.
The whole purpose of making this indicator was to eliminate confusion around different indicators for overbought and oversold and many other headaches. You use price action and you are looking for confirmation to see there is a PRZ? here is your indicator. I found there are certain patterns with CCI and RSI in higher timeframe which helps to find the PRZ and I made this indicator with it.

You can choose to use this indicator in different timeframe. But you have to consider, the lower timeframe you'll go, you will get more signals but the effectiveness goes down with it. Also, if you are willing to change the time frame, You have to change some settings as well which I'll get into it in a moment.

The default settings are for 30min timeframe with these settings.

https://ibb.co/Z2LB8pY

In case you would like to go to 15min time frame, here is the suggested changes in the setting.

https://ibb.co/SfvMs2h

I would suggest to play with different timeframe to find the suitable setting for the pairs you would like to trade. The main goal is you have to choose first CCI one timeframe higher ( if you are in 5min chart, first CCI should be at least 15 or 30min) and the second CCI one timeframe higher than first CCI (if you choose 15min for first CCI , go with 1hr for second CCI ). And lastly, RSI can be variable but it is suggested to be at least as low as first CCI timeframe.

CODE:
CSS:
#/ This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © MBCryptocurrency
#indicator("Supply and Demand Zone Confirmation",  overlay=true, timeframe="", timeframe_gaps=false)
# Converted and mod by Sam4Cok@samer800 - 01/2023

#//CCI
input ShowLabel  = yes;
input cci1Timeframe = AggregationPeriod.HOUR;      # 'First CCI timeframe'
input cci2Timeframe = AggregationPeriod.TWO_HOURS; # 'second CCI timeframe'
input rsiTimeframe = AggregationPeriod.HOUR;
input MovAvgType = AverageType.SIMPLE;

def na = Double.NaN;

def hlc60  = hlc3(Period = cci1Timeframe);
def hlc120 = hlc3(Period = cci2Timeframe);

def ma = MovingAverage(MovAvgType, hlc3, 14);
def cci = (hlc3 - ma) / (0.015 * LinDev(hlc3, 20));

def ma60 = MovingAverage(MovAvgType, hlc60, 14);
def cci6 = (hlc60 - ma60) / (0.015 * LinDev(hlc60, 20));

def ma120 = MovingAverage(MovAvgType, hlc120, 14);
def cci120 = (hlc120 - ma120) / (0.015 * LinDev(hlc120, 20));

def CCI15 = cci6;
def CCI60 = cci120;

#///RSI

def change = close - close[1];
def change60 = close(Period=RSItimeframe) - close(Period=RSItimeframe)[1];

def up   = WildersAverage(max(change, 0), 14);
def down = WildersAverage(-min(change, 0), 14);
def rsi = if down == 0 then 100 else
          if up == 0 then 0 else 100 - (100 / (1 + up / down));
def rsiMA = MovingAverage(MovAvgType, rsi, 14);

def up60   = WildersAverage(max(change60, 0), 14);
def down60 = WildersAverage(-min(change60, 0), 14);
def rsi60  = if down60 == 0 then 100 else
             if up60 == 0 then 0 else 100 - (100 / (1 + up60 / down60));
def rsi15 = rsi60;

#//condition
def cross  = crosses(cci,-100);
def cross2 = crosses(cci,100);

def signal_buy;# = false
def signal_sell;# = false

if  CCI15 < -100 and CCI60 < -150 and rsiMA < 35 and rsi15 < 50 {
    signal_buy = yes;
    signal_sell = no;
    } else
if  CCI15 > 100 and CCI60 > 150 and rsiMA > 65 and rsi15 > 50 {
    signal_buy = no;
    signal_sell = yes;
    } else {
    signal_buy = no;
    signal_sell = no;
}
#//only first signal to show
def Buy;# = false
def Sell;# = false

Buy  = if signal_buy then yes else
       if signal_sell then no else if cross then no else if cross2 then no else Buy[1];
Sell = if signal_sell then yes else
       if signal_buy then no else if cross then no else if cross2 then no else Sell[1];

def Final_buy  = signal_buy and !Buy[1];
def Final_sell = signal_sell and !Sell[1];

#--- Lines
def buyLineL = if Final_buy then low[1] else buyLineL[1];
def buyLineH = if Final_buy then high[1] else buyLineH[1];
def SellLineH = if Final_sell then high[1] else SellLineH[1];
def SellLineL = if Final_sell then low[1] else SellLineL[1];

plot SupLineL  = if buyLineL==buyLineL[1] then buyLineL else na;
plot SupLineH  = if buyLineH==buyLineH[1] then buyLineH else na;
plot ResLineH  = if SellLineH==SellLineH[1] then SellLineH else na;
plot ResLineL  = if SellLineL==SellLineL[1] then SellLineL else na;

SupLineL.setHiding(yes);
SupLineH.SetHiding(yes);
ResLineH.SetHiding(yes);
ResLineL.SetHiding(yes);

AddCloud(SupLineH, SupLineL, Color.DARK_GREEN, Color.DARK_GREEN, yes);
AddCloud(ResLineH, ResLineL, Color.DARK_RED, Color.DARK_RED, yes);
#//plotshapes

AddChartBubble(ShowLabel and Final_sell, high, "Sell Zone", Color.RED, yes);
AddChartBubble(ShowLabel and Final_buy, low, "Buy Zone", Color.GREEN, no);



#--- END CODE
 
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
439 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