Author: Copyright 2002, Finware.ru Ltd.
s_rbci

This script is a technical analysis tool designed for the MetaTrader platform to help traders visualize specific price momentum and trends. It functions by generating two distinct lines on a separate indicator window, providing a clearer picture of market dynamics than standard price charts alone.

Core Logic and Functionality

The primary objective of this script is to calculate two different types of weighted moving averages (referred to in the code as "FTLM" and "STLM"). Rather than using simple averages—where every past price point carries equal weight—this script uses a sophisticated mathematical model where different historical prices are assigned specific multipliers.

1. Mathematical Weighting

The tool analyzes a series of past closing prices (ranging from roughly 43 to 50 candles back) and applies a unique coefficient to each one. This means:

  • Recent price action has a high impact on the current calculation.
  • Older price action is given progressively less weight.
  • Negative weights are applied to specific historical points, which helps "smooth out" noise or react more aggressively to certain types of trend reversals.

2. The Two Indicator Lines

The script produces two unique values based on the interactions between these weighted averages:

  • FTLM (Fast Trend Line Momentum): This is calculated by subtracting one weighted average from another. Because it focuses on shorter-range price data, it is designed to be more sensitive to immediate changes in market direction. It helps traders identify "fast" momentum shifts.
  • STLM (Slow Trend Line Momentum): This is calculated using a different set of weights and historical data points. It is intended to be "slower" and more stable, reflecting the broader trend of the market.

How it Works for the User

When you apply this script to a chart:

  1. Data Processing: The script constantly scans the history of the current asset's closing prices.
  2. Comparison: It calculates the "Fast" and "Slow" momentum values simultaneously.
  3. Visual Output: It plots these as two lines in a separate window below your main chart.

Trading Context

By observing the relationship between these two lines, traders can look for specific signals:

  • Crossovers: When the fast line moves above or below the slow line, it can indicate a potential change in trend direction.
  • Divergence: When the lines move away from each other significantly, it may suggest increasing volatility or strength in a particular direction.
  • Trend Confirmation: If both lines are moving upward or downward in synchronization, it provides visual confirmation of the prevailing market trend.
Miscellaneous
Implements a curve of type %1
14 Views
0 Downloads
0 Favorites
s_rbci
//+------------------------------------------------------------------+ 
//| s_ftlm-stlm.mq4 
//| 
//+------------------------------------------------------------------+ 
#property copyright "Copyright 2002, Finware.ru Ltd." 
#property link "http://www.finware.ru/" 

#property indicator_separate_window 
#property indicator_buffers 2 
#property indicator_color1 Aqua 
#property indicator_color2 Bisque 


