FTLM_hist

This script functions as a specialized technical analysis tool for the MetaTrader platform, designed to visualize specific market momentum or trend fluctuations through a custom histogram. Instead of relying on standard moving averages or basic price action, it utilizes a sophisticated weighted mathematical model to determine market direction.

Core Logic Overview

The script operates by performing high-precision calculations based on historical closing prices. It evaluates the market by comparing two different weighted "values" at two different points in time (the current period and the preceding period).

Here is a breakdown of how that logic flows:

  • Weighted Data Analysis: The tool looks back at a significant window of historical price data. For every single bar on your chart, it applies a unique set of positive and negative multipliers (weights) to the closing prices. This essentially creates a "filtered" version of the price history, where some past prices are given more importance than others based on specific mathematical coefficients.
  • Comparative Calculation: The script performs this heavy weighting twice:
    1. It calculates a value for the current price position.
    2. It calculates a value for the previous price position (shifted by one bar).
  • Delta Determination: By subtracting these two weighted values from each other, the script identifies the "net change" or momentum between these two points. This results in two distinct indicators: FTLM and FTLM1.
  • Directional Signal Generation: The final step is a logic gate. The script compares the current result (FTLM) against the previous result (FTLM1).
    • If the current momentum value is greater than the previous one, the script identifies this as an Upward movement and colors the histogram accordingly (Green).
    • If the previous momentum value was higher, it identifies this as a Downward movement and colors the histogram accordingly (Red).

Visual Representation

The result of this logic is displayed in a separate window below your main chart as a histogram. Rather than just showing you where the price is, it provides a visual representation of whether the underlying mathematical momentum is increasing or decreasing relative to the weighted history provided by the script's unique coefficients.

Miscellaneous
Implements a curve of type %1
12 Views
0 Downloads
0 Favorites
FTLM_hist
//+------------------------------------------------------------------+
//| 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