RSL1
Download scriptThis script is designed as a visual analysis tool for trading charts that identifies specific structural movements in price action by monitoring the relationship between market trends and price extremes. Instead of just showing standard lines, it creates a dynamic "histogram" of historical activity on your screen.
Core Logic Overview
The tool operates by analyzing two main components: the movement of an Exponential Moving Average (EMA) and the discovery of new price highs or lows. Here is how the logic flows step-by-step:
1. Establishing the Market Boundaries When the script starts, it scans the entire visible history of the asset to identify the absolute highest price point and the absolute lowest price point reached. This creates a "container" or a coordinate system for the chart, ensuring that all data is scaled correctly within the range of what the market has actually achieved.
2. Monitoring Trend Reversals The script constantly watches the behavior of a Moving Average (EMA). It is specifically looking for "inflection points"—moments where the moving average changes direction (e.g., when it stops falling and starts rising, or vice versa).
3. Identifying "Significant" Price Hits Whenever the moving average flips direction, the script checks if the price at that exact moment has broken a previous boundary:
- If the trend turns upward and breaks a previous high, it logs an occurrence.
- If the trend turns downward and breaks a previous low, it logs an occurrence.
4. Calculating the Distribution (The Histogram) Instead of just marking these events on a timeline, the script calculates the "distance" from the bottom of the price range to the point where the breakout occurred. It then increments a counter for that specific price level. This effectively creates a frequency map: it tracks how many times the market has interacted with specific price zones during trend shifts.
5. Visual Rendering Finally, the script translates this data into visual objects on your chart. It draws horizontal dotted rectangles that represent these frequency "hits."
- The height and position of these visual elements are determined by the price levels identified in the previous steps.
- The length of the visual marks is adjusted based on a user-defined multiplier, allowing you to customize how prominent the historical data appears on your screen.
Summary for the User
In plain terms, this tool tells you where the "action" has happened most frequently in the past. By identifying every time a trend change coincided with a new price peak or valley, it visualizes zones of historical significance. This allows you to see at a glance which price levels have historically acted as turning points for the market, helping you identify potential areas of resistance or support based on past behavior.
//+------------------------------------------------------------------+
//| RSL1.mq4 |
//| Copyright © 2006, Õàðèòîíîâ À. |
//| HaritonovAB@rambler.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, MetaQuotes Software Corp."
#property link "HaritonovAB@rambler.ru"
#property indicator_chart_window
#property indicator_buffers 1
//---- input parameters
extern int MA_period=20; // Ïåðèîä îïîðíîé ñêîëüçÿùåé ñðåäíåé (MA)
extern double LHistoCor=1.0; // Ìíîæèòåëü êîððåêòèðîâêè âèäèìîé äëèíû ãèñòîãðàììû
extern color Hcolor=Red; // Öâåò ãèñòîãðàììû
double MA[];
int RS[];
int FS,n;
double maxHigh,minLow;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
IndicatorBuffers(1);
SetIndexStyle(0,DRAW_NONE);
SetIndexBuffer(0,MA);
int Asize;
maxHigh=High[Highest(NULL,0,MODE_HIGH,WHOLE_ARRAY,0)];
minLow =Low[Lowest(NULL,0,MODE_LOW,WHOLE_ARRAY,0)];
Asize= (maxHigh - minLow)/Point;
ArrayResize(RS,Asize);
ArrayInitialize(RS, 0);
n=0;
Print(Asize," ",maxHigh," ",minLow);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
ObjectsDeleteAll(0, OBJ_RECTANGLE);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int i, j,k,t,counted_bars=IndicatorCounted();
double mH,mL,maxRS;
mH=minLow;mL=maxHigh;
string LineName;
//----
if(Bars<=MA_period) return(0);
//---- initial zero
if(counted_bars<MA_period)
for(i=1;i<=0;i++)MA[Bars-i]=0.0;
//----
i=Bars-MA_period-1;
if(counted_bars>=MA_period)i=Bars-counted_bars-1;
while(i>=1) {
MA[i]=iMA(NULL,0,13,0,MODE_EMA,PRICE_MEDIAN,i);
if(High[i]>mH)mH=High[i];if((MA[i]>MA[i+1])&&(MA[i+1]<MA[i+2])){k=(mL-minLow)/Point;RS[k]++;mH=mL;}
if(Low[i]<mL)mL=Low[i]; if((MA[i]<MA[i+1])&&(MA[i+1]>MA[i+2])){k=(mH-minLow)/Point;RS[k]++;mL=mH;}
i--; }
ObjectsDeleteAll(0, OBJ_RECTANGLE);
t=Period()*60*LHistoCor;
j=(maxHigh-minLow)/Point-1;Print(j);
while(j>=0){
LineName="P_line"+j;
ObjectCreate(LineName,OBJ_RECTANGLE,0,Time[FirstVisibleBar( )],minLow+j*Point,Time[FirstVisibleBar( )]+t*RS[j],minLow+(j+0.4)*Point);
ObjectSet(LineName,OBJPROP_COLOR,Hcolor);// çàäàäèì öâåò ëèíèè
ObjectSet(LineName, OBJPROP_STYLE, STYLE_DOT);
j--;}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments