[i]2MA_v1
Download scriptThis tool is designed to provide visual trend reversal signals on your trading charts by identifying specific momentum shifts between two different moving averages. Instead of cluttering the screen with constant data, it simplifies market movement into clear visual cues (arrows) when certain price conditions are met.
Core Logic and Mechanics
The indicator operates by analyzing the relationship between two Exponential Moving Averages (EMA) on a higher timeframe (specifically the 4-Hour chart). By looking at these longer-term averages, the tool aims to filter out "noise" from smaller price fluctuations to identify more significant shifts in market direction.
How the signals are generated:
-
The Bullish Signal (Upward Momentum): The script constantly monitors the distance between a fast-moving average (15 periods) and a slower-moving average (100 periods). A signal is triggered when the fast line "crosses over" the slow line from below to above. Visually, this appears as an upward arrow placed just above the price candle, suggesting that short-term momentum is turning positive relative to the long-term trend.
-
The Bearish Signal (Downward Momentum): Conversely, a downward signal is triggered when the fast-moving average "crosses under" the slow-moving average from above to below. This produces a downward arrow placed just below the price candle, indicating that short-term momentum is weakening and potentially shifting toward a downtrend.
Key Features for the User
- High Timeframe Awareness: A unique aspect of this logic is that while you may be viewing your current chart at a 5-minute interval, the indicator "looks ahead" to the 4-Hour timeframe to determine its signals. This helps ensure that the arrows provided are based on significant structural moves rather than momentary price spikes.
- Visual Clarity: The tool uses specific arrow symbols (codes 233 and 234) to mark the exact moment these crossovers occur. This allows for quick scanning of historical data to see where trend changes happened in the past or identifying new entries as they appear in real-time.
- Automatic Positioning: The script automatically calculates the correct placement for the arrows based on the current price, ensuring they are positioned clearly above or below the candles without overlapping the actual price action.
//+------------------------------------------------------------------+
//| 5 Min RSI 12-period qual INDICATOR |
//+------------------------------------------------------------------+
#property copyright "Ron T"
#property link "http://www.lightpatch.com"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 White
#property indicator_color2 Red
//---- buffers
double Buffer1[];
double Buffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//|------------------------------------------------------------------|
int init()
{
// 233 up arrow
// 234 down arrow
// 159 big dot
// 158 little dot
// 168 open square
// 120 box with X
SetIndexStyle(0,DRAW_ARROW);
SetIndexBuffer(0, Buffer1);
SetIndexArrow(0,233);
SetIndexStyle(1,DRAW_ARROW);
SetIndexBuffer(1, Buffer2);
SetIndexArrow(1,234);
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
int i;
for( i=0; i<Bars; i++ ) Buffer1[i]=0;
for( i=0; i<Bars; i++ ) Buffer2[i]=0;
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int pos=Bars-100; // leave room for moving average periods
int ctr=0;
double emaM, emaS;
double PemaM, PemaS;
double p=Point();
while(pos>=1)
{
emaM= iMA(Symbol(),PERIOD_H4, 15,0,PRICE_OPEN,MODE_EMA,pos);
emaS= iMA(Symbol(),PERIOD_H4,100,0,PRICE_OPEN,MODE_EMA,pos);
PemaM=iMA(Symbol(),PERIOD_H4, 15,0,PRICE_OPEN,MODE_EMA,pos+1);
PemaS=iMA(Symbol(),PERIOD_H4,100,0,PRICE_OPEN,MODE_EMA,pos+1);
if (PemaM<emaS && emaM>emaS) {Buffer1[pos]=High[pos]+(50*p);}
if (PemaM>emaS && emaM<emaS) {Buffer2[pos]=Low[pos]-(50*p);}
pos--;
}
return(0);
}
//+------------------------------------------------------------------+
Comments