TrendForce
Download scriptThe TrendForce script is designed to provide a comprehensive overview of current market momentum by aggregating data from multiple technical indicators across various timeframes simultaneously. Instead of relying on a single piece of information, it calculates a "consensus" score to determine the overall strength and direction of the market trend.
How the Logic Works
The tool operates by analyzing seven different timeframes (ranging from the 1-minute chart up to the Daily chart). For each of these timeframes, the script evaluates 13 distinct technical indicators. These indicators include:
- Moving Averages: It checks three different types of moving averages (Fast, Medium, and Slow) to see if they are sloping upwards or downwards.
- Momentum & Strength Indicators: It analyzes tools such as RSI, MACD, CCI, Force Index, Momentum Index, and DeMarker to determine the velocity of price movement.
- Directional Bias Tools: It utilizes ADX (to measure trend strength), Bulls Power, and Bears Power (to see which side has more "weight"), and Stochastic Oscillators (to identify overbought or oversold conditions).
The Scoring System
The script follows a systematic "voting" process:
- Individual Assessment: For every single timeframe, the script looks at each indicator. If an indicator suggests an upward trend, it adds a point to the "Up" tally. If it suggests a downward trend, it adds a point to the "Down" tally.
- Cumulative Summation: Because there are 13 indicators across 7 timeframes, the script creates a large pool of data points to compare against one another.
- Percentage Calculation: Once all data points have been processed, the script calculates the percentage of "Up" votes versus "Down" votes.
- Visual Output: The final result is displayed directly on your chart as a percentage score. This gives you a clear, unified view of whether the market is currently biased toward the upside (Green) or the downside (Red).
Key Takeaway for the User
Rather than forcing you to look at dozens of different charts and lines to guess where the price might go next, this script condenses that complexity into a single "Trend Force" percentage. It tells you how much of the technical market landscape is currently aligned in one direction at any given moment.
//+------------------------------------------------------------------+
//| TrendForce.mq4 |
//+------------------------------------------------------------------+
//| Ðàñ÷åò ñèëû òåíäåíöèè äâèæåíèÿ íà ðûíêå, íàáîð èíäèêàòîðîâ è èõ
//| ïàðàìåòðû ïîëíîñòüþ âçÿòû èç:
//| -----------------------------------------------------------------+
//| FerruFx_Multi_info+_light_chart_v1.1-Ndisc.mq4 |
//| Copyright © 2007, FerruFx |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, Bookkeeper"
#property link "yuzefovich@gmail.com"
#property indicator_chart_window
//---- Indicators parameters
//---- Moving Average Settings
int FastMAPeriod = 20; // Fast Moving Average period
int MediumMAPeriod = 50; // Medium Moving Average period
int SlowMAPeriod = 100; // Slow Moving Average period
int MAMethod = MODE_EMA; // Moving Average method
int MAPrice = PRICE_CLOSE; // Moving Average price
//---- CCI Settings
int CCIPeriod = 14; // Commodity Channel Index period
int CCIPrice = PRICE_CLOSE; // CCI price
//---- MACD Settings
int MACDFast = 12; // MACD fast EMA period
int MACDSlow = 26; // MACD slow EMA period
int MACDSignal = 9; // MACD signal SMA period
//---- ADX Settings ===";
int ADXPeriod = 14; // Average Directional movement period
int ADXPrice = PRICE_CLOSE; // ADX price
//---- BULLS Settings ===";
int BULLSPeriod = 13; // Bulls Power period
int BULLSPrice = PRICE_CLOSE; // Bulls Power price
//---- BEARS Settings ===";
int BEARSPeriod = 13; // Bears Power period
int BEARSPrice = PRICE_CLOSE; // Bears Power price
//---- STOCHASTIC Settings ===";
int STOKPeriod = 5; // Stochastic %K period
int STODPeriod = 3; // Stochastic %D period
int STOSlowing = 3; // Stochastic slowing
//---- RSI Settings ===";
int RSIPeriod = 14; // RSI period
//---- FORCE INDEX Settings ===";
int FIPeriod = 14; // Force Index period
int FIMethod = MODE_SMA; // Force Index method
int FIPrice = PRICE_CLOSE; // Force Index price
//---- MOMENTUM INDEX Settings ===";
int MOMPeriod = 14; // Momentum period
int MOMPrice = PRICE_CLOSE; // Momentum price
//---- DeMARKER Settings ===";
int DEMPeriod = 14; // DeMarker period
int TF[7]={PERIOD_D1,
PERIOD_H4,
PERIOD_H1,
PERIOD_M30,
PERIOD_M15,
PERIOD_M5,
PERIOD_M1};
//+------------------------------------------------------------------+
int init()
{
ObjectCreate("Trend_text", OBJ_LABEL, 0, 0, 0);
ObjectSetText("Trend_text","Trend Force",9, "System", Blue);
ObjectSet("Trend_text", OBJPROP_CORNER, 1);
ObjectSet("Trend_text", OBJPROP_XDISTANCE, 15);
ObjectSet("Trend_text", OBJPROP_YDISTANCE, 10);
ObjectCreate("Trend_UP_text", OBJ_LABEL, 0, 0, 0);
ObjectSet("Trend_UP_text", OBJPROP_CORNER, 1);
ObjectSet("Trend_UP_text", OBJPROP_XDISTANCE, 50);
ObjectSet("Trend_UP_text", OBJPROP_YDISTANCE, 30);
ObjectCreate("Trend_UP_value", OBJ_LABEL, 0, 0, 0);
ObjectSet("Trend_UP_value", OBJPROP_CORNER, 1);
ObjectSet("Trend_UP_value", OBJPROP_XDISTANCE, 15);
ObjectSet("Trend_UP_value", OBJPROP_YDISTANCE, 30);
ObjectCreate("Trend_DOWN_text", OBJ_LABEL, 0, 0, 0);
ObjectSet("Trend_DOWN_text", OBJPROP_CORNER, 1);
ObjectSet("Trend_DOWN_text", OBJPROP_XDISTANCE, 50);
ObjectSet("Trend_DOWN_text", OBJPROP_YDISTANCE, 45);
ObjectCreate("Trend_DOWN_value", OBJ_LABEL, 0, 0, 0);
ObjectSet("Trend_DOWN_value", OBJPROP_CORNER, 1);
ObjectSet("Trend_DOWN_value", OBJPROP_XDISTANCE, 15);
ObjectSet("Trend_DOWN_value", OBJPROP_YDISTANCE, 45);
return(0);
}
//+------------------------------------------------------------------+
int deinit()
{
ObjectDelete("Trend_text");
ObjectDelete("Trend_UP_text");
ObjectDelete("Trend_UP_value");
ObjectDelete("Trend_DOWN_text");
ObjectDelete("Trend_DOWN_value");
return(0);
}
//+------------------------------------------------------------------+
int start()
{
if( Period() > PERIOD_D1 ) return(0);
int SUM_UP=0, SUM_DOUN=0;
for(int j=0; j<7; j++)
{
int TimeFrame=TF[j];
double FastMA_1 = iMA(NULL,TimeFrame,FastMAPeriod,0,MAMethod,MAPrice,0);
double FastMA_2 = iMA(NULL,TimeFrame,FastMAPeriod,0,MAMethod,MAPrice,1);
if ((FastMA_1 > FastMA_2)) SUM_UP++;
if ((FastMA_1 < FastMA_2)) SUM_DOUN++;
double MediumMA_1 = iMA(NULL,TimeFrame,MediumMAPeriod,0,MAMethod,MAPrice,0);
double MediumMA_2 = iMA(NULL,TimeFrame,MediumMAPeriod,0,MAMethod,MAPrice,1);
if ((MediumMA_1 > MediumMA_2)) SUM_UP++;
if ((MediumMA_1 < MediumMA_2)) SUM_DOUN++;
double SlowMA_1 = iMA(NULL,TimeFrame,SlowMAPeriod,0,MAMethod,MAPrice,0);
double SlowMA_2 = iMA(NULL,TimeFrame,SlowMAPeriod,0,MAMethod,MAPrice,1);
if ((SlowMA_1 > SlowMA_2)) SUM_UP++;
if ((SlowMA_1 < SlowMA_2)) SUM_DOUN++;
double cci=iCCI(NULL,TimeFrame,CCIPeriod,CCIPrice,0);
if ((cci > 0)) SUM_UP++;
if ((cci < 0)) SUM_DOUN++; //
double MACD_m=iMACD(NULL,TimeFrame,MACDFast,MACDSlow,MACDSignal,PRICE_CLOSE,MODE_MAIN,0);
double MACD_s=iMACD(NULL,TimeFrame,MACDFast,MACDSlow,MACDSignal,PRICE_CLOSE,MODE_SIGNAL,0);
if ((MACD_m > MACD_s)) SUM_UP++;
if ((MACD_m < MACD_s)) SUM_DOUN++;
double ADX_plus=iADX(NULL,TimeFrame,ADXPeriod,ADXPrice,MODE_PLUSDI,0);
double ADX_minus=iADX(NULL,TimeFrame,ADXPeriod,ADXPrice,MODE_MINUSDI,0);
if ((ADX_plus > ADX_minus)) SUM_UP++;
if ((ADX_plus < ADX_minus)) SUM_DOUN++;
double bulls=iBullsPower(NULL,TimeFrame,BULLSPeriod,BULLSPrice,0);
if ((bulls > 0)) SUM_UP++;
if ((bulls < 0)) SUM_DOUN++;
double bears=iBearsPower(NULL,TimeFrame,BEARSPeriod,BEARSPrice,0);
if ((bears > 0)) SUM_UP++;
if ((bears < 0)) SUM_DOUN++;
double stoch_m=iStochastic(NULL,TimeFrame,STOKPeriod,STODPeriod,STOSlowing,MODE_SMA,1,MODE_MAIN,0);
double stoch_s=iStochastic(NULL,TimeFrame,STOKPeriod,STODPeriod,STOSlowing,MODE_SMA,1,MODE_SIGNAL,0);
if (stoch_m >= stoch_s) SUM_UP++;
if (stoch_m < stoch_s) SUM_DOUN++;
double rsi=iRSI(NULL,TimeFrame,RSIPeriod,PRICE_CLOSE,0);
if (rsi >= 50) SUM_UP++;
if (rsi < 50) SUM_DOUN++;
double fi=iForce(NULL,TimeFrame,FIPeriod,FIMethod,FIPrice,0);
if (fi >= 0) SUM_UP++;
if (fi < 0) SUM_DOUN++;
double momentum=iMomentum(NULL,TimeFrame,MOMPeriod,MOMPrice,0);
if (momentum >= 100) SUM_UP++;
if (momentum < 100) SUM_DOUN++;
double demarker_0=iDeMarker(NULL,TimeFrame,DEMPeriod,0);
double demarker_1=iDeMarker(NULL,TimeFrame,DEMPeriod,1);
if (demarker_0 >= demarker_1) SUM_UP++;
if (demarker_0 < demarker_1) SUM_DOUN++;
}
double v=100.0*SUM_UP/(SUM_UP+SUM_DOUN);
string Trend_UP=DoubleToStr(v,0);
string Trend_DOWN=DoubleToStr((100.0-v),0);
ObjectSetText("Trend_UP_text","UP",10, "System", ForestGreen);
ObjectSetText("Trend_UP_value",Trend_UP+"%",10, "System", ForestGreen);
ObjectSetText("Trend_DOWN_text","DOWN",10, "System", Red);
ObjectSetText("Trend_DOWN_value",Trend_DOWN+"%",10, "System", Red);
return(0);
}
Comments