CBC Flip For ThinkOrSwim

FuBar

New member
The author states:
This is an indicator for the Candle By Candle (CBC) Flip strategy as created by @MapleStax
It’s useful to traders because it’s a simple approach to gauge if bulls or bears are in control for any particular candle. The logic is as follows:
If the most recent candle close is above the previous candle high, then bulls are in control.
If the most recent candle close is below the previous candle low, then bears are in control.
If neither of these 2 conditions are met, then whoever was already in control remains in force until one of the 2 conditions is met and the sentiment is flipped, hence the name CBC Flip.

The indicator output is simply interpreted as follows:
Triangle up = bulls in control
Triangle down = bears in control

In my experience this script is best used on the 5 or 10 minute time frames, as it helps to keep you in the trade for the bigger moves once a trend is established, while not getting shaken out from the “noisy” up/down candle price action of lower time frames like the 1 minute.

I’ve also had more success with this indicator when only taking long trades once the green triangle appears and price is above VWAP, and only taking short trades once the red triangle appears and price is below VWAP.
t3jCJ00.png


Can anyone convert the small amount of code below?

Thanks in advance!

https://www.tradingview.com/script/r9fHTyuj-CBC-Flip/
 
Last edited by a moderator:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Can anyone convert the small amount of code below?

Thanks in advance!

https://www.tradingview.com/script/r9fHTyuj-CBC-Flip/
find below

CSS:
#// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0
#// © friksa
#indicator("CBC Flip", overlay = true)
# Converted by Sam4Cok@Samer800    - 01/2024

input timeframe = {Default "Chart", "Custom"};
input customTimeframe = AggregationPeriod.FIFTEEN_MIN;

def cHTF = close(Period = customTimeframe);
def hHTF = high(Period = customTimeframe);
def lHTF = low(Period = customTimeframe);
def c; def h; def l;
Switch (timeframe) {
Case "Custom" :
    c = cHTF;
    h = hHTF;
    l = lHTF;
Default :
    c = close;
    h = high;
    l = low;
}
def na = Double.NaN;
def cbc;
def cbc1 = cbc[1];
if cbc1 and c < l[1] {
    cbc = no;
    } else
if !cbc1 and c > h[1] {
    cbc = yes;
    } else {
    cbc = cbc1;
}

plot dn = if !cbc and cbc[1] then high else na;
plot up = if cbc and !cbc[1] then low else na;

dn.SetPaintingStrategy(PaintingStrategy.BoOLEAN_WEDGE_UP);
up.SetPaintingStrategy(PaintingStrategy.BoOLEAN_WEDGE_DOWN);
dn.SetDefaultColor(Color.MAGENTA);
up.SetDefaultColor(Color.CYAN);

# end of CODE
 
Python:
dn.SetPaintingStrategy(PaintingStrategy.BoOLEAN_WEDGE_UP);
up.SetPaintingStrategy(PaintingStrategy.BoOLEAN_WEDGE_DOWN);

Should be inverted:

Python:
dn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
up.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
 
Python:
dn.SetPaintingStrategy(PaintingStrategy.BoOLEAN_WEDGE_UP);
up.SetPaintingStrategy(PaintingStrategy.BoOLEAN_WEDGE_DOWN);

Should be inverted:

Python:
dn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
up.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
Weges_Up and Down is location not direction. i.e above the candle or below the candle.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
220 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