This MT4 indicator is designed to help traders identify market momentum and strength by analyzing data from multiple timeframes simultaneously. Instead of just looking at the current price action, it "borrows" calculations from a higher timeframe to provide a broader perspective on whether the market is leaning bullish, bearish, or staying neutral.
Core Logic and Functionality
Multi-Timeframe Analysis The script's primary role is to bridge the gap between different time horizons. For example, while you might be looking at a 15-minute chart, the indicator can be configured to pull strength data from a Daily or Hourly chart. This allows traders to see "the big picture" without switching back and forth between screens.
The Strength Calculation (The Engine) The indicator utilizes a specialized calculation method (Absolute Strength) which can be toggled between three distinct types of technical analysis:
- RSI Method: Focuses on overbought and oversold conditions.
- Stochastic Method: Looks at the position of prices relative to a recent range.
- ADX Method: Measures the actual strength of a trend regardless of its direction.
Visual Signals The indicator translates complex mathematical data into three distinct visual markers on your chart:
- Bullish Strength (Light Blue): Appears when the upward momentum is calculated to be stronger than the downward momentum.
- Bearish Strength (Tomato): Appears when the downward momentum is calculated to be stronger than the upward momentum.
- No Trade/Neutral Zone (Yellow): This serves as a filter, appearing when the conditions for a clear trend are not met, suggesting that the market might be range-bound or lacks sufficient conviction in either direction.
Smart Smoothing and Customization To ensure the signals aren't "noisy" or overly sensitive to minor price flickers, the script includes several refinement layers:
- Price Modes: You can choose which part of the candle (Open, High, Low, Close, etc.) the indicator uses as its primary data point.
- Moving Average Smoothing: It offers various types of smoothing (Simple, Exponential, Smoothed, or Linear Weighted) to help filter out market "jitter."
- Buffer Refresh: The script includes a synchronization logic that ensures that when you are looking at a lower timeframe, the higher timeframe data remains consistent and visually aligned across the bars.
Summary for the User
In simple terms, this tool acts as a "trend compass." It looks at a larger timeframe you specify, calculates whether the market is pushing up or down using your preferred mathematical method, and then places symbols on your current chart to tell you: "The big picture is moving this way," or "The market is currently too weak to trade."
//+------------------------------------------------------------------+
//| MTF_ AbsoluteStrength_v1.1 Sidebar mq4 |
//| forex-tsd.com Copyright © 2006, MetaQuotes Software Corp. |
//| Copyright © 2006, TrendLaboratory Ltd. |
//| http://finance.groups.yahoo.com/group/TrendLaboratory |
//| E-mail: igorad2004@list.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, TrendLaboratory Ltd."
#property link "http://finance.groups.yahoo.com/group/TrendLaboratory"
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 LightBlue
#property indicator_color2 Tomato
#property indicator_color3 Yellow
#property indicator_maximum 77
#property indicator_minimum 1
//---- input parameters
extern int TimeFrame =0;
extern int ASbarLevel = 4; // bar location in sep.windpw(from 1(min) to 77(max))
extern int Mode = 0; // 0-RSI method; 1-Stoch method; 2-ADX method
extern string note = "Level:1-77;Mode:RSI1;Stoch2;ADX3";
extern int Length = 10; // Period
extern int Smooth = 5; // Period of smoothing
extern int Signal = 5; // Period of Signal Line
extern int Price = 0; // Price mode : 0-Close,1-Open,2-High,3-Low,4-Median,5-Typical,6-Weighted
extern int ModeMA = 3; // Mode of Moving Average
extern string note1 = "Price(OCHLMTF)ModeMa(SMA0,EMA1,SmmMA2,LWMA3";
/*************************************************************************
PERIOD_M1 1
PERIOD_M5 5
PERIOD_M15 15
PERIOD_M30 30
PERIOD_H1 60
PERIOD_H4 240
PERIOD_D1 1440
PERIOD_W1 10080
PERIOD_MN1 43200
You must use the numeric value of the timeframe that you want to use
when you set the TimeFrame' value with the indicator inputs.
---------------------------------------
MODE_SMA 0 Simple moving average,
MODE_EMA 1 Exponential moving average,
MODE_SMMA 2 Smoothed moving average,
MODE_LWMA 3 Linear weighted moving average.
You must use the numeric value of the MA Method that you want to use
when you set the 'ma_method' value with the indicator inputs.
**********************************************************/
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double SmthBulls[];
double SmthBears[];
double SigBulls[];
double SigBears[];
double SigNoTrade[];
string TimeFrameStr;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_ARROW);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_ARROW);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexStyle(2,DRAW_ARROW);
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexArrow(0,59); // 111,249,250(hollowSquare);
SetIndexArrow(1,59);// 176,177,164,165 (target) 161,162 circle
SetIndexArrow(2,159); // 251(x), 158,159(dot), 115,119(romb),
SetIndexLabel(0,"AS_Bulls("+TimeFrame+")");
SetIndexLabel(1,"AS_Bears("+TimeFrame+")");
SetIndexLabel(2,"AS_NoTrade("+TimeFrame+")");
switch(TimeFrame)
{
case 1 : TimeFrameStr="Period_M1"; break;
case 5 : TimeFrameStr="Period_M5"; break;
case 15 : TimeFrameStr="Period_M15"; break;
case 30 : TimeFrameStr="Period_M30"; break;
case 60 : TimeFrameStr="Period_H1"; break;
case 240 : TimeFrameStr="Period_H4"; break;
case 1440 : TimeFrameStr="Period_D1"; break;
case 10080 : TimeFrameStr="Period_W1"; break;
case 43200 : TimeFrameStr="Period_MN1"; break;
default : TimeFrameStr="Current TimeFrame"; TimeFrame=0;
}
IndicatorShortName("MTF_ASsb("+TimeFrameStr+")["+Length+"]");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
datetime TimeArray[];
int i,limit,y=0,counted_bars=IndicatorCounted();
// Plot defined time frame on to current time frame
ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame);
limit=Bars-counted_bars+TimeFrame/Period();
for(i=0,y=0;i<limit;i++)
{
if (Time[i]<TimeArray[y]) y++;
ExtMapBuffer1[i]=EMPTY_VALUE;
ExtMapBuffer2[i]=EMPTY_VALUE;
ExtMapBuffer3[i]=EMPTY_VALUE;
double SmthBulls =iCustom(NULL,TimeFrame,"AbsoluteStrength_v1.1", Mode, Length,Smooth, Signal, Price, ModeMA,0,0,0,y);
double SmthBears =iCustom(NULL,TimeFrame,"AbsoluteStrength_v1.1", Mode, Length,Smooth, Signal, Price, ModeMA,0,0,1,y);
double SigBulls =iCustom(NULL,TimeFrame,"AbsoluteStrength_v1.1", Mode, Length,Smooth, Signal, Price, ModeMA,0,0,2,y);
double SigBears =iCustom(NULL,TimeFrame,"AbsoluteStrength_v1.1", Mode, Length,Smooth, Signal, Price, ModeMA,0,0,3,y);
if(SmthBulls > SmthBears )ExtMapBuffer1[i] = ASbarLevel;//
if(SmthBulls <= SmthBears )ExtMapBuffer2[i] = ASbarLevel;//
if(SmthBulls < SigBulls && SmthBears < SigBears)ExtMapBuffer3[i] = ASbarLevel;//
}
//---- Refresh buffers ++++++++++++++++++++ upgrade by Raff
int TimeFrame; if (TimeFrame>Period()) {
int PerINT=TimeFrame/Period()+1;
datetime TimeArr[]; ArrayResize(TimeArr,PerINT);
ArrayCopySeries(TimeArr,MODE_TIME,Symbol(),Period());
for(i=0;i<PerINT+1;i++) {if (TimeArr[i]>=TimeArray[0]) {
/********************************************************
Refresh buffers: buffer[i] = buffer[0];
********************************************************/
ExtMapBuffer1[i] = ExtMapBuffer1[0];
ExtMapBuffer2[i] = ExtMapBuffer2[0];
ExtMapBuffer3[i] = ExtMapBuffer3[0];
//--
} } }
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Raff
return(0);
}
//+-------------------------------------------------------+
Comments