FTLM_hist_v2

Download script
FTLM_hist_v2

This script functions as a specialized technical analysis tool designed to visualize market momentum and price trends through a custom historical histogram. Rather than using standard moving averages or simple oscillators, it utilizes a complex mathematical weighting system to determine the "strength" of price movement over a specific period.

Core Logic Overview

The primary objective of the script is to compare two distinct types of weighted price actions to identify which trend is currently dominant. It achieves this through the following steps:

1. Data Collection and Weighting The indicator looks back at a set window of historical price data (the number of bars is customizable but defaults to 300). For every point on the chart, it calculates four unique values (value1 through value4). Each of these values is derived by multiplying previous closing prices by specific, highly precise decimal coefficients.

  • Value 1 & 3: These represent a primary weighted calculation based on a specific set of historical price points.
  • Value 2 & 4: These represent a secondary, different weighting profile applied to the same timeframe.

2. Comparative Analysis (The "Shift") The script creates two "results" by subtracting the second value from the first:

  • FTLM: The difference between the current weighted data and its primary counterpart.
  • FTLM1: The difference between the next immediate set of weighted data.

By comparing FTLM to FTLM1, the script determines whether the current momentum is expanding, contracting, or shifting direction.

3. Visual Representation (The Histogram) The final output is displayed as a two-color histogram in a separate window below the main price chart:

  • Green Bars: These appear when the primary calculation (FTLM) is greater than the secondary comparison (FTLM1), signaling one type of momentum or "upward" pressure.
  • Red Bars: These appear when the secondary comparison exceeds the primary, signaling a shift in weight or "downward" pressure.

Summary for the User

Think of this tool as a momentum filter. Instead of just telling you if the price is going up or down, it uses a sophisticated "recipe" of historical prices to see which trend is winning the tug-of-war. The histogram provides a clear visual cue: when the bars are Green, one specific mathematical trend is dominant; when they turn Red, the weight of the market has shifted in favor of the opposing calculation.

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