Renko_v1_v2
Download scriptThis script is designed to transform standard price charts into a specialized "Renko" visualization. Unlike traditional charts that display price movements based on time (e.g., every minute or hour), this tool filters out market noise to focus exclusively on significant price movement.
Core Logic and Functionality
Volatility-Based Measurement The script begins by analyzing recent market history to determine the average volatility of the asset. It calculates a "brick size"—which is the minimum amount of price movement required to trigger a new visual update. This is achieved by looking at a specific period of previous data to establish a baseline for how much the price typically fluctuates.
Trend Identification Instead of showing every tiny fluctuation, the script monitors the price until it moves enough to complete a "brick."
- Upward Movement: If the price rises by the calculated brick size, the script identifies an upward trend and updates the visual markers accordingly.
- Downward Movement: If the price drops by the calculated brick size, it identifies a downward trend.
Mathematical Smoothing To ensure the visuals remain consistent, the logic uses rounding. This means that even if a price move is slightly larger than the required brick size, the script rounds the movement to the nearest whole "brick." This prevents the chart from becoming cluttered and ensures that each block represents a standardized unit of price change.
Visual Output The final result is a streamlined view of the market where only meaningful price progress is displayed. By ignoring small, insignificant movements (often referred to as "noise"), the tool allows traders to see the underlying trend more clearly, making it easier to identify whether the overall momentum is moving up or down.
//+------------------------------------------------------------------+
//| 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