Visualizing Candlestick Body Proportions Relative to Shadows

02 Feb 2021
0 comment
0 attachment

This ProBuilder code snippet is designed to visually highlight candlesticks on a chart where the body is less than or equal to half the size of the shadows. This can be useful for traders looking to identify specific candlestick patterns that might indicate indecision or potential reversals in the market.


DEFPARAM CalculateOnLastBars = 1000
R=0
G=255
B=0
F=255

IF close > open THEN
    UpperShadow = high - close
    LowerShadow = open - low
ELSE
    UpperShadow = high - open
    LowerShadow = close - low
ENDIF

Shadows = UpperShadow + LowerShadow
Body = range - Shadows

IF Body <= (Shadows / 2) THEN
    DotVal = low - (100 * pipsize)
    DRAWTEXT("•",barindex,DotVal,Dialog,Bold,12) coloured(R,G,B,F)
ENDIF

RETURN

Explanation of the Code:

  • DEFPARAM CalculateOnLastBars = 1000: This line sets the indicator to calculate based on the last 1000 bars on the chart.
  • Color Variables (R, G, B, F): These lines define the color and opacity for the drawing. Here, it sets the color to green with full opacity.
  • Conditional Shadows Calculation: Depending on whether the close is greater than the open (bullish candle) or not (bearish candle), it calculates the lengths of the upper and lower shadows.
  • Shadows and Body Calculation: It sums the upper and lower shadows to get the total shadow length and subtracts this from the total range (high to low) of the candle to get the body length.
  • Conditional Drawing: If the body is less than or equal to half the length of the shadows, it draws a dot below the low of the candlestick. The position is adjusted by 100 times the pip size to ensure visibility.
  • DRAWTEXT Function: This function is used to place the dot on the chart, with parameters specifying the text style and color.

This snippet is particularly useful for identifying candles where the price action is uncertain or balanced between buyers and sellers, often seen in doji or spinning top formations.

Related Post

Check out this related content for more information:

https://www.prorealcode.com/topic/basing-candle-indicator/#post-44313

Visit Link
What is a Snippet? A snippet is a small, reusable chunk of code designed to solve specific tasks quickly. Think of it as a shortcut that helps you achieve your coding goals without reinventing the wheel. How to Use: Simply copy the snippet and paste it into your project where needed. Don't forget to tweak it to fit your context. Snippets are not just time-savers; they're also learning tools to help you become a more efficient coder.
robertogozzi Master
Roberto https://www.ots-onlinetradingsoftware.com
Author’s Profile

Comments

Search Snippets

Showing some results...
Sorry, no result found!

Snippets Categories

global
35
indicator
133
strategy
171

Recent Snippets

How to Create a Simple MTF Trend Dashboard with EMA and SMA
indicator
This indicator builds a compact multi-timeframe (MTF) dashboard that shows whether price is trading above or below a [...]
How to Display Per-Bar Volume Accumulation in Real Time (Intrabar Updates)
global
This snippet tracks and displays the current bar’s accumulated volume while the bar is still forming, instead of only [...]
Ticks Counter: Count Tick Updates Per Bar on Tick or Time Charts
global
This snippet counts how many tick updates have occurred for the current bar by incrementing a per-bar counter on each [...]
How to Build a Step-Based Trailing Stop That Moves to Break-Even First
strategy
This snippet implements a step trailing stop that advances in fixed increments once price reaches predefined profit [...]
Utilizing Arrays to Track and Compare Indicator Values Within the Same Bar in ProBuilder
indicator
This ProBuilder code snippet demonstrates how to use arrays to compare the values of an indicator (RSI in this case) [...]
Logo Logo
Loading...