FDM_Multi-Trend
Download scriptThis script functions as a multi-trend analysis tool designed to help traders identify the prevailing direction of the market by combining price action, momentum, and historical volatility. Rather than relying on a single metric, it synthesizes several layers of data to produce a visual representation of current market trends.
Core Logic Overview
The indicator works by processing market data through three primary stages: price range analysis, momentum calculation, and trend filtering.
1. Price Range & Position Analysis
The tool first establishes the "playing field" by looking back at a specific number of historical bars (defined by the internal settings). It identifies the highest high and the lowest low within that window to determine the total volatility range. It then calculates where the current price sits relative to that range. By understanding how far the price has traveled from its recent lows compared to its recent highs, the tool establishes a base percentage of market movement.
2. Momentum & Smoothing
To ensure the indicator doesn't react too wildly to minor "noise" in the market, the script applies several smoothing filters:
- Smoothing: It uses weighted calculations to blend the current price position with previous data points. This helps prevent erratic jumping of the indicator values.
- Logarithmic Transformation: The script converts these smoothed values into a logarithmic scale. This is a common mathematical technique used to normalize data, making it easier to see clear trends regardless of how volatile the underlying asset is.
3. Trend Confirmation (The Signal)
The final step involves comparing the calculated trend against an Average Directional Index (ADX). The ADX measures the strength of a move regardless of direction. By combining the smoothed price position with these directional indicators, the script categorizes the market into four distinct states:
- Strong Bullish: High upward momentum confirmed by positive price positioning.
- Strong Bearish: High downward momentum confirmed by negative price positioning.
- Weak Bullish: Upward movement that lacks significant strength or "push."
- Weak Bearish: Downward movement that is losing steam or strength.
Visual Output
The indicator renders these four states as histograms in a separate window. By looking at the colors and heights of the bars, a user can quickly discern not just which way the market is moving, but also the "conviction" behind that move. If the price is moving up but the momentum is low, the visual output reflects that lack of strength, helping traders avoid entering trades during exhausted trends.
/*
*/
#property copyright "Copyright © 2008, Forex Day Monster"
#property link "www.forexprofitmonster.com"
#property indicator_separate_window
#property indicator_minimum 0.0
#property indicator_maximum 1.0
#property indicator_buffers 4
#property indicator_color1 Red
#property indicator_color2 Lime
#property indicator_color3 Salmon
#property indicator_color4 LightGreen
extern int Minutes = 5;
int gi_80 = 13;
int gi_84 = 6;
double g_ibuf_88[];
double g_ibuf_92[];
double g_ibuf_96[];
double g_ibuf_100[];
double gda_104[];
double g_iadx_132;
double g_iadx_140;
string gs_148;
double gd_156;
double g_ilow_164 = 0.0;
double g_ihigh_172 = 0.0;
double gd_180 = 0.0;
double gd_188 = 0.0;
double gd_unused_196 = 0.0;
double gd_204 = 0.0;
double gd_212 = 0.0;
double gd_220 = 0.0;
int init() {
IndicatorBuffers(5);
SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID, 5);
SetIndexBuffer(0, g_ibuf_88);
SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID, 5);
SetIndexBuffer(1, g_ibuf_92);
SetIndexStyle(2, DRAW_HISTOGRAM, STYLE_SOLID, 2);
SetIndexBuffer(2, g_ibuf_96);
SetIndexStyle(3, DRAW_HISTOGRAM, STYLE_SOLID, 2);
SetIndexBuffer(3, g_ibuf_100);
SetIndexLabel(0, NULL);
SetIndexLabel(1, NULL);
SetIndexLabel(2, NULL);
SetIndexLabel(3, NULL);
SetIndexLabel(4, NULL);
switch (Minutes) {
case 1:
gs_148 = "Period_M1";
break;
case 5:
gs_148 = "Period_M5";
break;
case 15:
gs_148 = "Period_M15";
break;
case 30:
gs_148 = "Period_M30";
break;
case 60:
gs_148 = "Period_H1";
break;
case 240:
gs_148 = "Period_H4";
break;
case 1440:
gs_148 = "Period_D1";
break;
case 10080:
gs_148 = "Period_W1";
break;
case 43200:
gs_148 = "Period_MN1";
break;
default:
gs_148 = "Current Timeframe";
Minutes = 0;
}
IndicatorShortName("FDM Multi-Trend (" + gs_148 + ")");
return (0);
}
int deinit() {
return (0);
}
int start() {
string ls_0 = "2015.11.01";
int l_str2time_8 = StrToTime(ls_0);
if (TimeCurrent() >= l_str2time_8) {
Alert(" Trial version has expired! Email support@forexprofitmonster.com with broker account number for rights to full version!");
return (0);
}
int li_unused_12 = IndicatorCounted();
for (int li_16 = 800; li_16 > -1; li_16--) {
g_ibuf_88[li_16] = 0;
g_ibuf_92[li_16] = 0;
g_ibuf_96[li_16] = 0;
g_ibuf_100[li_16] = 0;
gda_104[li_16] = 0;
g_iadx_132 = iADX(NULL, Minutes, 14, PRICE_CLOSE, MODE_PLUSDI, li_16);
g_iadx_140 = iADX(NULL, Minutes, 14, PRICE_CLOSE, MODE_MINUSDI, li_16);
g_ihigh_172 = iHigh(NULL, Minutes, iHighest(NULL, Minutes, MODE_HIGH, gi_80, li_16));
g_ilow_164 = iLow(NULL, Minutes, iLowest(NULL, Minutes, MODE_LOW, gi_80, li_16));
gd_156 = (iHigh(NULL, Minutes, li_16) + iLow(NULL, Minutes, li_16)) / 2.0;
if (gi_84 == 1) gd_156 = iOpen(NULL, Minutes, li_16);
if (gi_84 == 2) gd_156 = iClose(NULL, Minutes, li_16);
if (gi_84 == 3) gd_156 = iHigh(NULL, Minutes, li_16);
if (gi_84 == 4) gd_156 = iLow(NULL, Minutes, li_16);
if (gi_84 == 5) gd_156 = (iHigh(NULL, Minutes, li_16) + iLow(NULL, Minutes, li_16) + iClose(NULL, Minutes, li_16)) / 3.0;
if (gi_84 == 6) gd_156 = (iOpen(NULL, Minutes, li_16) + iHigh(NULL, Minutes, li_16) + iLow(NULL, Minutes, li_16) + iClose(NULL, Minutes, li_16)) / 4.0;
if (gi_84 == 7) gd_156 = (iOpen(NULL, Minutes, li_16) + iClose(NULL, Minutes, li_16)) / 2.0;
gd_180 = 0.66 * ((gd_156 - g_ilow_164) / (g_ihigh_172 - g_ilow_164) - 0.5) + 0.67 * gd_188;
gd_180 = MathMin(MathMax(gd_180, -0.999), 0.999);
gd_204 = MathLog((gd_180 + 1.0) / (1 - gd_180)) / 2.0 - gd_212 / 2.0 - gd_220 / 2.0;
if (gd_204 > 0.0 && g_iadx_132 > g_iadx_140) g_ibuf_92[li_16] = 1;
if (gd_204 > 0.0 && g_iadx_140 > g_iadx_132) g_ibuf_100[li_16] = 1;
if (gd_204 < 0.0 && g_iadx_140 > g_iadx_132) g_ibuf_88[li_16] = 1;
if (gd_204 < 0.0 && g_iadx_132 > g_iadx_140) g_ibuf_96[li_16] = 1;
if (g_ibuf_88[li_16] == 0.0 && g_ibuf_92[li_16] == 0.0) {
}
if (gd_204 == 0.0 && g_iadx_132 > g_iadx_140) g_ibuf_92[li_16] = 1;
if (gd_204 == 0.0 && g_iadx_132 < g_iadx_140) g_ibuf_88[li_16] = 1;
gd_188 = gd_180;
gd_220 = gd_212;
gd_212 = gd_204;
}
return (0);
}
Comments