//---- buffers 
double FTLMBuffer[]; 
double STLMBuffer[]; 
double value1; 
double value2; 
double value3; 
double value4; 
//+------------------------------------------------------------------+ 
//| Custom indicator initialization function | 
//+------------------------------------------------------------------+ 
int init() 
{ 
string short_name; 
//---- indicator line 
IndicatorBuffers(2); 
SetIndexStyle(0,DRAW_LINE); 
SetIndexBuffer(0,STLMBuffer); 
SetIndexStyle(1,DRAW_LINE); 
SetIndexBuffer(1,FTLMBuffer); 
SetIndexDrawBegin(0,90); 
SetIndexDrawBegin(1,43); 
//---- 
return(0); 
} 
//+------------------------------------------------------------------+ 
//| FTLM_STLM | 
//+------------------------------------------------------------------+ 
int start() 
{ 
int i,counted_bars=IndicatorCounted(); 
//---- 
if(Bars<=90) return(0); 
//---- initial zero 
if(counted_bars<43) 
{ 
for(i=1;i<=0;i++) FTLMBuffer[Bars-i]=0.0; 
for(i=1;i<=0;i++) STLMBuffer[Bars-i]=0.0; 
} 
//---- 
i=Bars-43-1; 
if(counted_bars>=43) i=Bars-counted_bars-1; 
while(i>=0) 
{ 
value1 =
//13-10-6-fatl
0.3455333437*Close[i+0]
+0.3104452395*Close[i+1]
+0.2467727110*Close[i+2]
+0.1660900892*Close[i+3]
+0.0824508141*Close[i+4]
+0.0093791793*Close[i+5]
-0.0429080876*Close[i+6]
-0.0693711163*Close[i+7]
-0.0707276930*Close[i+8]
-0.0526773552*Close[i+9]
-0.0240516883*Close[i+10]
+0.0055741101*Close[i+11]
+0.0281944290*Close[i+12]
+0.0390002224*Close[i+13]
+0.0371103592*Close[i+14]
+0.0251274787*Close[i+15]
+0.0079573481*Close[i+16]
-0.0088280666*Close[i+17]
-0.0206078968*Close[i+18]
-0.0248192566*Close[i+19]
-0.0213730519*Close[i+20]
-0.0123302545*Close[i+21]
-0.0010359963*Close[i+22]
+0.0089942973*Close[i+23]
+0.0150902506*Close[i+24]
+0.0160720394*Close[i+25]
+0.0123983771*Close[i+26]
+0.0057455569*Close[i+27]
-0.0014872353*Close[i+28]
-0.0071768492*Close[i+29]
-0.0098867646*Close[i+30]
-0.0092331526*Close[i+31]
-0.0058709069*Close[i+32]
-0.0011380552*Close[i+33]
+0.0034367594*Close[i+34]
+0.0066183781*Close[i+35]
+0.0077774866*Close[i+36]
+0.0069860925*Close[i+37]
+0.0048875000*Close[i+38]
+0.0024285792*Close[i+39]
+0.0005301752*Close[i+40]
-0.0110773896*Close[i+41];
value2 =
//49-25-24-satl
0.1126457090*Close[i+0]
+0.1119178157*Close[i+1]
+0.1097515596*Close[i+2]
+0.1062007593*Close[i+3]
+0.1013546034*Close[i+4]
+0.0953357303*Close[i+5]
+0.0882937068*Close[i+6]
+0.0804008531*Close[i+7]
+0.0718465222*Close[i+8]
+0.0628323102*Close[i+9]
+0.0535620683*Close[i+10]
+0.0442383619*Close[i+11]
+0.0350615758*Close[i+12]
+0.0262302131*Close[i+13]
+0.0179223763*Close[i+14]
+0.0102710095*Close[i+15]
+0.0033680535*Close[i+16]
-0.0026278180*Close[i+17]
-0.0076997756*Close[i+18]
-0.0117990489*Close[i+19]
-0.0149206753*Close[i+20]
-0.0170825558*Close[i+21]
-0.0183366512*Close[i+22]
-0.0187561124*Close[i+23]
-0.0184263036*Close[i+24]
-0.0174482225*Close[i+25]
-0.0159365431*Close[i+26]
-0.0140135349*Close[i+27]
-0.0118000645*Close[i+28]
-0.0094125258*Close[i+29]
-0.0069602520*Close[i+30]
-0.0045435715*Close[i+31]
-0.0022498315*Close[i+32]
-0.0001521196*Close[i+33]
+0.0016920951*Close[i+34]
+0.0032413803*Close[i+35]
+0.0044722431*Close[i+36]
+0.0053784555*Close[i+37]
+0.0059688616*Close[i+38]
+0.0062637124*Close[i+39]
+0.0062944662*Close[i+40]
+0.0061041927*Close[i+41]
+0.0057461721*Close[i+42]
+0.0052789376*Close[i+43]
+0.0047654671*Close[i+44]
+0.0042767741*Close[i+45]
+0.0038939686*Close[i+46]
+0.0037048971*Close[i+47]
+0.0038109913*Close[i+48]
-0.0099602367*Close[i+49];
value3 =
//21-15-5-fatl
0.2298632753*Close[i+0]
+0.2199017446*Close[i+1]
+0.2007736117*Close[i+2]
+0.1739985778*Close[i+3]
+0.1416608247*Close[i+4]
+0.1062218659*Close[i+5]
+0.0702807556*Close[i+6]
+0.0363415171*Close[i+7]
+0.0065760683*Close[i+8]
-0.0173315587*Close[i+9]
-0.0343517389*Close[i+10]
-0.0441053307*Close[i+11]
-0.0469021916*Close[i+12]
-0.0436354762*Close[i+13]
-0.0356532074*Close[i+14]
-0.0245976416*Close[i+15]
-0.0121758836*Close[i+16]
+0.0000029355*Close[i+17]
+0.0105248262*Close[i+18]
+0.0183573818*Close[i+19]
+0.0229683690*Close[i+20]
+0.0241626727*Close[i+21]
+0.0222686734*Close[i+22]
+0.0178659325*Close[i+23]
+0.0118025988*Close[i+24]
+0.0050130968*Close[i+25]
-0.0015862661*Close[i+26]
-0.0072129596*Close[i+27]
-0.0112882928*Close[i+28]
-0.0134939132*Close[i+29]
-0.0137738906*Close[i+30]
-0.0123158227*Close[i+31]
-0.0095074687*Close[i+32]
-0.0058529296*Close[i+33]
-0.0019101049*Close[i+34]
+0.0017968549*Close[i+35]
+0.0048312099*Close[i+36]
+0.0068953947*Close[i+37]
+0.0078444430*Close[i+38]
+0.0077028921*Close[i+39]
+0.0066191689*Close[i+40]
+0.0048534821*Close[i+41]
+0.0027136793*Close[i+42]
+0.0005156435*Close[i+43]
-0.0014549046*Close[i+44]
-0.0030005610*Close[i+45]
-0.0040576821*Close[i+46]
-0.0048185742*Close[i+47]
-0.0061414736*Close[i+48]
-0.0109740041*Close[i+49]
+0.0037843806*Close[i+50];



 


value4 =
//79-35-39-satl
0.0804692711*Close[i+0]
+0.0802203973*Close[i+1]
+0.0794623927*Close[i+2]
+0.0782236568*Close[i+3]
+0.0764961087*Close[i+4]
+0.0743248341*Close[i+5]
+0.0717239549*Close[i+6]
+0.0687255419*Close[i+7]
+0.0653657257*Close[i+8]
+0.0616926805*Close[i+9]
+0.0577427116*Close[i+10]
+0.0535665574*Close[i+11]
+0.0492085652*Close[i+12]
+0.0447243879*Close[i+13]
+0.0401594217*Close[i+14]
+0.0355693778*Close[i+15]
+0.0309962143*Close[i+16]
+0.0264933500*Close[i+17]
+0.0220986833*Close[i+18]
+0.0178608526*Close[i+19]
+0.0138091664*Close[i+20]
+0.0099890307*Close[i+21]
+0.0064213237*Close[i+22]
+0.0031389533*Close[i+23]
+0.0001486155*Close[i+24]
-0.0025170368*Close[i+25]
-0.0048671074*Close[i+26]
-0.0068796890*Close[i+27]
-0.0085698730*Close[i+28]
-0.0099246833*Close[i+29]
-0.0109768396*Close[i+30]
-0.0117053764*Close[i+31]
-0.0121596410*Close[i+32]
-0.0123628563*Close[i+33]
-0.0122836389*Close[i+34]
-0.0120059539*Close[i+35]
-0.0115353294*Close[i+36]
-0.0109048290*Close[i+37]
-0.0101267136*Close[i+38]
-0.0092396470*Close[i+39]
-0.0082649112*Close[i+40]
-0.0072388642*Close[i+41]
-0.0061827937*Close[i+42]
-0.0051238697*Close[i+43]
-0.0040799769*Close[i+44]
-0.0030726303*Close[i+45]
-0.0021149420*Close[i+46]
-0.0012227141*Close[i+47]
-0.0004082162*Close[i+48]
+0.0003177353*Close[i+49]
+0.0009502553*Close[i+50]
+0.0014841713*Close[i+51]
+0.0019167936*Close[i+52]
+0.0022500277*Close[i+53]
+0.0024879419*Close[i+54]
+0.0026324876*Close[i+55]
+0.0026941894*Close[i+56]
+0.0026766661*Close[i+57]
+0.0025912075*Close[i+58]
+0.0024446415*Close[i+59]
+0.0126902404*Close[i+60];
STLMBuffer[i] = value3-value4; 
FTLMBuffer[i] = value1-value2; 
i--; 
} 
return(0); 
} 
//+------------------------------------------------------------------+ 

Comments