digitalf-t01
Download scriptOverview of DigitalF-T01 Logic
The DigitalF-T01 is a sophisticated technical analysis indicator designed to filter market noise and identify specific price reaction levels. It functions by combining a multi-layered digital smoothing filter with a dynamic "trigger" mechanism that adjusts based on historical time cycles.
Here is a breakdown of the logic in non-technical terms:
1. The Core Filtering Engine (Digital Filter)
The primary component of this script is a high-precision digital filter. Instead of simply looking at the current price, the indicator analyzes a specific sequence of past data points (a window of 24 previous bars).
Each of these past points is assigned a unique mathematical weight—some are positive, while others are negative. By combining these weighted values, the script creates a "smoothed" trend line. This approach allows the indicator to react to the underlying momentum of the market while ignoring minor, insignificant fluctuations in price.
2. Dynamic Price Input Selection
The script is highly versatile regarding the type of data it monitors. Users can choose which price point to feed into the filter. While the default is the "Closing Price," the logic supports various other metrics including:
- Standard Prices: Open, High, Low, and Typical prices.
- Custom Calculations: Median, Weighted, Simpl, and Quartered prices.
- Advanced Trend-Following Prices: Specialized logic that switches between High, Low, or Mid-point prices based on whether the current bar's candle is bullish (up) or bearish (down).
3. The Trigger Mechanism
Once the primary filtered line is established, the script calculates a secondary "Trigger" line. This is where the indicator becomes unique:
- Time-Based Lookback: The script calculates a specific historical offset based on the time of day. It looks back to a specific point in the past (based on hourly/minute increments) to find a reference price.
- Comparison Logic: The script compares the current filtered value against that historical reference price.
- Dynamic Offsets: Depending on whether the current filtered value is higher or lower than that historical point, the Trigger line will project either above or below that point by a user-defined "half-channel" distance.
4. Visual Representation
The indicator provides three distinct visual elements on the chart:
- Main Line: A solid curve representing the smoothed digital filter.
- Trigger Line: A secondary line (usually highlighted in red) that marks the calculated reaction zone.
- Cloud Filling: The area between the main filtered line and the trigger line is filled with a two-tone color gradient (Pale Green and Hot Pink). This "cloud" provides a visual representation of the volatility or "zone" between the trend and the trigger, making it easier for a user to identify potential areas of interest or price equilibrium.
Summary for the User
In essence, this tool tells you where the market is "supposed" to be based on complex historical weighting (the Cloud/Main Line) and provides a specific reaction point (the Trigger) relative to historical time cycles. It is designed to help traders see past the "messiness" of live price action to find cleaner structural signals.
//+------------------------------------------------------------------+
//| DigitalF-T01.mq5 |
//| Copyright © 2006, XXX |
//| |
//+------------------------------------------------------------------+
//---- àâòîðñòâî èíäèêàòîðà
#property copyright "Copyright © 2006, XXX"
//---- àâòîðñòâî èíäèêàòîðà
#property link ""
//---- íîìåð âåðñèè èíäèêàòîðà
#property version "1.00"
//---- îòðèñîâêà èíäèêàòîðà â îòäåëüíîì îêíå
#property indicator_separate_window
//---- äëÿ ðàñ÷åòà è îòðèñîâêè èíäèêàòîðà èñïîëüçîâàíî ÷åòûðå áóôåðà
#property indicator_buffers 4
//---- èñïîëüçîâàíî òðè ãðàôè÷åñêèõ ïîñòðîåíèÿ
#property indicator_plots 3
//+----------------------------------------------+
//| Ïàðàìåòðû îòðèñîâêè èíäèêàòîðà DigitalF-T01 |
//+----------------------------------------------+
//---- îòðèñîâêà èíäèêàòîðà 1 â âèäå ëèíèè
#property indicator_type1 DRAW_LINE
//---- â êà÷åñòâå öâåòà îñíîâíîé ëèíèè èíäèêàòîðà èñïîëüçîâàí öâåò DarkOrchid
#property indicator_color1 clrDarkOrchid
//---- ëèíèÿ èíäèêàòîðà 1 - íåïðåðûâíàÿ êðèâàÿ
#property indicator_style1 STYLE_SOLID
//---- òîëùèíà ëèíèè èíäèêàòîðà 1 ðàâíà 2
#property indicator_width1 2
//---- îòîáðàæåíèå ìåòêè ëèíèè èíäèêàòîðà
#property indicator_label1 "DigitalF-T01"
//+----------------------------------------------+
//| Ïàðàìåòðû îòðèñîâêè èíäèêàòîðà Trigger |
//+----------------------------------------------+
//---- îòðèñîâêà èíäèêàòîðà 2 â âèäå ëèíèè
#property indicator_type2 DRAW_LINE
//---- â êà÷åñòâå öâåòà ñèãíàëüíîé ëèíèè èíäèêàòîðà èñïîëüçîâàí öâåò Red
#property indicator_color2 clrRed
//---- ëèíèÿ èíäèêàòîðà 2 - íåïðåðûâíàÿ êðèâàÿ
#property indicator_style2 STYLE_SOLID
//---- òîëùèíà ëèíèè èíäèêàòîðà 2 ðàâíà 2
#property indicator_width2 2
//---- îòîáðàæåíèå ìåòêè ëèíèè èíäèêàòîðà
#property indicator_label2 "Trigger"
//+----------------------------------------------+
//| Ïàðàìåòðû îòðèñîâêè îáëàêà |
//+----------------------------------------------+
//---- îòðèñîâêà èíäèêàòîðà â âèäå öâåòíîãî îáëàêà
#property indicator_type3 DRAW_FILLING
//---- â êà÷åñòâå öâåòîâ èíäèêàòîðà èñïîëüçîâàíû
#property indicator_color3 clrPaleGreen,clrHotPink
//+----------------------------------------------+
//| Îáúÿâëåíèå ïåðå÷èñëåíèÿ |
//+----------------------------------------------+
enum Applied_price_ //Òèï êîíñòàíòû
{
PRICE_CLOSE_ = 1, //Close
PRICE_OPEN_, //Open
PRICE_HIGH_, //High
PRICE_LOW_, //Low
PRICE_MEDIAN_, //Median Price (HL/2)
PRICE_TYPICAL_, //Typical Price (HLC/3)
PRICE_WEIGHTED_, //Weighted Close (HLCC/4)
PRICE_SIMPL_, //Simpl Price (OC/2)
PRICE_QUARTER_, //Quarted Price (HLOC/4)
PRICE_TRENDFOLLOW0_, //TrendFollow_1 Price
PRICE_TRENDFOLLOW1_, //TrendFollow_2 Price
PRICE_DEMARK_ //Demark Price
};
//+----------------------------------------------+
//| Âõîäíûå ïàðàìåòðû èíäèêàòîðà |
//+----------------------------------------------+
input uint halfchanel=25; // Êîýôôèöèåíò ñðàáàòûâàíèÿ òðèãåðà
input Applied_price_ IPC=PRICE_CLOSE_;// Öåíîâàÿ êîíñòàíòà
input int Shift=0; // Ñäâèã èíäèêàòîðà ïî ãîðèçîíòàëè â áàðàõ
//+----------------------------------------------+
//---- îáúÿâëåíèå äèíàìè÷åñêèõ ìàññèâîâ, êîòîðûå â äàëüíåéøåì
//---- áóäóò èñïîëüçîâàíû â êà÷åñòâå èíäèêàòîðíûõ áóôåðîâ
double DigBuffer[];
double TriggerBuffer[];
double UpBuffer[];
double DnBuffer[];
//----
double dHalfchanel;
//---- îáúÿâëåíèå öåëî÷èñëåííûõ ïåðåìåííûõ íà÷àëà îòñ÷åòà äàííûõ
int min_rates_total;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void OnInit()
{
//---- èíèöèàëèçàöèÿ ïåðåìåííûõ íà÷àëà îòñ÷åòà äàííûõ
min_rates_total=24;
int sh=int(MathRound(60*(23*60+59)/PeriodSeconds())+1);
min_rates_total=MathMax(min_rates_total,sh);
dHalfchanel=halfchanel*_Point;
//---- ïðåâðàùåíèå äèíàìè÷åñêîãî ìàññèâà DigBuffer[] â èíäèêàòîðíûé áóôåð
SetIndexBuffer(0,DigBuffer,INDICATOR_DATA);
//---- îñóùåñòâëåíèå ñäâèãà èíäèêàòîðà 1 ïî ãîðèçîíòàëè íà Shift
PlotIndexSetInteger(0,PLOT_SHIFT,Shift);
//---- îñóùåñòâëåíèå ñäâèãà íà÷àëà îòñ÷åòà îòðèñîâêè èíäèêàòîðà 1 íà min_rates_total
PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,min_rates_total);
//---- óñòàíîâêà çíà÷åíèé èíäèêàòîðà, êîòîðûå íå áóäóò âèäèìû íà ãðàôèêå
PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,EMPTY_VALUE);
//---- ïðåâðàùåíèå äèíàìè÷åñêîãî ìàññèâà TriggerBuffer[] â èíäèêàòîðíûé áóôåð
SetIndexBuffer(1,TriggerBuffer,INDICATOR_DATA);
//---- îñóùåñòâëåíèå ñäâèãà èíäèêàòîðà 2 ïî ãîðèçîíòàëè íà Shift
PlotIndexSetInteger(1,PLOT_SHIFT,Shift);
//---- îñóùåñòâëåíèå ñäâèãà íà÷àëà îòñ÷åòà îòðèñîâêè èíäèêàòîðà 2 íà min_rates_total
PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,min_rates_total+1);
//---- óñòàíîâêà çíà÷åíèé èíäèêàòîðà, êîòîðûå íå áóäóò âèäèìû íà ãðàôèêå
PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,EMPTY_VALUE);
//---- ïðåâðàùåíèå äèíàìè÷åñêîãî ìàññèâà UpBuffer[] â èíäèêàòîðíûé áóôåð
SetIndexBuffer(2,UpBuffer,INDICATOR_DATA);
//---- îñóùåñòâëåíèå ñäâèãà èíäèêàòîðà 1 ïî ãîðèçîíòàëè íà Shift
PlotIndexSetInteger(2,PLOT_SHIFT,Shift);
//---- îñóùåñòâëåíèå ñäâèãà íà÷àëà îòñ÷åòà îòðèñîâêè èíäèêàòîðà 1 íà min_rates_total
PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,min_rates_total);
//---- óñòàíîâêà çíà÷åíèé èíäèêàòîðà, êîòîðûå íå áóäóò âèäèìû íà ãðàôèêå
PlotIndexSetDouble(2,PLOT_EMPTY_VALUE,EMPTY_VALUE);
//---- ïðåâðàùåíèå äèíàìè÷åñêîãî ìàññèâà DnBuffer[] â èíäèêàòîðíûé áóôåð
SetIndexBuffer(3,DnBuffer,INDICATOR_DATA);
//---- îñóùåñòâëåíèå ñäâèãà èíäèêàòîðà 1 ïî ãîðèçîíòàëè íà Shift
PlotIndexSetInteger(3,PLOT_SHIFT,Shift);
//---- îñóùåñòâëåíèå ñäâèãà íà÷àëà îòñ÷åòà îòðèñîâêè èíäèêàòîðà 1 íà min_rates_total
PlotIndexSetInteger(3,PLOT_DRAW_BEGIN,min_rates_total);
//---- óñòàíîâêà çíà÷åíèé èíäèêàòîðà, êîòîðûå íå áóäóò âèäèìû íà ãðàôèêå
PlotIndexSetDouble(3,PLOT_EMPTY_VALUE,EMPTY_VALUE);
//---- èíèöèàëèçàöèÿ ïåðåìåííîé äëÿ êîðîòêîãî èìåíè èíäèêàòîðà
string shortname;
StringConcatenate(shortname,"DigitalF-T01(",halfchanel,", ",EnumToString(IPC),", ",Shift,")");
//---- ñîçäàíèå èìåíè äëÿ îòîáðàæåíèÿ â îòäåëüíîì ïîäîêíå è âî âñïëûâàþùåé ïîäñêàçêå
IndicatorSetString(INDICATOR_SHORTNAME,shortname);
//---- îïðåäåëåíèå òî÷íîñòè îòîáðàæåíèÿ çíà÷åíèé èíäèêàòîðà
IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total, // êîëè÷åñòâî èñòîðèè â áàðàõ íà òåêóùåì òèêå
const int prev_calculated,// êîëè÷åñòâî èñòîðèè â áàðàõ íà ïðåäûäóùåì òèêå
const datetime &time[],
const double &open[],
const double& high[], // öåíîâîé ìàññèâ ìàêñèìóìîâ öåíû äëÿ ðàñ÷åòà èíäèêàòîðà
const double& low[], // öåíîâîé ìàññèâ ìèíèìóìîâ öåíû äëÿ ðàñ÷åòà èíäèêàòîðà
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//---- ïðîâåðêà êîëè÷åñòâà áàðîâ íà äîñòàòî÷íîñòü äëÿ ðàñ÷åòà
if(rates_total<min_rates_total) return(0);
//---- îáúÿâëåíèÿ ëîêàëüíûõ ïåðåìåííûõ
int first,bar;
//---- ðàñ÷åò ñòàðòîâîãî íîìåðà first äëÿ öèêëà ïåðåñ÷åòà áàðîâ
if(prev_calculated>rates_total || prev_calculated<=0) // ïðîâåðêà íà ïåðâûé ñòàðò ðàñ÷åòà èíäèêàòîðà
first=24; // ñòàðòîâûé íîìåð äëÿ ðàñ÷åòà âñåõ áàðîâ
else first=prev_calculated-1; // ñòàðòîâûé íîìåð äëÿ ðàñ÷åòà íîâûõ áàðîâ
//---- îñíîâíîé öèêë ðàñ÷åòà öèôðîâîãî ôèëüòðà
for(bar=first; bar<rates_total && !IsStopped(); bar++)
{
DigBuffer[bar]=
0.24470985659780*PriceSeries(IPC,bar,open,low,high,close)
+0.23139774006970*PriceSeries(IPC,bar-1,open,low,high,close)
+0.20613796947320*PriceSeries(IPC,bar-2,open,low,high,close)
+0.17166230340640*PriceSeries(IPC,bar-3,open,low,high,close)
+0.13146907903600*PriceSeries(IPC,bar-4,open,low,high,close)
+0.08950387549560*PriceSeries(IPC,bar-5,open,low,high,close)
+0.04960091651250*PriceSeries(IPC,bar-6,open,low,high,close)
+0.01502270569607*PriceSeries(IPC,bar-7,open,low,high,close)
-0.01188033734430*PriceSeries(IPC,bar-8,open,low,high,close)
-0.02989873856137*PriceSeries(IPC,bar-9,open,low,high,close)
-0.03898967104900*PriceSeries(IPC,bar-10,open,low,high,close)
-0.04014113626390*PriceSeries(IPC,bar-11,open,low,high,close)
-0.03511968085800*PriceSeries(IPC,bar-12,open,low,high,close)
-0.02611613850342*PriceSeries(IPC,bar-13,open,low,high,close)
-0.01539056955666*PriceSeries(IPC,bar-14,open,low,high,close)
-0.00495353651394*PriceSeries(IPC,bar-15,open,low,high,close)
+0.00368588764825*PriceSeries(IPC,bar-16,open,low,high,close)
+0.00963614049782*PriceSeries(IPC,bar-17,open,low,high,close)
+0.01265138888314*PriceSeries(IPC,bar-18,open,low,high,close)
+0.01307496106868*PriceSeries(IPC,bar-19,open,low,high,close)
+0.01169702291063*PriceSeries(IPC,bar-20,open,low,high,close)
+0.00974841844086*PriceSeries(IPC,bar-21,open,low,high,close)
+0.00898900012545*PriceSeries(IPC,bar-22,open,low,high,close)
-0.00649745721156*PriceSeries(IPC,bar-23,open,low,high,close);
}
if(prev_calculated>rates_total || prev_calculated<=0) first=min_rates_total;
//---- îñíîâíîé öèêë ðàñ÷åòà òðèãåðíîé ëèíèè
for(bar=first; bar<rates_total && !IsStopped(); bar++)
{
MqlDateTime tm;
TimeToStruct(time[bar],tm);
int per=int(MathRound(60*(tm.hour*60+tm.min)/PeriodSeconds())+1);
int barX=bar-per;
if(DigBuffer[bar]>=close[barX]) TriggerBuffer[bar]=close[barX]+dHalfchanel;
if(DigBuffer[bar]<close[barX]) TriggerBuffer[bar]=close[barX]-dHalfchanel;
UpBuffer[bar]=DigBuffer[bar];
DnBuffer[bar]=TriggerBuffer[bar];
}
//----
return(rates_total);
}
//+------------------------------------------------------------------+
//| Ïîëó÷åíèå çíà÷åíèÿ öåíîâîé òàéìñåðèè |
//+------------------------------------------------------------------+
double PriceSeries(uint applied_price,// öåíîâàÿ êîíñòàíòà
uint bar,// èíäåêñ ñäâèãà îòíîñèòåëüíî òåêóùåãî áàðà íà óêàçàííîå êîëè÷åñòâî ïåðèîäîâ íàçàä èëè âïåðåä).
const double &Open[],
const double &Low[],
const double &High[],
const double &Close[])
{
//----
switch(applied_price)
{
//---- öåíîâûå êîíñòàíòû èç ïåðå÷èñëåíèÿ ENUM_APPLIED_PRICE
case PRICE_CLOSE: return(Close[bar]);
case PRICE_OPEN: return(Open [bar]);
case PRICE_HIGH: return(High [bar]);
case PRICE_LOW: return(Low[bar]);
case PRICE_MEDIAN: return((High[bar]+Low[bar])/2.0);
case PRICE_TYPICAL: return((Close[bar]+High[bar]+Low[bar])/3.0);
case PRICE_WEIGHTED: return((2*Close[bar]+High[bar]+Low[bar])/4.0);
//----
case 8: return((Open[bar] + Close[bar])/2.0); // PRICE_SIMPL_
case 9: return((Open[bar] + Close[bar] + High[bar] + Low[bar])/4.0); // PRICE_QUARTER_
//----
case 10: // PRICE_TRENDFOLLOW0_
{
if(Close[bar]>Open[bar])return(High[bar]);
else
{
if(Close[bar]<Open[bar])
return(Low[bar]);
else return(Close[bar]);
}
}
//----
case 11: // PRICE_TRENDFOLLOW1_
{
if(Close[bar]>Open[bar])return((High[bar]+Close[bar])/2.0);
else
{
if(Close[bar]<Open[bar])
return((Low[bar]+Close[bar])/2.0);
else return(Close[bar]);
}
break;
}
//----
case 12: // PRICE_DEMARK_
{
double res=High[bar]+Low[bar]+Close[bar];
//----
if(Close[bar]<Open[bar]) res=(res+Low[bar])/2;
if(Close[bar]>Open[bar]) res=(res+High[bar])/2;
if(Close[bar]==Open[bar]) res=(res+Close[bar])/2;
return(((res-Low[bar])+(res-High[bar]))/2);
}
//----
default: return(Close[bar]);
}
//----
//return(0);
}
//+------------------------------------------------------------------+
Comments