This tool is designed to provide traders with a visual representation of where the current market price sits relative to a specific range of price action. Rather than looking at raw price movements, it simplifies market dynamics into a percentage-based scale, making it easier to identify whether the market is currently "expensive," "cheap," or positioned in the middle of its recent behavior.
How the Logic Works
The script operates by analyzing historical price data over a set period (customizable by the user) to establish a dynamic boundary. Here is the step-by-step logic it follows:
1. Defining the Boundary The indicator looks at the lowest prices reached during a specific timeframe. It then calculates two distinct boundaries based on these lows: an upper limit and a lower limit. This creates a "zone" or a corridor that represents the recent price floor and ceiling.
2. Calculating the Range (The "Height") The script determines the total distance between this upper and lower boundary. Think of this as the total height of a building; it tells the indicator how much room there is for price movement within the current trend.
3. Determining Relative Position For every new price point, the tool calculates how far the current closing price has risen from the bottom boundary. It then compares this specific distance against the "total height" calculated in the previous step.
4. Converting to a Percentage Finally, the tool converts that position into a percentage.
- If the price is at the very bottom of the range, the indicator will show a low percentage.
- If the price moves toward the top of the range, the percentage increases.
- The resulting value is plotted as a smooth line on a separate window, providing a clear visual cue of the price's momentum and relative "altitude" within its current market cycle.
Purpose for the Trader
By transforming complex price fluctuations into a steady percentage line, this logic helps traders visualize the "room to run." It allows you to see at a glance whether the market is stretched toward its upper limits or retreating toward its lower boundaries, regardless of the actual currency or asset being traded.
//+------------------------------------------------------------------+
//| Yaanna.mq4 |
//| Copyright © 2009, Victor Chebotariov |
//| http://www.chebotariov.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, Victor Chebotariov"
#property link "http://www.chebotariov.com"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Green
//---- input parameters
extern int BBPeriod=200;
//---- buffers
double ExtMapBuffer1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorShortName("Yaanna ("+BBPeriod+")");
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Yaanna |
//+------------------------------------------------------------------+
int start()
{
int i,counted_bars=IndicatorCounted();
//----
i=Bars-counted_bars-1;
while(i>=0)
{
double highbb = iBands(NULL,0,BBPeriod,2,0,PRICE_LOW,MODE_UPPER,i);
double lowbb = iBands(NULL,0,BBPeriod,2,0,PRICE_LOW,MODE_LOWER,i);
double close = Close[i];
double ma = iMA(NULL,0,BBPeriod,0,0,0,i);
double visota = (highbb-lowbb); // âûñîòà == 100%
if(visota==0){visota=1;}
double pclose = (close-lowbb); // öåíà
double enter = pclose/visota*100;
ExtMapBuffer1[i]=enter;
i--;
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments