FTLM_KG_hist_v1

Download script
FTLM_KG_hist_v1

This script functions as a sophisticated price filter designed to smooth out market "noise" and identify underlying trends. Rather than relying on simple moving averages, it utilizes a complex mathematical model called a Digital Filter to interpret price action more accurately.

How the Logic Works

1. Advanced Data Processing (The Weights) The core of this script lies in its use of specific weightings for historical prices. Instead of treating all previous price points equally, the script assigns a unique decimal value to 62 different historical data points. This creates a "weighted calculation" where certain timeframes have more influence on the current output than others. Some values are positive, and some are negative; this allows the script to mathematically "subtract" specific types of noise or outliers from the calculation.

2. Dual-Layer Analysis The script performs two separate calculations simultaneously:

  • Primary Calculation: It processes a set of data points to create one filtered value.
  • Secondary Calculation: It processes a slightly offset set of data points (shifted by one position) to create a second filtered value.

By running these two calculations in parallel, the script can compare the relationship between current price behavior and its immediate predecessor.

3. Trend Identification The final step of the logic involves a comparison between these two primary results:

  • If the first calculation is higher than the second, the script identifies this as upward momentum.
  • If the second calculation is higher, it identifies downward momentum.

4. Visual Representation To make this information easy for a trader to read at a glance, the script translates these mathematical results into a visual histogram:

  • Green Histograms: Represent periods where the logic detects upward movement or strength.
  • Red Histograms: Represent periods where the logic detects downward movement or weakness.

Summary for the User

In plain terms, this tool acts like a "smart lens" for your charts. It looks back at the last 62 bars of data, applies a complex mathematical formula to filter out distractions, and highlights the resulting trend in Green or Red. This allows you to see the "true" direction of the market more clearly than you might by looking at raw price action alone.

Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
FTLM_KG_hist_v1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//| FTLM_KG_hist.mq4 
//| Digital filter from Kenny-Goodman
//| 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+62);
   SetIndexDrawBegin(1,Bars-CountBars+62);
   int i,i2,counted_bars=IndicatorCounted();
   double FTLM,FTLM1,value1,value2,value3,value4;
//----
   if(Bars<=62) return(0);
//---- initial zero
   if(counted_bars<62)
   {
      for(i=1;i<=0;i++) Up[Bars-i]=0.0;
      for(i=1;i<=0;i++) Down[Bars-i]=0.0;
   }
//----
   i=CountBars-62-1;
