Candle Body Resistance Channel
Summary
The script calculates a Candle Body Resistance Channel based on the closing prices, using a simple moving average as a reference line and the highest and lowest values over the past 13 periods to define the channel's boundaries. It also provides options to identify bearish and bullish conditions based on the relationship between the closing price and the SMA. The plotting section allows for visualization of these channels, with an option to toggle their display.
Variables and Inputs
len
is set to 34, which represents the length of the Simple Moving Average (SMA) calculation period.src
is an input variable that takes the closing price (close
) as its default value. This is the source data for the CBRC calculation.
Calculations
Calculates the SMA over the specified period (
len
). This SMA will serve as a reference line within the CBRC.
last8h
finds the highest high over the past 13 periods.lastl8
finds the lowest low over the past 13 periods.
Checks for bearish and bullish conditions:
bearish
: True if the close crosses below the SMA (out
) and the close is falling.bullish
: True if the close crosses above the SMA (out
) and the close is rising.
Plotting
An input option to toggle the visibility of the channel lines on/off.
Plots the upper (
ul2
) and lower (ll2
) levels of the CBRC:Upper level (
ul2
): Ifchannel2
is true, plots the highest high (last8h
). Otherwise, checks if the current highest high is equal to the previous one; if so, it plots the current highest high; otherwise, it plotsna
(not a number).Lower level (
ll2
): Similar logic applies but for the lowest low (lastl8
).
Commented Out Fill
This line is commented out, but if uncommented, it would fill the area between the upper and lower levels of the CBRC with a semi-transparent black color, providing visual representation of the channel.
Citations:
Last updated