OPEN-SOURCE SCRIPT

Buy/Sell EMA Candle

This indicator is designed to display various technical indicators, candle patterns, and trend directions on a price chart. Let's break down the code and explain its different sections:

Exponential Moving Averages (EMA):
The code calculates and plots five EMAs of different lengths (13, 21, 55, 90, and 200) on the price chart. These EMAs are used to identify trends and potential crossovers.

Engulfing Candle Patterns:
The code identifies and highlights potential bullish and bearish engulfing candle patterns. It checks if the current candle's body size is larger than the combined body sizes of the previous and subsequent four candles. If this condition is met, it marks the pattern on the chart.

https://s3.tradingview.com/snapshots/e/Ej3z4WAE.png

EMA Crossovers:
The code identifies and highlights points where the shorter EMA (ema1) crosses above or below the longer EMA (ema2). It plots circles to indicate these crossover points.

Candle Direction and RSI Trend:
The code determines the trend direction of the last candle based on whether it closed higher or lower than its open price. It also calculates the RSI (Relative Strength Index) and determines its trend direction (overbought, oversold, or neutral) based on predefined thresholds.

https://s3.tradingview.com/snapshots/5/5k1hdTPK.png

Table Display:
The code creates a table displaying trend directions for different timeframes (monthly, weekly, daily, 4-hour, and 1-hour) for candle direction and RSI trends. The trends are labeled with "L" for long, "S" for short, and "N/A" for not applicable.

High Volume Bars (HVB):
The code identifies and colors bars with above-average volume as either bullish or bearish based on whether the price closed higher or lower than it opened. The color and conditions for high volume bars can be customized.

https://s3.tradingview.com/snapshots/o/OWh6MTD6.png

Doji Candle Pattern:
The code identifies and marks doji candle patterns, where the open and close prices are very close to each other within a certain percentage of the candle's high-low range.

RSI-Based Candle Coloring:
The code adjusts the color of the candles based on the RSI value. If the RSI value is above the overbought threshold or below the oversold threshold, the candles are colored yellow.

Usage and Interpretation:

Traders can use this indicator to identify potential trend changes based on EMA crossovers and candle patterns like engulfing and doji.
The RSI trend direction can provide additional insight into potential overbought or oversold conditions.
High volume bars can indicate potential price reversals or continuation patterns.
The table provides an overview of trend directions on different timeframes for both candle direction and RSI trends.
Keep in mind that this is a complex indicator with multiple features. Users should carefully evaluate its performance and consider combining it with other indicators and analysis methods for more accurate trading decisions.


The table is designed to provide a consolidated view of trend directions and other indicators across multiple timeframes. It is displayed on the chart and organized into rows and columns. Each row corresponds to a specific aspect of analysis, and each column corresponds to a different timeframe.

Here's a breakdown of the components of the table:

Row 1: Separation.

Row 2 (Header Row): This row contains the headers for the columns. The headers represent the different timeframes being analyzed, such as Monthly (M), Weekly (W), Daily (D), 4-hour (4h), and 1-hour (1h).

Row 3 (Content Row): This row contains labels indicating the types of information being displayed in the columns. The labels include "T" for Trend, "C" for Current Candle, and "R" for RSI Trend.

Row 4 and Onwards: These rows display the actual data for each aspect of analysis across different timeframes.

For each aspect of analysis (Trend, Current Candle, RSI Trend), the corresponding rows display the following information:

Monthly (M): The trend direction for the given aspect on the monthly timeframe.
Weekly (W): The trend direction for the given aspect on the weekly timeframe.
Daily (D): The trend direction for the given aspect on the daily timeframe.
4-hour (4h): The trend direction for the given aspect on the 4-hour timeframe.
1-hour (1h): The trend direction for the given aspect on the 1-hour timeframe.
The trend directions are represented by labels such as "L" for Long, "S" for Short, or "N/A" for Not Applicable.

The table's purpose is to provide a quick overview of trend directions and related information across multiple timeframes, aiding traders in making informed decisions based on the analysis of trend changes and other indicators.
buysellsignalcandestickpatternsCandlestick analysisExponential Moving Average (EMA)emacrossoverEngulfing Candlersi-ema

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?


Also on:

Disclaimer