//   if(counted_bars>=62) i=Bars-counted_bars-1;
   while(i>=0)
     {

value1 =
0.216679747671846*Close[i+0]
+0.211269420463811*Close[i+1]
+0.195544884029715*Close[i+2]
+0.170965415406708*Close[i+3]
+0.139777024336523*Close[i+4]
+0.10475520757496*Close[i+5]
+0.0688963726406815*Close[i+6]
+0.0350907878482374*Close[i+7]
+0.00582303578389499*Close[i+8]
-0.0170687325113629*Close[i+9]
-0.0325430291353946*Close[i+10]
-0.0404061862801786*Close[i+11]
-0.0412576874250575*Close[i+12]
-0.0363489006817302*Close[i+13]
-0.0273726712811041*Close[i+14]
-0.0162239477577438*Close[i+15]
-0.00474919988104162*Close[i+16]
+0.00546044031567738*Close[i+17]
+0.0132340752866597*Close[i+18]
+0.0179048641241163*Close[i+19]
+0.0193288196450583*Close[i+20]
+0.0178203001317383*Close[i+21]
+0.0140521142662672*Close[i+22]
+0.00890900942687798*Close[i+23]
+0.00332796683926323*Close[i+24]
-0.00183047425117888*Close[i+25]
-0.00590003260461143*Close[i+26]
-0.008470924607332*Close[i+27]
-0.00941376204563632*Close[i+28]
-0.00885433738048246*Close[i+29]
-0.00711869639879854*Close[i+30]
-0.00465317542176635*Close[i+31]
-0.00194019707183346*Close[i+32]
+0.000579603884990088*Close[i+33]
+0.00256707017356023*Close[i+34]
+0.00381977207432852*Close[i+35]
+0.00428068634338846*Close[i+36]
+0.00402313632832263*Close[i+37]
+0.0032179506176373*Close[i+38]
+0.00209012998360153*Close[i+39]
+0.000874173133673174*Close[i+40]
-0.000224786383933042*Close[i+41]
-0.0010587336898008*Close[i+42]
-0.00155052433232022*Close[i+43]
-0.00169306769372935*Close[i+44]
-0.00153786701404679*Close[i+45]
-0.00117483219738423*Close[i+46]
-0.000710127079707358*Close[i+47]
-0.000243983404727185*Close[i+48]
+0.000144391315936508*Close[i+49]
+0.000408472741254023*Close[i+50]
+0.000535354473765889*Close[i+51]
+0.000542366420043941*Close[i+52]
+0.000469190409143627*Close[i+53]
+0.000367676722499057*Close[i+54]
-0.000413583883278278*Close[i+55];

value2=
0.0364298167208155*Close[i+0]
+0.0553906231378775*Close[i+1]
+0.0739088457518267*Close[i+2]
+0.0904000966980787*Close[i+3]
+0.103396797434432*Close[i+4]
+0.111711342284296*Close[i+5]
+0.114572120305459*Close[i+6]
+0.111711342284296*Close[i+7]
+0.103396797434432*Close[i+8]
+0.0904000966980787*Close[i+9]
+0.0739088457518267*Close[i+10]
+0.0553906231378775*Close[i+11]
+0.0364298167208155*Close[i+12]
+0.0185546919366474*Close[i+13]
+0.00307900283041587*Close[i+14]
-0.00902530529856102*Close[i+15]
-0.0172075327263682*Close[i+16]
-0.0213652751829327*Close[i+17]
-0.0218155170382955*Close[i+18]
-0.0192199347960543*Close[i+19]
-0.0144736414953281*Close[i+20]
-0.00857861481888381*Close[i+21]
-0.00251119869748709*Close[i+22]
+0.00288727595213947*Close[i+23]
+0.00699768244225111*Close[i+24]
+0.00946742032203178*Close[i+25]
+0.0102203545718079*Close[i+26]
+0.0094227060558747*Close[i+27]
+0.00743023076018664*Close[i+28]
+0.00471074990083792*Close[i+29]
+0.00175970399253971*Close[i+30]
-0.000967886100918518*Close[i+31]
-0.00311971586013391*Close[i+32]
-0.00447910708609257*Close[i+33]
-0.00497764414629577*Close[i+34]
-0.00468184137410999*Close[i+35]
-0.00376409954776387*Close[i+36]
-0.00246042456645472*Close[i+37]
-0.00102590341145799*Close[i+38]
+0.000306472786469948*Close[i+39]
+0.00135737038610145*Close[i+40]
+0.00201975214731277*Close[i+41]
+0.00226346631835387*Close[i+42]
+0.00212728353418576*Close[i+43]
+0.0017015315425756*Close[i+44]
+0.00110518230941413*Close[i+45]
+0.000462229952338165*Close[i+46]
-0.000118858605382952*Close[i+47]
-0.000559818649332224*Close[i+48]
-0.000819859088114563*Close[i+49]
-0.000895230669111811*Close[i+50]
-0.00081316637313982*Close[i+51]
-0.000621207183890965*Close[i+52]
-0.000375488554341561*Close[i+53]
-0.000129009269667756*Close[i+54]
+0.0000763487100123232*Close[i+55]
+0.000215985058849768*Close[i+56]
+0.000283075358142209*Close[i+57]
+0.000286783012231603*Close[i+58]
+0.000248090283379797*Close[i+59]
+0.000194413654881473*Close[i+60]
-0.000218687638971784*Close[i+61];


value3=
0.216679747671846*Close[i+0+1]
+0.211269420463811*Close[i+1+1]
+0.195544884029715*Close[i+2+1]
+0.170965415406708*Close[i+3+1]
+0.139777024336523*Close[i+4+1]
+0.10475520757496*Close[i+5+1]
+0.0688963726406815*Close[i+6+1]
+0.0350907878482374*Close[i+7+1]
+0.00582303578389499*Close[i+8+1]
-0.0170687325113629*Close[i+9+1]
-0.0325430291353946*Close[i+10+1]
-0.0404061862801786*Close[i+11+1]
-0.0412576874250575*Close[i+12+1]
-0.0363489006817302*Close[i+13+1]
-0.0273726712811041*Close[i+14+1]
-0.0162239477577438*Close[i+15+1]
-0.00474919988104162*Close[i+16+1]
+0.00546044031567738*Close[i+17+1]
+0.0132340752866597*Close[i+18+1]
+0.0179048641241163*Close[i+19+1]
+0.0193288196450583*Close[i+20+1]
+0.0178203001317383*Close[i+21+1]
+0.0140521142662672*Close[i+22+1]
+0.00890900942687798*Close[i+23+1]
+0.00332796683926323*Close[i+24+1]
-0.00183047425117888*Close[i+25+1]
-0.00590003260461143*Close[i+26+1]
-0.008470924607332*Close[i+27+1]
-0.00941376204563632*Close[i+28+1]
-0.00885433738048246*Close[i+29+1]
-0.00711869639879854*Close[i+30+1]
-0.00465317542176635*Close[i+31+1]
-0.00194019707183346*Close[i+32+1]
+0.000579603884990088*Close[i+33+1]
+0.00256707017356023*Close[i+34+1]
+0.00381977207432852*Close[i+35+1]
+0.00428068634338846*Close[i+36+1]
+0.00402313632832263*Close[i+37+1]
+0.0032179506176373*Close[i+38+1]
+0.00209012998360153*Close[i+39+1]
+0.000874173133673174*Close[i+40+1]
-0.000224786383933042*Close[i+41+1]
-0.0010587336898008*Close[i+42+1]
-0.00155052433232022*Close[i+43+1]
-0.00169306769372935*Close[i+44+1]
-0.00153786701404679*Close[i+45+1]
-0.00117483219738423*Close[i+46+1]
-0.000710127079707358*Close[i+47+1]
-0.000243983404727185*Close[i+48+1]
+0.000144391315936508*Close[i+49+1]
+0.000408472741254023*Close[i+50+1]
+0.000535354473765889*Close[i+51+1]
+0.000542366420043941*Close[i+52+1]
+0.000469190409143627*Close[i+53+1]
+0.000367676722499057*Close[i+54+1]
-0.000413583883278278*Close[i+55+1];

value4=
0.0364298167208155*Close[i+0+1]
+0.0553906231378775*Close[i+1+1]
+0.0739088457518267*Close[i+2+1]
+0.0904000966980787*Close[i+3+1]
+0.103396797434432*Close[i+4+1]
+0.111711342284296*Close[i+5+1]
+0.114572120305459*Close[i+6+1]
+0.111711342284296*Close[i+7+1]
+0.103396797434432*Close[i+8+1]
+0.0904000966980787*Close[i+9+1]
+0.0739088457518267*Close[i+10+1]
+0.0553906231378775*Close[i+11+1]
+0.0364298167208155*Close[i+12+1]
+0.0185546919366474*Close[i+13+1]
+0.00307900283041587*Close[i+14+1]
-0.00902530529856102*Close[i+15+1]
-0.0172075327263682*Close[i+16+1]
-0.0213652751829327*Close[i+17+1]
-0.0218155170382955*Close[i+18+1]
-0.0192199347960543*Close[i+19+1]
-0.0144736414953281*Close[i+20+1]
-0.00857861481888381*Close[i+21+1]
-0.00251119869748709*Close[i+22+1]
+0.00288727595213947*Close[i+23+1]
+0.00699768244225111*Close[i+24+1]
+0.00946742032203178*Close[i+25+1]
+0.0102203545718079*Close[i+26+1]
+0.0094227060558747*Close[i+27+1]
+0.00743023076018664*Close[i+28+1]
+0.00471074990083792*Close[i+29+1]
+0.00175970399253971*Close[i+30+1]
-0.000967886100918518*Close[i+31+1]
-0.00311971586013391*Close[i+32+1]
-0.00447910708609257*Close[i+33+1]
-0.00497764414629577*Close[i+34+1]
-0.00468184137410999*Close[i+35+1]
-0.00376409954776387*Close[i+36+1]
-0.00246042456645472*Close[i+37+1]
-0.00102590341145799*Close[i+38+1]
+0.000306472786469948*Close[i+39+1]
+0.00135737038610145*Close[i+40+1]
+0.00201975214731277*Close[i+41+1]
+0.00226346631835387*Close[i+42+1]
+0.00212728353418576*Close[i+43+1]
+0.0017015315425756*Close[i+44+1]
+0.00110518230941413*Close[i+45+1]
+0.000462229952338165*Close[i+46+1]
-0.000118858605382952*Close[i+47+1]
-0.000559818649332224*Close[i+48+1]
-0.000819859088114563*Close[i+49+1]
-0.000895230669111811*Close[i+50+1]
-0.00081316637313982*Close[i+51+1]
-0.000621207183890965*Close[i+52+1]
-0.000375488554341561*Close[i+53+1]
-0.000129009269667756*Close[i+54+1]
+0.0000763487100123232*Close[i+55+1]
+0.000215985058849768*Close[i+56+1]
+0.000283075358142209*Close[i+57+1]
+0.000286783012231603*Close[i+58+1]
+0.000248090283379797*Close[i+59+1]
+0.000194413654881473*Close[i+60+1]
-0.000218687638971784*Close[i+61+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