This script is a technical analysis tool designed for the MetaTrader platform to help traders visualize price trends and identify potential entry points. It functions by plotting several moving averages simultaneously on a chart, providing a visual representation of the market's momentum.
Core Visual Components
The tool displays multiple Exponential Moving Averages (EMAs). These are smooth lines that follow the price action; they give more weight to recent data, making them highly responsive to current market changes. By observing how these lines move relative to one another, traders can gauge the overall direction of the market.
Trend Recognition Logic
The script offers two primary operational modes based on the user's preference:
- 4-Line Mode: This mode calculates and displays four different EMAs. It focuses on the relationship between the fastest moving average and the slowest one to identify significant trend shifts.
- 3-Line Mode: This mode simplifies the visual by focusing on three moving averages, allowing for a more condensed view of market dynamics.
Automated Signal Generation
Beyond just drawing lines, the script includes logic to automatically identify "crosses"—moments where a fast-moving average moves from below to above (or vice versa) a slower-moving average. These crossings are interpreted as potential trend reversals:
- Buy Signals: When the fast EMA crosses upward over the slow EMA, the script can place a blue arrow on the chart to indicate a potential "buy" or upward momentum.
- Sell Signals: When the fast EMA crosses downward under the slow EMA, the script places a red arrow to signal potential "sell" pressure or downward momentum.
Customization and Alerts
The tool is designed with several user-friendly features to adapt to different trading styles:
- Visual Offsets: You can adjust how far above or below the price the signal arrows appear so they do not clutter the candles.
- On/Off Toggles: Users can choose whether to display these visual arrows on the chart or keep them hidden.
- Smart Alerts: The script can be configured to send real-time notifications (alerts) when a crossover occurs. To prevent "noise," these alerts are programmed to trigger only during periods of low trading volume, highlighting signals that may have more significance.
In summary, this tool simplifies complex price action into a clear visual system of moving lines and automated icons, helping traders identify where the trend is shifting in real-time.
//+----------------------------------------------------------+
//| EMA4hon.mq4 |
//| Makimoto |
//| |
//+----------------------------------------------------------+
#property copyright " Makimoto"
#property link ""
//++++++++++++++++++++++++++++++++++++++++++++++++++
#property indicator_chart_window
#property indicator_buffers 6
#property indicator_color1 White //EMA-1
#property indicator_color2 Turquoise //EMA-2
#property indicator_color3 Yellow //EMA-3
#property indicator_color4 Red //EMA-4
#property indicator_color5 DodgerBlue //
#property indicator_color6 Red //
//üíÌÝè
#property indicator_style11 STYLE_SOLID
#property indicator_style12 STYLE_SOLID
#property indicator_style13 STYLE_SOLID
#property indicator_style14 STYLE_SOLID
//üÌA¾³
#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 2
#property indicator_width4 2
#property indicator_width5 2
#property indicator_width6 2
//++++++++++++++++++++++++++++++++++++++++++++++++++
//wWobt@ÌÝè
double BufEMA_1[]; //EMA_1
double BufEMA_2[]; //EMA_2
double BufEMA_3[]; //EMA_3
double BufEMA_4[]; //EMA_4
double Bufbuyarrow[] ; //¢îó233
double Bufsellarrow[] ; //èîó234
//++++++++++++++++++++++++++++++++++++++++++++++++++
//p[^[ÌÝè
extern int MaMetod = 1; //MODE_EMA 1
extern int EMA_1 = 5;
extern int EMA_2 = 8;
extern int EMA_3 = 13;
extern int EMA_4 = 21;
//+(SignalSlide * Point);
extern int ARROW_onoff = 0 ;
extern int SignalSlide = 10;
extern int Alert_onoff = 0 ;
extern int honsuu = 4 ;
//++++++++++++++++++++++++++++++++++++++++++++++++++
int init()
{
SetIndexBuffer(0,BufEMA_1);
SetIndexBuffer(1,BufEMA_2);
SetIndexBuffer(2,BufEMA_3);
SetIndexBuffer(3,BufEMA_4);
SetIndexBuffer(4,Bufbuyarrow);
SetIndexBuffer(5,Bufsellarrow);
SetIndexStyle(0,DRAW_LINE, STYLE_SOLID, 2, White);
SetIndexStyle(1,DRAW_LINE, STYLE_SOLID, 2, Turquoise);
SetIndexStyle(2,DRAW_LINE, STYLE_SOLID, 2, Yellow);
SetIndexStyle(3,DRAW_LINE, STYLE_SOLID, 2, Red);
SetIndexStyle(4, DRAW_ARROW, STYLE_SOLID, 2, DodgerBlue);
SetIndexArrow(4,233);
SetIndexStyle(5, DRAW_ARROW, STYLE_SOLID, 2, Red);
SetIndexArrow(5,234);
//+-------------------------------------------
SetIndexDrawBegin(0, 500 );
SetIndexDrawBegin(1, 500 );
SetIndexDrawBegin(2, 500 );
SetIndexDrawBegin(3, 500 );
SetIndexDrawBegin(4, 500 );
SetIndexDrawBegin(5, 500 );
return(0);
}
//++++++++++++++++++++++++++++++++++++++++++++++++++
int start()
{
int counted_bar = IndicatorCounted();
int limit = Bars-counted_bar;
for(int i=limit-1; i>=0; i--)
{
//+------------------+
if( honsuu == 4 )
{
//EMA4hon
//EMA_1
BufEMA_1[i] = iMA(NULL,0,EMA_1, 0,MaMetod,PRICE_CLOSE,i);
//EMA_2
BufEMA_2[i] = iMA(NULL,0,EMA_2, 0,MaMetod,PRICE_CLOSE,i);
//EMA_3
BufEMA_3[i] = iMA(NULL,0,EMA_3, 0,MaMetod,PRICE_CLOSE,i);
//EMA_4
BufEMA_4[i] = iMA(NULL,0,EMA_4, 0,MaMetod,PRICE_CLOSE,i);
//+--------------------------------------------------------+
Bufbuyarrow[i] = EMPTY_VALUE;
if( (BufEMA_1[i+2] < BufEMA_4[i+2]) &&
(BufEMA_1[i+1] > BufEMA_4[i+1]) )
{// if001
if(ARROW_onoff == 1)
Bufbuyarrow[i] = BufEMA_4[i] - (SignalSlide * Point) ;
if((Alert_onoff == 1) && ( Volume[i] < 2 ) )
{
Alert(Symbol(),"EMA_4honBuy ", Symbol(), " at ", Ask);
}
}// if001END
//+-------------------------------------------+
Bufsellarrow[i] = EMPTY_VALUE;
if( (BufEMA_1[i+2] > BufEMA_4[i+2]) &&
(BufEMA_1[i+1] < BufEMA_4[i+1]) )
{ // if003
if(ARROW_onoff == 1)
Bufsellarrow[i] = BufEMA_4[i] + (SignalSlide * Point) ;
if((Alert_onoff == 1) && ( Volume[i] < 2 ) )
{
Alert(Symbol(),"EMA_4honSell ", Symbol(), " at ", Bid);
}
} // if003END
}//if( honsuu == 4 )END
//+------------------+
//+------------------+
if( honsuu == 3 )
{
//EMA3hon
//EMA_1
BufEMA_1[i] = iMA(NULL,0,EMA_1, 0,MaMetod,PRICE_CLOSE,i);
//EMA_2
BufEMA_2[i] = iMA(NULL,0,EMA_2, 0,MaMetod,PRICE_CLOSE,i);
//EMA_3
BufEMA_3[i] = iMA(NULL,0,EMA_3, 0,MaMetod,PRICE_CLOSE,i);
//EMA_4
//BufEMA_4[i] = iMA(NULL,0,EMA_4, 0,MaMetod,PRICE_CLOSE,i);
//+--------------------------------------------------------+
Bufbuyarrow[i] = EMPTY_VALUE;
if( (BufEMA_1[i+2] < BufEMA_3[i+2]) &&
(BufEMA_1[i+1] > BufEMA_3[i+1]) )
{// if001
if(ARROW_onoff == 1)
Bufbuyarrow[i] = BufEMA_3[i] - (SignalSlide * Point) ;
if((Alert_onoff == 1) && ( Volume[i] < 2 ) )
{
Alert(Symbol(),"EMA_3honBuy ", Symbol(), " at ", Ask);
}
}// if001END
//+-------------------------------------------+
Bufsellarrow[i] = EMPTY_VALUE;
if( (BufEMA_1[i+2] > BufEMA_3[i+2]) &&
(BufEMA_1[i+1] < BufEMA_3[i+1]) )
{ // if003
if(ARROW_onoff == 1)
Bufsellarrow[i] = BufEMA_3[i] + (SignalSlide * Point) ;
if((Alert_onoff == 1) && ( Volume[i] < 2 ) )
{
Alert(Symbol(),"EMA_3honSell ", Symbol(), " at ", Bid);
}
} // if003END
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+-------------------------------------------+
} // for(int i=limit-1; i>=0; i--)END
//+-------------------------------------------+
//+-------------------------------------------+
return(0);
} //int start()END
//+------------------------------------------------------------------+
//++++++++++++++++++++++++++++++++++++++++++++++++++
//++++++++++++++++++++++++++++++++++++++++++++++++++
Comments