Kairi
Download scriptThe Kairi indicator is designed to provide traders with a visual representation of the percentage deviation between the current market price and its moving average. By isolating this relationship into a separate window on your trading platform, it allows you to gauge "overextended" market conditions more clearly than by looking at a standard price chart alone.
How the Logic Works
The indicator functions by performing three primary steps in real-time:
1. Establishing a Baseline (The Moving Average) The tool first calculates a Simple Moving Average (SMA) based on a user-defined period of time (such as the last 10 candles). This moving average acts as the "equilibrium" or the baseline of the market's recent trend.
2. Measuring the Distance Instead of just showing you where the price is, the script calculates the mathematical distance between the current closing price and that moving average. It looks at how far the market has pulled away from its established average.
3. Converting to Percentage Deviation This is the core logic of the Kairi indicator. Rather than displaying raw price points, the tool converts that distance into a percentage. The formula identifies how much higher or lower the price is compared to the average relative to the average's value itself.
How to Interpret the Results
- Positive Values: When the line on your indicator window moves above zero, it indicates that the current market price is trading at a premium (higher) than its moving average.
- Negative Values: When the line moves below zero, it shows the market price is trading at a discount (lower) than its moving average.
- Volatility Insights: By observing how quickly the percentage fluctuates, traders can identify periods of extreme volatility or potential "exhaustion" points where the price may be stretched too far from its mean, potentially signaling a future correction or trend reversal.
Customization Options
The tool provides three primary settings to tailor the logic to your specific trading style:
- MA_Period: Adjusts how many bars are used to calculate the average (longer periods create smoother lines; shorter periods react faster).
- Shift_Bars: Allows you to offset the calculation if you wish to compare current prices against historical averages.
- Bars_Count: Determines the amount of historical data displayed on the chart at one time.
//+------------------------------------------------------------------+
//| Kairi.mq4 |
//| Copyright © 2006 Scorpion@fxfisherman.com |
//+------------------------------------------------------------------+
#property copyright "FxFisherman.com"
#property link "http://www.fxfisherman.com"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Aqua
extern int MA_Period=10;
extern int Shift_Bars=0;
extern int Bars_Count= 1000;
//---- buffers
double v1[];
double val1;
int init()
{
IndicatorBuffers(1);
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
SetIndexDrawBegin(0,-1);
SetIndexBuffer(0, v1);
SetIndexLabel(0,"Kairi");
watermark();
return(0);
}
int start()
{
int i;
int shift;
double sma;
int counted_bars = IndicatorCounted();
if (counted_bars > 0) counted_bars--;
if (Bars_Count > 0 && Bars_Count <= Bars)
{
i = Bars_Count - counted_bars;
}else{
i = Bars - counted_bars;
}
while(i>=0)
{
shift = i + Shift_Bars;
sma = iMA(NULL, 0, MA_Period, Shift_Bars, MODE_SMA, PRICE_CLOSE, i);
if (sma>0)
{
v1[i] = ((Close[shift]-sma)/sma) * 100;
}
i--;
}
return(0);
}
//+------------------------------------------------------------------+
void watermark()
{
ObjectCreate("fxfisherman", OBJ_LABEL, 0, 0, 0);
ObjectSetText("fxfisherman", "fxfisherman.com", 11, "Lucida Handwriting", RoyalBlue);
ObjectSet("fxfisherman", OBJPROP_CORNER, 2);
ObjectSet("fxfisherman", OBJPROP_XDISTANCE, 5);
ObjectSet("fxfisherman", OBJPROP_YDISTANCE, 10);
return(0);
}
Comments