Renko_v1_v1
Download scriptThis script is designed to transform standard price movements into a "Renko" chart format. Unlike traditional charts that show price fluctuations over specific periods of time (like minutes or hours), this tool filters out the "noise" of minor price ticks and focuses exclusively on significant price changes based on set movement targets.
Core Logic Overview
The primary goal of this script is to display a series of blocks, often called "bricks," where each brick represents a specific amount of price movement. If the price does not move enough to complete a full block in one direction, the chart effectively stays still, providing a much cleaner visual representation of the market trend.
Key Components of the Analysis
1. Volatility Measurement (The Foundation) To ensure the blocks are relevant to current market conditions, the script uses a volatility calculation. It looks back at a specific number of recent price bars to determine the average range between the highs and lows. By doing this, the script adapts to different markets—for example, it will create larger bricks during high-volatility periods and smaller bricks during quieter sessions.
2. Brick Construction The "size" of each brick is determined by a multiplier applied to that volatility measurement. This ensures that the movement required to form a new block is consistent with the recent behavior of the asset.
3. Trend Directional Logic The script monitors the closing price of the market continuously against the established boundaries of the last "brick":
- Upward Movement: If the market price rises beyond the upper boundary of the previous brick by the required amount, a new upward brick is created. The script calculates how many full blocks have been completed and moves the upper boundary accordingly.
- Downward Movement: Conversely, if the market price drops below the lower boundary of the previous brick by the required amount, a new downward brick is formed.
4. Visual Filtering By focusing only on these completed movements, the script ignores small, indecisive fluctuations that often occur within a trend. This allows a trader to see the "skeleton" of the price action—making it easier to identify whether the market is trending up, down, or moving sideways without being distracted by minor price spikes.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| Renko_v1.mq4 |
//| Copyright © 2005, TrendLaboratory Ltd. |
//| E-mail: igorad2004@list.ru |
//| Many Thanks To Konkop |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, TrendLaboratory Ltd."
#property link "E-mail: igorad2004@list.ru"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Aqua
#property indicator_color2 Magenta
//---- input parameters
extern int PeriodATR=10;
extern double Katr=1.00;
//---- indicator buffers
double UpBuffer[];
double DnBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicator line
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(0,UpBuffer);
SetIndexBuffer(1,DnBuffer);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
//---- name for DataWindow and indicator subwindow label
short_name="Renko("+PeriodATR+","+Katr+")";
IndicatorShortName(short_name);
SetIndexLabel(0,"Renko");
//----
SetIndexDrawBegin(0,PeriodATR);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Renko_v1 |
//+------------------------------------------------------------------+
int start()
{
int i,shift;
double Up,Dn,Brick,AvgRange,dK,ATR,BrickUp,BrickDn;
for(shift=Bars-1-PeriodATR;shift>=0;shift--)
{
AvgRange=0;
for (i=PeriodATR-1;i>=0;i--)
{
dK = 1;
AvgRange+=dK*MathAbs(High[i+shift]-Low[i+shift]);
}
ATR = AvgRange/PeriodATR;
if (shift==Bars-1-PeriodATR)
{
Up=High[shift];
Dn=Low[shift];
Brick=Katr*(High[shift]-Low[shift]);
}
if (shift<Bars-1-PeriodATR)
{
if (Close[shift] > Up + Brick)
{
if (Brick==0)
BrickUp=0;
else
BrickUp=MathRound((Close[shift]-Up)/Brick)*Brick;
Up = Up + BrickUp;
Brick = Katr*ATR;
Dn = Up - Brick;
BrickDn = 0;
}
if (Close[shift] < Dn - Brick)
{
if (Brick==0)
BrickDn=0;
else
BrickDn=MathRound((Dn-Close[shift])/Brick)*Brick;
Dn = Dn - BrickDn;
Brick = Katr*ATR;
Up = Dn + Brick;
BrickUp = 0;
}
}
UpBuffer[shift]=Up;
DnBuffer[shift]=Dn;
}
return(0);
}
Comments