MTF_AbsoluteStrength_sBar3
Download scriptThe MTF Absolute Strength Sidebar is a sophisticated technical analysis tool designed to help traders identify market trends and sentiment by analyzing data from multiple timeframes simultaneously. Rather than just looking at the current price action, this script "looks ahead" into larger timeframes to provide a clearer picture of the prevailing market direction.
Core Functionality
The primary purpose of this tool is to categorize market behavior into distinct types of movements. It evaluates various technical signals (based on user-selected methods like RSI, Stochastic, or ADX) and translates them into visual markers on your chart.
By processing these complex calculations in the background, the script identifies six specific market states:
- Strong Uptrend: Indicates heavy bullish momentum where buying pressure significantly outweighs selling pressure.
- Weak Uptrend: Signals that the market is moving upward, but with less conviction or higher competition from sellers.
- Strong Downtrend: Highlights dominant bearish sentiment where selling pressure is overwhelming.
- Weak Downtrend: Indicates a downward move that is losing steam or facing resistance from buyers.
- No Direction (Neutral): Identifies periods of consolidation or "sideways" trading where there is no clear bias in either direction.
- Volatile: Flags specific moments where the buying and selling pressures are perfectly balanced, often preceding a significant breakout or period of high uncertainty.
Multi-Timeframe Intelligence
One of the script's most powerful features is its Multi-Timeframe (MTF) capability. Most indicators only show what is happening "right now" on your current chart. This script allows you to overlay information from higher timeframes (e.g., viewing Weekly or Daily trends while trading on a 15-minute chart).
It achieves this by:
- Sampling data from a higher timeframe defined by the user.
- Aligning that high-level data with your current chart's timeline.
- Filling in "buffer" zones so that the trend information remains consistent and visible across all smaller candles between those larger timeframe marks.
Customization and Flexibility
The logic is highly adaptable to different trading styles through several adjustable parameters:
- Calculation Methods: Traders can choose between three different mathematical models (RSI, Stochastic, or ADX) to determine strength.
- Smoothing & Periodicity: Users can adjust how "fast" or "slow" the indicator reacts to price changes by modifying the smoothing periods and lengths.
- Price Type: The logic can be set to calculate strength based on different price points, such as the Close, Open, High, Low, Median, Typical, or Weighted prices.
Summary for the Trader
In essence, this tool acts as a "trend filter." Instead of guessing which way the market is going based solely on the candles in front of you, it uses heavy-duty mathematical modeling to tell you the underlying strength of the current trend across multiple horizons of time. It simplifies complex data into clear visual signals, helping you stay aligned with the "big picture" while executing smaller trades.
//+------------------------------------------------------------------+
//| 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 6
#property indicator_color1 Blue
#property indicator_color2 DodgerBlue
#property indicator_color3 Tomato
#property indicator_color4 Red
#property indicator_color5 Yellow
#property indicator_color6 Gold
#property indicator_maximum 10
#property indicator_minimum 1
//---- input parameters
extern int TimeFrame =60;
extern int ASbarLevel = 5; // 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 TrendUpStrong[];
double TrendUp[];
double TrendDown[];
double TrendDownStrong[];
double NoDirection[];
double Volatile[];
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,TrendUpStrong);
SetIndexArrow(0,110);
SetIndexStyle(1,DRAW_ARROW);
SetIndexBuffer(1,TrendUp);
SetIndexArrow(1,110);
SetIndexStyle(2,DRAW_ARROW);
SetIndexBuffer(2,TrendDown);
SetIndexArrow(2,110);
SetIndexStyle(3,DRAW_ARROW);
SetIndexBuffer(3,TrendDownStrong);
SetIndexArrow(3,110);
SetIndexStyle(4,DRAW_ARROW);
SetIndexBuffer(4,NoDirection);
SetIndexArrow(4,110);
SetIndexStyle(5,DRAW_ARROW);
SetIndexBuffer(5,Volatile);
SetIndexArrow(5,110);
//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++;
TrendUpStrong[i]=EMPTY_VALUE;
TrendUp[i]=EMPTY_VALUE;
TrendDown[i]=EMPTY_VALUE;
TrendDownStrong[i]=EMPTY_VALUE;
NoDirection[i]=EMPTY_VALUE;
Volatile[i]=EMPTY_VALUE;
double SmthBulls =iCustom(NULL,0,"AbsoluteStrength_v1.1", Mode, Length,Smooth, Signal, Price, ModeMA,0,0,0,y);
double SmthBears =iCustom(NULL,0,"AbsoluteStrength_v1.1", Mode, Length,Smooth, Signal, Price, ModeMA,0,0,1,y);
double SigBulls =iCustom(NULL,0,"AbsoluteStrength_v1.1", Mode, Length,Smooth, Signal, Price, ModeMA,0,0,2,y);
double SigBears =iCustom(NULL,0,"AbsoluteStrength_v1.1", Mode, Length,Smooth, Signal, Price, ModeMA,0,0,3,y);
if(SmthBulls>SigBulls && SmthBears<=SigBears) TrendUpStrong[i]=ASbarLevel;
if(SmthBulls>SigBulls && SmthBears>SigBears && ((SmthBulls-SigBulls)>(SmthBears-SigBears))) TrendUp[i]=ASbarLevel;
if(SmthBulls>SigBulls && SmthBears>SigBears && ((SmthBulls-SigBulls)<(SmthBears-SigBears))) TrendDown[i]=ASbarLevel;
if(SmthBulls<=SigBulls && SmthBears>SigBears) TrendDownStrong[i]=ASbarLevel;
if(SmthBulls<=SigBulls && SmthBears<=SigBears) NoDirection[i]=ASbarLevel;
if(SmthBulls>SigBulls && SmthBears>SigBears && ((SmthBulls-SigBulls)==(SmthBears-SigBears))) Volatile[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];
********************************************************/
TrendUpStrong[i] = TrendUpStrong[0];
TrendUp[i] = TrendUp[0];
TrendDown[i] = TrendDown[0];
TrendDownStrong[i] = TrendDownStrong[0];
NoDirection[i] = NoDirection[0];
Volatile[i] = Volatile[0];
//--
} } }
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Raff
return(0);
}
//+-------------------------------------------------------+
Comments