DigitalF-T01_v1
Download scriptThis tool is a technical analysis indicator designed to provide visual data on price trends within the MetaTrader platform. It operates by analyzing historical price movements and projecting specific data points onto a separate viewing window for easier interpretation.
Core Logic and Functionality
Data Processing and Calculation The script functions by scanning a specific history of recent price candles (defined by a user-set count). For every candle in this range, the tool performs a complex weighted calculation. It looks at 24 consecutive previous closing prices and applies a unique mathematical coefficient to each one. This means that some past prices have a much stronger influence on the current result than others, allowing the tool to filter out "noise" and identify underlying momentum.
Dynamic Visual Output The script generates two distinct visual lines:
- The Primary Value: This represents the result of the complex weighted calculation mentioned above. It tracks the smoothed trend of the asset.
- The Reference Line: This line serves as a dynamic benchmark. The tool identifies the current price at a specific time interval (calculated based on the current hour and minute relative to the chart period) and creates a boundary.
Dynamic Positioning The script determines the placement of the reference line by comparing the calculated trend value against the actual market price:
- If the calculated trend is higher than the current price, the reference line is placed slightly above the price.
- If the calculated trend is lower than the current price, the reference line is placed slightly below the price.
Summary of Behavior
In essence, this script acts as a momentum tracker. It sifts through historical data to produce a smoothed trend value and then automatically plots that value alongside a dynamic "buffer" zone. This allows traders to visually observe the relationship between weighted historical momentum and real-time market pricing.
//+------------------------------------------------------------------+
//| DigitalF-T01.mq4 |
//| Copyright © 2006, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
//----
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red
//----
extern int CountBars=300;
extern int halfchanel=25;
//----
double buf1[];
double buf2[];
//----
bool FirstTime=True;
int AccountedBars=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,buf1);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,buf2);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int shift,per;
double digf,draw;
//----
per=MathRound((Hour()*60+Minute())/Period())+1;
if(FirstTime)
{
AccountedBars=CountBars;
FirstTime=False;
}
for(shift=AccountedBars;shift>=0;shift--)
{
digf=
0.2447098565978*Close[shift]
+0.2313977400697*Close[shift+1]
+0.2061379694732*Close[shift+2]
+0.1716623034064*Close[shift+3]
+0.1314690790360*Close[shift+4]
+0.0895038754956*Close[shift+5]
+0.0496009165125*Close[shift+6]
+0.01502270569607*Close[shift+7]
-0.01188033734430*Close[shift+8]
-0.02989873856137*Close[shift+9]
-0.0389896710490*Close[shift+10]
-0.0401411362639*Close[shift+11]
-0.0351196808580*Close[shift+12]
-0.02611613850342*Close[shift+13]
-0.01539056955666*Close[shift+14]
-0.00495353651394*Close[shift+15]
+0.00368588764825*Close[shift+16]
+0.00963614049782*Close[shift+17]
+0.01265138888314*Close[shift+18]
+0.01307496106868*Close[shift+19]
+0.01169702291063*Close[shift+20]
+0.00974841844086*Close[shift+21]
+0.00898900012545*Close[shift+22]
-0.00649745721156*Close[shift+23];
//----
buf1[shift]=digf;
if(digf>=Close[per]) draw=Close[per]+halfchanel*Point;
if(digf<Close[per]) draw=Close[per]-halfchanel*Point;
buf2[shift]=draw;
if(shift>0) AccountedBars=AccountedBars-1;
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments