XPeriodCandle
Download scriptThis script is designed to create a specialized visual representation of price action on a trading chart. Instead of showing standard individual candles, it transforms market data into "Period Candles," which represent aggregated price movements over a specific timeframe defined by the user.
Here is a breakdown of how the logic functions:
Core Concept
The primary goal of this tool is to smooth out market noise by grouping multiple smaller price bars into single, larger consolidated candles. This allows traders to see the broader price trend more clearly without being distracted by minor fluctuations or "market flicker."
How it Works
-
Data Aggregation (Smoothing): The script utilizes several advanced smoothing algorithms (such as JJMA, ParMA, and others) to calculate the average prices for four key data points: Open, High, Low, and Close. It doesn't just take a simple average; it uses these mathematical models to ensure the resulting "Period Candle" reflects the true momentum of the market during that specific period.
-
Dynamic Calculation:
- Highs and Lows: For every period defined by the user, the script scans the underlying price action to find the absolute highest peak and lowest valley reached.
- Opening and Closing: It determines the starting and ending values based on the smoothing algorithms applied to the data.
- Refined Boundaries: The script includes a secondary logic check that compares the smoothed prices against the absolute highs and lows. This ensures that the visual candle always covers the full range of price movement, preventing "short" candles that might hide significant price spikes.
-
Visual Output: The result is plotted on your chart as custom-drawn candles. These candles are color-coded based on the price direction:
- One color represents a Bullish movement (where the period ended higher than it began).
- Another color represents a Bearish movement (where the period ended lower than it began).
- A neutral color is used for periods with little to no movement.
User Control Options
The script provides several inputs to customize the behavior:
- Period: Controls how many smaller bars are grouped together to form one "Period Candle."
- Smoothing Method: Allows you to choose different mathematical formulas to calculate the averages, letting you decide how "smooth" or "reactive" the candles should be.
- MA Length & Phase: These are technical parameters that fine-tune the smoothing algorithms (specifically for complex types like JJMA), allowing for high levels of customization regarding how the data is processed.
Summary
Essentially, this script acts as a "lens" for your trading chart. It takes raw, erratic price data and reorganizes it into structured, smoothed "Period Candles." This helps traders identify significant trend shifts and support/resistance levels by filtering out minor price volatility.
ÿþ/ / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
/ / | X P e r i o d C a n d l e . m q 5 |
/ / | C o p y r i g h t © 2 0 1 8 , N i k o l a y K o s i t s i n |
/ / | K h a b a r o v s k , f a r r i a @ m a i l . r e d c o m . r u |
/ / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
/ / - - - - 02B>@AB2> 8=48:0B>@0
# p r o p e r t y c o p y r i g h t "