ma_kino_Price-4MA
Download scriptThis tool is designed to help traders visualize the relationship between current market prices and several different Moving Averages (MAs) simultaneously. Rather than looking at simple lines on a chart, this script calculates the specific "distance" or gap between the price and four distinct moving averages.
How the Logic Works
The core functionality of this script relies on measuring the difference between two primary data points:
- The Reference Price: A baseline price determined by your settings.
- Four Moving Averages: Four separate averages calculated over different time periods (for example, 10, 21, 34, and 55 periods).
Instead of just plotting these lines, the script performs a subtraction for each moving average. It takes the value of the Moving Average and subtracts the Reference Price. This calculation identifies how far away each average is from the current price at any given moment.
Visual Representation
The results of these calculations are displayed in a separate window below your main trading chart:
- Histogram Tracking: The script visualizes the gap for the largest (longest) Moving Average as a histogram. This allows you to see the magnitude of the trend's "stretch."
- Trend Analysis: By observing the height and direction of these values, traders can gauge how far the price has deviated from its historical average.
- Dynamic Scaling: The script includes a "zooming" feature that amplifies these distances, making it easier for the human eye to identify significant trends or overextended moves that might not be as obvious on a standard price chart.
Practical Application for Traders
The primary goal of this logic is to help with trade management and trend identification:
- Trend Strength: When the histogram values are significant, it suggests a strong trend is in place, which may signal that a trade can be held longer.
- Distance Awareness: By seeing all four distances at once, traders can better understand where the price sits in relation to multiple layers of moving averages, helping to identify potential exhaustion points or areas of high momentum.
//+------------------------------------------------------------------+
//| kino_Close-EMA.mq4 |
//| Copyright © April 2008, MetaQuotes Software Corp. |
//| http://kinonen.over-blog.com |
//+------------------------------------------------------------------+
// based on the 4 EMA distance to Close
// histo on the biggest EMA , if histo is great you can keep longer the trade
// kinonen Octobre 2008
#property copyright "Copyright © 2008, MetaQuotes Software Corp."
#property link "http://kinonen.over-blog.com"
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Teal
#property indicator_color2 Red
#property indicator_color3 Yellow
#property indicator_color4 Lime
//+++++++++++++++++++++++++++++
extern int Price=0;
extern string notePrice = "0O,1C 2H3L,4Md 5Tp 6WghC: Md(HL/2)4,Tp(HLC/3)5,Wgh(HLCC/4)6";
extern string MA_Mode = "SMA0 EMA1 SMMA2 LWMA3";
extern int MA1periode=10;
extern int MA1mode=1;
extern int MA1price=0;
extern int MA2periode=21;
extern int MA2mode=1;
extern int MA2price=0;
extern int MA3periode=34;
extern int MA3mode=1;
extern int MA3price=0;
extern int MA4periode=55;
extern int MA4mode=1;
extern int MA4price=0;
extern int zooming=3;
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(3,DRAW_LINE,EMPTY);
SetIndexBuffer(3,ExtMapBuffer4);
SetIndexStyle(1,DRAW_LINE,EMPTY);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexStyle(2,DRAW_LINE,EMPTY);
SetIndexBuffer(2,ExtMapBuffer3);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
double val1,val2,val3,val4,val5,val6,val7,val8,val9;
//++++++++++++++++++++++++++++++
int limit;
int counted_bars = IndicatorCounted();
//---- check for possible errors
if(counted_bars < 0)
return(-1);
//---- last counted bar will be recounted
if(counted_bars > 0)
counted_bars--;
limit = Bars - counted_bars;
//==========================================
for(int i = limit; i >= 0; i--)
{
// iMA( string symbol, int timeframe, int period, int ma_shift, int ma_method, int applied_price, int shift)
double price=iMA(NULL,0,1,0,MODE_SMA,Price,i);
val1=iMA(NULL,0,MA1periode,0,MA1mode,MA1price,i);
val2=iMA(NULL,0,MA2periode,0,MA2mode,MA2price,i);
val3=iMA(NULL,0,MA3periode,0,MA3mode,MA3price,i);
val4=iMA(NULL,0,MA4periode,0,MA4mode,MA4price,i);
// val5=Close[i];
val6=val1-price;
val7=val2-price;
val8=val3-price;
val9=val4-price;
// collecte des resultats / collecting results
ExtMapBuffer4[i]=-zooming*val6;
ExtMapBuffer2[i]=-zooming*val7;
ExtMapBuffer3[i]=-zooming*val8;
ExtMapBuffer1[i]=-zooming*val9;
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments