Didi_Index
Download scriptThe Didi Index is a technical analysis tool designed to help traders visualize the relationship between different price trends by normalizing them into a single, easy-to-read relative format. Instead of looking at raw price figures, this indicator focuses on the mathematical proportion between short-term, medium-term, and long-term market movements.
Core Logic and Functionality
The script operates by calculating three distinct moving averages based on different time horizons:
- Short-Term (Curta): Tracks rapid, immediate price fluctuations.
- Medium-Term (Media): Tracks the intermediate trend of the market.
- Long-Term (Longa): Tracks the broader, sustained price direction.
How the Data is Processed
The unique logic of this indicator lies in its normalization process. Rather than simply displaying these three averages as independent lines on your chart, the script performs a division calculation to create a relative index:
- Relative Comparison: The values of the Short-Term and Long-Term averages are divided by the value of the Medium-Term average.
- Baseline Alignment: By dividing both the "Short" and "Long" figures by the "Medium" figure, the script sets the Medium-Term trend as a constant baseline (a value of 1).
What This Means for the User
By converting these movements into ratios, the indicator eliminates the "noise" of absolute price levels. This allows you to see how much the short-term price is deviating from the medium-term trend and where the long-term trend sits in relation to it simultaneously.
The result is a visual representation that highlights momentum:
- When the lines move significantly above or below the baseline, it indicates a strengthening of specific trends relative to the rest of the market.
- It provides a clearer picture of "overextended" markets by showing the proportional gap between different timeframes in a single, synchronized view.
//+------------------------------------------------------------------+
//| Didi Index.mq4 |
//| Rudinei Felipetto |
//| http://www.conttinua.com |
//+------------------------------------------------------------------+
#property copyright "Rudinei Felipetto"
#property link "http://www.conttinua.com"
#property version "1.00"
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_plots 3
//--- plot Curta
#property indicator_label1 "Curta"
#property indicator_type1 DRAW_LINE
#property indicator_color1 clrLime
#property indicator_style1 STYLE_SOLID
#property indicator_width1 1
//--- plot Media
#property indicator_label2 "Media"
#property indicator_type2 DRAW_LINE
#property indicator_color2 clrWhite
#property indicator_style2 STYLE_SOLID
#property indicator_width2 1
//--- plot Longa
#property indicator_label3 "Longa"
#property indicator_type3 DRAW_LINE
#property indicator_color3 clrYellow
#property indicator_style3 STYLE_SOLID
#property indicator_width3 1
//--- input parameters
extern int Curta=3;
extern ENUM_APPLIED_PRICE CurtaAppliedPrice = PRICE_CLOSE;
extern ENUM_MA_METHOD CurtaMethod = MODE_SMA;
extern int Media=8;
extern ENUM_APPLIED_PRICE MediaAppliedPrice = PRICE_CLOSE;
extern ENUM_MA_METHOD MediaMethod = MODE_SMA;
extern int Longa=20;
extern ENUM_APPLIED_PRICE LongaAppliedPrice = PRICE_CLOSE;
extern ENUM_MA_METHOD LongaMethod = MODE_SMA;
//--- indicator buffers
double CurtaBuffer[];
double MediaBuffer[];
double LongaBuffer[];
int init()
{
SetIndexBuffer(0, CurtaBuffer, INDICATOR_DATA);
SetIndexBuffer(1, MediaBuffer, INDICATOR_DATA);
SetIndexBuffer(2, LongaBuffer, INDICATOR_DATA);
return(0);
}
int start()
{
if(Bars<=Longa) return(0);
CalculateDidiIndex();
return(0);
}
//+------------------------------------------------------------------+
void CalculateDidiIndex()
{
for(int i = 1; i <= Bars; i++)
{
CurtaBuffer[i] = iMA(_Symbol, 0, Curta, 0, CurtaMethod, CurtaAppliedPrice, i);
MediaBuffer[i] = iMA(_Symbol, 0, Media, 0, MediaMethod, MediaAppliedPrice, i);
LongaBuffer[i] = iMA(_Symbol, 0, Longa, 0, LongaMethod, LongaAppliedPrice, i);
CurtaBuffer[i] /= MediaBuffer[i];
LongaBuffer[i] /= MediaBuffer[i];
MediaBuffer[i] = 1;
}
}
//+------------------------------------------------------------------+
Comments