FTLM_hist_v1
Download scriptThis script functions as a visual technical indicator designed to help traders identify momentum and potential trend shifts by analyzing historical price data. Instead of plotting directly on the main price chart, it appears in a separate window at the bottom of your trading platform, displaying information as a histogram (vertical bars).
Core Logic and Mechanism
The script operates based on a sophisticated mathematical comparison between two distinct weighted averages. Here is how that logic works step-by-step:
1. Weighted Price Calculation The tool looks back at a specific number of previous price points (determined by the "CountBars" setting). It calculates two primary values, which we can call "Value 1/3" and "Value 2/4." Each of these values is derived by multiplying past closing prices by unique, predefined coefficients. These coefficients determine how much weight each specific historical price holds in the current calculation; some prices are given significant importance (positive weights), while others may be discounted or subtracted (negative weights).
2. Dual-Layer Comparison The script performs this complex weighted calculation twice:
- It calculates a value for the current immediate data set.
- It then calculates a secondary value based on a slightly offset version of that same data.
By comparing these two different "weighted perspectives," the script creates a variance—essentially measuring the difference between current momentum and the expected trend based on the weighted history.
3. Trend Identification (Up vs. Down) The script takes the results of these comparisons and converts them into a visual signal:
- Bullish Signal (Green): If the first calculation result is greater than the second, the script identifies an upward momentum. It records this as an "Up" value and draws a green bar on the histogram.
- Bearish Signal (Red): If the second calculation result is greater, it identifies downward momentum. It records this as a "Down" value and draws a red bar on the histogram.
Summary for the Trader
In simple terms, this script acts as a sophisticated "filter." Rather than just showing you where the price is, it processes dozens of historical data points through a complex mathematical formula to determine if the current market "pressure" is leaning more towards the upside or the downside. The resulting histogram allows you to see these momentum shifts clearly in real-time.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| FTLM_hist.mq4
//| Ramdass - Conversion only
//+------------------------------------------------------------------+
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red
extern int CountBars=300;
//---- buffers
double Up[];
double Down[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicator line
IndicatorBuffers(2);
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(0,Up);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexBuffer(1,Down);
//----
return(0);
}
//+------------------------------------------------------------------+
//| FTLM |
//+------------------------------------------------------------------+
int start()
{
SetIndexDrawBegin(0,Bars-CountBars+43);
SetIndexDrawBegin(1,Bars-CountBars+43);
int i,i2,counted_bars=IndicatorCounted();
double FTLM,FTLM1,value1,value2,value3,value4;
//----
if(Bars<=43) return(0);
//---- initial zero
if(counted_bars<43)
{
for(i=1;i<=0;i++) Up[CountBars-i]=0.0;
for(i=1;i<=0;i++) Down[CountBars-i]=0.0;
}
//----
i=CountBars-43-1;
// if(counted_bars>=43) i=Bars-counted_bars-1;
while(i>=0)
{
value1 =
0.4360409450*Close[i+0]
+0.3658689069*Close[i+1]
+0.2460452079*Close[i+2]
+0.1104506886*Close[i+3]
-0.0054034585*Close[i+4]
-0.0760367731*Close[i+5]
-0.0933058722*Close[i+6]
-0.0670110374*Close[i+7]
-0.0190795053*Close[i+8]
+0.0259609206*Close[i+9]
+0.0502044896*Close[i+10]
+0.0477818607*Close[i+11]
+0.0249252327*Close[i+12]
-0.0047706151*Close[i+13]
-0.0272432537*Close[i+14]
-0.0338917071*Close[i+15]
-0.0244141482*Close[i+16]
-0.0055774838*Close[i+17]
+0.0128149838*Close[i+18]
+0.0226522218*Close[i+19]
+0.0208778257*Close[i+20]
+0.0100299086*Close[i+21]
-0.0036771622*Close[i+22]
-0.0136744850*Close[i+23]
-0.0160483392*Close[i+24]
-0.0108597376*Close[i+25]
-0.0016060704*Close[i+26]
+0.0069480557*Close[i+27]
+0.0110573605*Close[i+28]
+0.0095711419*Close[i+29]
+0.0040444064*Close[i+30]
-0.0023824623*Close[i+31]
-0.0067093714*Close[i+32]
-0.0072003400*Close[i+33]
-0.0047717710*Close[i+34]
+0.0005541115*Close[i+35]
+0.0007860160*Close[i+36]
+0.0130129076*Close[i+37]
+0.0040364019*Close[i+38];
value2 =
-0.0025097319*Close[i+0]
+0.0513007762*Close[i+1]
+0.1142800493*Close[i+2]
+0.1699342860*Close[i+3]
+0.2025269304*Close[i+4]
+0.2025269304*Close[i+5]
+0.1699342860*Close[i+6]
+0.1142800493*Close[i+7]
+0.0513007762*Close[i+8]
-0.0025097319*Close[i+9]
-0.0353166244*Close[i+10]
-0.0433375629*Close[i+11]
-0.0311244617*Close[i+12]
-0.0088618137*Close[i+13]
+0.0120580088*Close[i+14]
+0.0233183633*Close[i+15]
+0.0221931304*Close[i+16]
+0.0115769653*Close[i+17]
-0.0022157966*Close[i+18]
-0.0126536111*Close[i+19]
-0.0157416029*Close[i+20]
-0.0113395830*Close[i+21]
-0.0025905610*Close[i+22]
+0.0059521459*Close[i+23]
+0.0105212252*Close[i+24]
+0.0096970755*Close[i+25]
+0.0046585685*Close[i+26]
-0.0017079230*Close[i+27]
-0.0063513565*Close[i+28]
-0.0074539350*Close[i+29]
-0.0050439973*Close[i+30]
-0.0007459678*Close[i+31]
+0.0032271474*Close[i+32]
+0.0051357867*Close[i+33]
+0.0044454862*Close[i+34]
+0.0018784961*Close[i+35]
-0.0011065767*Close[i+36]
-0.0031162862*Close[i+37]
-0.0033443253*Close[i+38]
-0.0022163335*Close[i+39]
+0.0002573669*Close[i+40]
+0.0003650790*Close[i+41]
+0.0060440751*Close[i+42]
+0.0018747783*Close[i+43];
value3 =
0.4360409450*Close[i+0+1]
+0.3658689069*Close[i+1+1]
+0.2460452079*Close[i+2+1]
+0.1104506886*Close[i+3+1]
-0.0054034585*Close[i+4+1]
-0.0760367731*Close[i+5+1]
-0.0933058722*Close[i+6+1]
-0.0670110374*Close[i+7+1]
-0.0190795053*Close[i+8+1]
+0.0259609206*Close[i+9+1]
+0.0502044896*Close[i+10+1]
+0.0477818607*Close[i+11+1]
+0.0249252327*Close[i+12+1]
-0.0047706151*Close[i+13+1]
-0.0272432537*Close[i+14+1]
-0.0338917071*Close[i+15+1]
-0.0244141482*Close[i+16+1]
-0.0055774838*Close[i+17+1]
+0.0128149838*Close[i+18+1]
+0.0226522218*Close[i+19+1]
+0.0208778257*Close[i+20+1]
+0.0100299086*Close[i+21+1]
-0.0036771622*Close[i+22+1]
-0.0136744850*Close[i+23+1]
-0.0160483392*Close[i+24+1]
-0.0108597376*Close[i+25+1]
-0.0016060704*Close[i+26+1]
+0.0069480557*Close[i+27+1]
+0.0110573605*Close[i+28+1]
+0.0095711419*Close[i+29+1]
+0.0040444064*Close[i+30+1]
-0.0023824623*Close[i+31+1]
-0.0067093714*Close[i+32+1]
-0.0072003400*Close[i+33+1]
-0.0047717710*Close[i+34+1]
+0.0005541115*Close[i+35+1]
+0.0007860160*Close[i+36+1]
+0.0130129076*Close[i+37+1]
+0.0040364019*Close[i+38+1];
value4 =
-0.0025097319*Close[i+0+1]
+0.0513007762*Close[i+1+1]
+0.1142800493*Close[i+2+1]
+0.1699342860*Close[i+3+1]
+0.2025269304*Close[i+4+1]
+0.2025269304*Close[i+5+1]
+0.1699342860*Close[i+6+1]
+0.1142800493*Close[i+7+1]
+0.0513007762*Close[i+8+1]
-0.0025097319*Close[i+9+1]
-0.0353166244*Close[i+10+1]
-0.0433375629*Close[i+11+1]
-0.0311244617*Close[i+12+1]
-0.0088618137*Close[i+13+1]
+0.0120580088*Close[i+14+1]
+0.0233183633*Close[i+15+1]
+0.0221931304*Close[i+16+1]
+0.0115769653*Close[i+17+1]
-0.0022157966*Close[i+18+1]
-0.0126536111*Close[i+19+1]
-0.0157416029*Close[i+20+1]
-0.0113395830*Close[i+21+1]
-0.0025905610*Close[i+22+1]
+0.0059521459*Close[i+23+1]
+0.0105212252*Close[i+24+1]
+0.0096970755*Close[i+25+1]
+0.0046585685*Close[i+26+1]
-0.0017079230*Close[i+27+1]
-0.0063513565*Close[i+28+1]
-0.0074539350*Close[i+29+1]
-0.0050439973*Close[i+30+1]
-0.0007459678*Close[i+31+1]
+0.0032271474*Close[i+32+1]
+0.0051357867*Close[i+33+1]
+0.0044454862*Close[i+34+1]
+0.0018784961*Close[i+35+1]
-0.0011065767*Close[i+36+1]
-0.0031162862*Close[i+37+1]
-0.0033443253*Close[i+38+1]
-0.0022163335*Close[i+39+1]
+0.0002573669*Close[i+40+1]
+0.0003650790*Close[i+41+1]
+0.0060440751*Close[i+42+1]
+0.0018747783*Close[i+43+1];
FTLM=value1-value2;
FTLM1=value3-value4;
if (FTLM>FTLM1) {Up[i]=FTLM;Down[i]=0.0;} else {Down[i]=FTLM;Up[i]=0.0;}
i--;
}
return(0);
}
//+------------------------------------------------------------------+
Comments