This tool is designed to analyze market trends and provide visual entry signals for traders using the MetaTrader platform. It works by processing price movements to identify specific momentum shifts, translating complex mathematical data into simple "Buy" and "Sell" markers on your chart.
How the Logic Works
The script functions through a three-layered calculation process:
1. Momentum Tracking (The Foundation) First, the tool calculates two different types of moving averages. One moves quickly to follow recent price changes, while the other moves more slowly to represent the broader trend. By subtracting the slow average from the fast one, the script determines the "momentum" of the market—essentially measuring how much faster or slower the price is moving in a specific direction.
2. Signal Smoothing (The Filter) To ensure that the momentum data isn't too erratic or "noisy," the script applies a secondary calculation to smooth out those fluctuations. This creates a stabilized baseline, helping the tool distinguish between minor market jitters and significant trend changes.
3. Histogram Analysis (The Trigger) The script then compares the current momentum against this smoothed baseline to create a "Histogram" value. This value represents the strength of the current price movement relative to its recent history.
Entry Signal Rules
The core logic for placing signals on your chart is based on a specific "threshold" (defined by the user's settings). The tool looks for a clear crossover of this threshold:
- Buy Signal: When the histogram value moves from below the threshold to above it, the script identifies an upward momentum shift and places a "Buy" arrow at the high point of that price candle.
- Sell Signal: When the histogram value moves from above the threshold to below it, the script identifies a downward momentum shift and places a "Sell" arrow at the low point of that price candle.
In short, this script automates the heavy lifting of comparing multiple moving averages and historical data points, alerting you only when the market momentum reaches a specific strength level required for a potential trade.
//+------------------------------------------------------------------+
//| maloma`s`enter.mq4 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, maloma"
#property indicator_chart_window
#property indicator_buffers 5
#property indicator_color4 Blue
#property indicator_color5 Red
//------- Ãëîáàëüíûå ïåðåìåííûå --------------------------------------
//------- Âíåøíèå ïàðàìåòðû èíäèêàòîðà -------------------------------
extern int Porog=20;
extern int FastEMA=12;
extern int SlowEMA=26;
extern int SignalSMA=9;
//------- Ïàðàìåòðû èíäèêàòîðà -------------------------------
double MacdBuffer[];
double SignalBuffer[];
double HistoBuffer[];
//------- Áóôåðû èíäèêàòîðà ------------------------------------------
double bufbuy[], bufsell[];
void init() {
SetIndexStyle(0,DRAW_NONE);
SetIndexStyle(1,DRAW_NONE);
SetIndexStyle(2,DRAW_NONE);
SetIndexStyle(3,DRAW_ARROW);
SetIndexStyle(4,DRAW_ARROW);
IndicatorDigits(Digits+1);
SetIndexBuffer(0,MacdBuffer);
SetIndexBuffer(1,SignalBuffer);
SetIndexBuffer(2,HistoBuffer);
SetIndexBuffer(3,bufbuy);
SetIndexBuffer(4,bufsell);
IndicatorShortName("Maloma`s`enter");
SetIndexLabel(0,"");
SetIndexLabel(1,"");
SetIndexLabel(2,"");
SetIndexLabel(3,"Buy");
SetIndexLabel(4,"Sell");
SetIndexArrow (3,164);
SetIndexArrow (4,164);
SetIndexEmptyValue(0,0);
SetIndexEmptyValue(1,0);
SetIndexEmptyValue(2,0);
SetIndexEmptyValue(3,0);
SetIndexEmptyValue(4,0);
}
void deinit() {
Comment("");
}
void start() {
int limit;
int counted_bars=IndicatorCounted();
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for(int i=0; i<limit; i++)
MacdBuffer[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
for(i=0; i<limit; i++)
SignalBuffer[i]=iMAOnArray(MacdBuffer,Bars,SignalSMA,0,MODE_SMA,i);
for(i=0; i<limit; i++)
HistoBuffer[i]=(MacdBuffer[i]-SignalBuffer[i])*10/Point;
for(i=0; i<limit; i++)
{
if (HistoBuffer[i+1]<Porog && HistoBuffer[i]>=Porog && bufbuy[i]==0) bufbuy[i]=High[i];
if (HistoBuffer[i+1]>-Porog && HistoBuffer[i]<=-Porog && bufsell[i]==0) bufsell[i]=Low[i];
}
}
//+------------------------------------------------------------------+
Comments