DigitalF-T01

Download script
Author: Copyright � 2006, MetaQuotes Software Corp.
DigitalF-T01

This custom technical indicator is designed to provide traders with a visual representation of market momentum and price trends by processing historical data into two distinct, color-coded lines.

Core Functionality

The script analyzes the closing prices of a specific number of past candles (defaulting to 300) to calculate a smoothed price trend. It achieves this by applying a specific weighted mathematical formula to the most recent 24 price points. By assigning different weights to each of these previous closes, the indicator filters out minor market noise to reveal an underlying "digital" trend value.

Visual Components

The tool displays two separate lines on a dedicated window below the main price chart:

  • Primary Trend Line (Lime): This represents the calculated moving average based on the weighted formula described above. It serves as the primary indicator of where the "weighted" price is heading at any given moment.
  • Secondary Comparison Line (Red): This line acts as a dynamic reference point. The script determines this value by looking at the current price relative to the calculated trend.
    • If the calculated trend is higher than the current price, the red line appears slightly below the current price.
    • If the calculated trend is lower than the current price, the red line appears slightly above it.

Key Logic Highlights

  • Time-Aware Scaling: The indicator incorporates a calculation based on the current time of day and the chart's timeframe to help position its reference points accurately within the market cycle.
  • Historical Memory: Upon loading, the script establishes a "memory" of the past 300 bars. As new data arrives, it systematically updates this memory, moving forward one bar at a time to ensure the trend remains fluid and responsive to live price action.
  • Precision Positioning: The relationship between the two lines is governed by a specific offset (halfchannel), ensuring that the visual gap between the trend and the reference price remains consistent for easier interpretation by the user.

In summary, this script helps traders visualize the discrepancy between the "weighted" market trend and the actual current price, allowing for a clearer view of potential momentum shifts.

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