Author: Copyright 2002, Finware.ru Ltd.
DTM

This script functions as a sophisticated technical analysis tool designed to measure and visualize market momentum. Rather than using simple averages, it employs a complex mathematical approach to identify underlying trends by analyzing the relationship between historical price points.

Core Logic Overview

The indicator operates by calculating two distinct types of momentum values simultaneously, which are then subtracted from one another to create two unique visual lines on your chart:

1. The Fast Momentum Component (FTLM) This is derived by subtracting one complex calculation (value2) from another (value1).

  • value1 uses a specific weighting system over 65 past data points, giving different levels of importance to more recent prices versus older ones.
  • value2 applies an entirely different set of weights over a slightly different timeframe (74 data points).
  • Result: By subtracting these two values, the script creates a "Fast" line that reacts quickly to immediate shifts in price direction and volatility.

2. The Slow Momentum Component (STLM) This follows a similar logic but uses much more extensive data sets to determine its value.

  • value3 is calculated using a weighted sum of the last 64 data points.
  • value4 is significantly more comprehensive, calculating a weighted sum of the last 85 data points.
  • Result: By subtracting these two values, the script creates a "Slow" line. Because it considers a much wider window of historical data, this line represents the broader, long-term trend of the market.

Visual Representation and Usage

When you apply this script to your platform, it generates two lines in a separate window:

  • The Blue Line (Fast): Represents the "short-term" heartbeat of the market. It captures sudden moves and immediate momentum.
  • The Red Line (Slow): Represents the "long-term" momentum. It smooths out the noise to show where the price is heading over a larger duration.

By observing how these two lines interact—such as when the fast line crosses the slow line or when they diverge significantly—traders can attempt to identify potential turning points, trend strength, or upcoming shifts in market sentiment.

Miscellaneous
Implements a curve of type %1
12 Views
0 Downloads
0 Favorites
DTM
//+------------------------------------------------------------------+ 
//| Digital Twin Momentum.mq4 
//+------------------------------------------------------------------+ 
#property copyright "Copyright 2002, Finware.ru Ltd." 
#property link "http://www.finware.ru/" 

#property indicator_separate_window 
#property indicator_buffers 2 
#property indicator_color1 Blue 
#property indicator_color2 Red 

//---- buffers 
double FTLMBuffer[]; 
double STLMBuffer[]; 
double value1; 
double value2; 
double value3; 
double value4; 
//+------------------------------------------------------------------+ 
//| Custom indicator initialization function | 
//+------------------------------------------------------------------+ 
int init() 
{ 
string short_name; 
//---- indicator line 
IndicatorBuffers(2); 
SetIndexStyle(0,DRAW_LINE); 
SetIndexBuffer(0,STLMBuffer); 
SetIndexStyle(1,DRAW_LINE); 
SetIndexBuffer(1,FTLMBuffer); 
SetIndexDrawBegin(0,90); 
SetIndexDrawBegin(1,43); 
//---- 
return(0); 
} 
int start() 
{ 
int shift,counted_bars=IndicatorCounted(); 
if(counted_bars<43) 
{ 
for(shift=1;shift<=0;shift++) FTLMBuffer[Bars-shift]=0.0; 
for(shift=1;shift<=0;shift++) STLMBuffer[Bars-shift]=0.0; 
} 
//---- 
shift=Bars-43-1; 
if(counted_bars>=43) shift=Bars-counted_bars-1; 
while(shift>=0) 
{ 
value1 = 
0.112952*Close[shift+0] 
+0.111644*Close[shift+1] 
+0.109058*Close[shift+2] 
+0.105254*Close[shift+3] 
+0.100320*Close[shift+4] 
+0.094368*Close[shift+5] 
+0.087532*Close[shift+6] 
+0.079966*Close[shift+7] 
+0.071834*Close[shift+8] 
+0.063313*Close[shift+9] 
+0.054575*Close[shift+10] 
+0.045801*Close[shift+11] 
+0.037159*Close[shift+12] 
+0.028809*Close[shift+13] 
+0.020898*Close[shift+14] 
+0.013548*Close[shift+15] 
+0.006870*Close[shift+16] 
+0.000944*Close[shift+17] 
-0.004166*Close[shift+18] 
-0.008428*Close[shift+19] 
-0.011828*Close[shift+20] 
-0.014378*Close[shift+21] 
-0.016112*Close[shift+22] 
-0.017080*Close[shift+23] 
-0.017348*Close[shift+24] 
-0.016998*Close[shift+25] 
-0.016118*Close[shift+26] 
-0.014806*Close[shift+27] 
-0.013156*Close[shift+28] 
-0.011270*Close[shift+29] 
-0.009238*Close[shift+30] 
-0.007152*Close[shift+31] 
-0.005090*Close[shift+32] 
-0.003120*Close[shift+33] 
-0.001302*Close[shift+34] 
+0.000322*Close[shift+35] 
+0.001714*Close[shift+36] 
+0.002858*Close[shift+37] 
+0.003744*Close[shift+38] 
+0.004372*Close[shift+39] 
+0.004754*Close[shift+40] 
+0.004910*Close[shift+41] 
+0.004864*Close[shift+42] 
+0.004646*Close[shift+43] 
+0.004288*Close[shift+44] 
+0.003824*Close[shift+45] 
+0.003288*Close[shift+46] 
+0.002712*Close[shift+47] 
+0.002124*Close[shift+48] 
+0.001548*Close[shift+49] 
+0.001010*Close[shift+50] 
+0.000522*Close[shift+51] 
+0.000098*Close[shift+52] 
-0.000254*Close[shift+53] 
-0.000530*Close[shift+54] 
-0.000734*Close[shift+55] 
-0.000866*Close[shift+56] 
-0.000934*Close[shift+57] 
-0.000948*Close[shift+58] 
-0.000914*Close[shift+59] 
-0.000844*Close[shift+60] 
-0.000750*Close[shift+61] 
-0.000638*Close[shift+62] 
-0.000520*Close[shift+63] 
-0.000922*Close[shift+64]; 

value2 = 
0.038953*Close[shift+0] 
+0.042502*Close[shift+1] 
+0.045773*Close[shift+2] 
+0.048702*Close[shift+3] 
+0.051237*Close[shift+4] 
+0.053326*Close[shift+5] 
+0.054931*Close[shift+6] 
+0.056018*Close[shift+7] 
+0.056566*Close[shift+8] 
+0.056566*Close[shift+9] 
+0.056018*Close[shift+10] 
+0.054931*Close[shift+11] 
+0.053326*Close[shift+12] 
+0.051237*Close[shift+13] 
+0.048702*Close[shift+14] 
+0.045773*Close[shift+15] 
+0.042502*Close[shift+16] 
+0.038953*Close[shift+17] 
+0.035190*Close[shift+18] 
+0.031281*Close[shift+19] 
+0.027295*Close[shift+20] 
+0.023298*Close[shift+21] 
+0.019357*Close[shift+22] 
+0.015532*Close[shift+23] 
+0.011880*Close[shift+24] 
+0.008451*Close[shift+25] 
+0.005287*Close[shift+26] 
+0.002424*Close[shift+27] 
-0.000112*Close[shift+28] 
-0.002305*Close[shift+29] 
-0.004142*Close[shift+30] 
-0.005624*Close[shift+31] 
-0.006758*Close[shift+32] 
-0.007558*Close[shift+33] 
-0.008042*Close[shift+34] 
-0.008240*Close[shift+35] 
-0.008177*Close[shift+36] 
-0.007890*Close[shift+37] 
-0.007415*Close[shift+38] 
-0.006786*Close[shift+39] 
-0.006041*Close[shift+40] 
-0.005219*Close[shift+41] 
-0.004349*Close[shift+42] 
-0.003466*Close[shift+43] 
-0.002596*Close[shift+44] 
-0.001764*Close[shift+45] 
-0.000991*Close[shift+46] 
-0.000294*Close[shift+47] 
+0.000318*Close[shift+48] 
+0.000835*Close[shift+49] 
+0.001254*Close[shift+50] 
+0.001575*Close[shift+51] 
+0.001801*Close[shift+52] 
+0.001937*Close[shift+53] 
+0.001993*Close[shift+54] 
+0.001978*Close[shift+55] 
+0.001902*Close[shift+56] 
+0.001777*Close[shift+57] 
+0.001616*Close[shift+58] 
+0.001428*Close[shift+59] 
+0.001228*Close[shift+60] 
+0.001020*Close[shift+61] 
+0.000816*Close[shift+62] 
+0.000622*Close[shift+63] 
+0.000445*Close[shift+64] 
+0.000287*Close[shift+65] 
+0.000154*Close[shift+66] 
+0.000045*Close[shift+67] 
-0.000040*Close[shift+68] 
-0.000100*Close[shift+69] 
-0.000139*Close[shift+70] 
-0.000159*Close[shift+71] 
-0.000161*Close[shift+72] 
-0.000672*Close[shift+73]; 

value3 = 
0.0729811286*Close[shift+0] 
+0.0727839290*Close[shift+1] 
+0.0721970455*Close[shift+2] 
+0.0712248998*Close[shift+3] 
+0.0698810899*Close[shift+4] 
+0.0681787637*Close[shift+5] 
+0.0661384062*Close[shift+6] 
+0.0637836328*Close[shift+7] 
+0.0611379416*Close[shift+8] 
+0.0582328720*Close[shift+9] 
+0.0551006677*Close[shift+10] 
+0.0517729856*Close[shift+11] 
+0.0482864520*Close[shift+12] 
+0.0446761673*Close[shift+13] 
+0.0409807341*Close[shift+14] 
+0.0372349199*Close[shift+15] 
+0.0334766035*Close[shift+16] 
+0.0297389677*Close[shift+17] 
+0.0260572889*Close[shift+18] 
+0.0224620500*Close[shift+19] 
+0.0189846476*Close[shift+20] 
+0.0156508337*Close[shift+21] 
+0.0124844115*Close[shift+22] 
+0.0095064451*Close[shift+23] 
+0.0067348956*Close[shift+24] 
+0.0041825353*Close[shift+25] 
+0.0018620649*Close[shift+26] 
-0.0002214306*Close[shift+27] 
-0.0020618579*Close[shift+28] 
-0.0036612349*Close[shift+29] 
-0.0050199184*Close[shift+30] 
-0.0061460477*Close[shift+31] 
-0.0070453847*Close[shift+32] 
-0.0077311361*Close[shift+33] 
-0.0082154598*Close[shift+34] 
-0.0085069196*Close[shift+35] 
-0.0086364464*Close[shift+36] 
-0.0086063959*Close[shift+37] 
-0.0084385053*Close[shift+38] 
-0.0081544217*Close[shift+39] 
-0.0077720532*Close[shift+40] 
-0.0073096701*Close[shift+41] 
-0.0067829639*Close[shift+42] 
-0.0062100031*Close[shift+43] 
-0.0056056555*Close[shift+44] 
-0.0049866671*Close[shift+45] 
-0.0043657084*Close[shift+46] 
-0.0037560684*Close[shift+47] 
-0.0031670013*Close[shift+48] 
-0.0026079202*Close[shift+49] 
-0.0020858529*Close[shift+50] 
-0.0016064640*Close[shift+51] 
-0.0011734916*Close[shift+52] 
-0.0007908741*Close[shift+53] 
-0.0004588212*Close[shift+54] 
-0.0001790390*Close[shift+55] 
+0.0000510113*Close[shift+56] 
+0.0002315881*Close[shift+57] 
+0.0003671215*Close[shift+58] 
+0.0004595615*Close[shift+59] 
+0.0005144014*Close[shift+60] 
+0.0005345365*Close[shift+61] 
+0.0005256791*Close[shift+62] 
+0.0028871340*Close[shift+63]; 

value4 = 
0.0077174463*Close[shift+0] 
+0.0093613543*Close[shift+1] 
+0.0110760659*Close[shift+2] 
+0.0128488828*Close[shift+3] 
+0.0146643234*Close[shift+4] 
+0.0165073564*Close[shift+5] 
+0.0183605871*Close[shift+6] 
+0.0202076529*Close[shift+7] 
+0.0220298758*Close[shift+8] 
+0.0238101118*Close[shift+9] 
+0.0255293260*Close[shift+10] 
+0.0271702104*Close[shift+11] 
+0.0287147044*Close[shift+12] 
+0.0301471980*Close[shift+13] 
+0.0314517917*Close[shift+14] 
+0.0326129335*Close[shift+15] 
+0.0336190364*Close[shift+16] 
+0.0344584557*Close[shift+17] 
+0.0351210901*Close[shift+18] 
+0.0356004564*Close[shift+19] 
+0.0358898494*Close[shift+20] 
+0.0359870888*Close[shift+21] 
+0.0358898494*Close[shift+22] 
+0.0356004564*Close[shift+23] 
+0.0351210901*Close[shift+24] 
+0.0344584557*Close[shift+25] 
+0.0336190364*Close[shift+26] 
+0.0326129335*Close[shift+27] 
+0.0314517917*Close[shift+28] 
+0.0301471980*Close[shift+29] 
+0.0287147044*Close[shift+30] 
+0.0271702104*Close[shift+31] 
+0.0255293260*Close[shift+32] 
+0.0238101118*Close[shift+33] 
+0.0220298758*Close[shift+34] 
+0.0202076529*Close[shift+35] 
+0.0183605871*Close[shift+36] 
+0.0165073564*Close[shift+37] 
+0.0146643234*Close[shift+38] 
+0.0128488828*Close[shift+39] 
+0.0110760659*Close[shift+40] 
+0.0093613543*Close[shift+41] 
+0.0077174463*Close[shift+42] 
+0.0061560794*Close[shift+43] 
+0.0046876404*Close[shift+44] 
+0.0033209857*Close[shift+45] 
+0.0020624135*Close[shift+46] 
+0.0009181866*Close[shift+47] 
-0.0001091877*Close[shift+48] 
-0.0010167048*Close[shift+49] 
-0.0018053597*Close[shift+50] 
-0.0024753283*Close[shift+51] 
-0.0030306241*Close[shift+52] 
-0.0034740883*Close[shift+53] 
-0.0038122332*Close[shift+54] 
-0.0040510538*Close[shift+55] 
-0.0041947730*Close[shift+56] 
-0.0042586429*Close[shift+57] 
-0.0042438250*Close[shift+58] 
-0.0041610379*Close[shift+59] 
-0.0040209559*Close[shift+60] 
-0.0038324095*Close[shift+61] 
-0.0036044078*Close[shift+62] 
-0.0033446882*Close[shift+63] 
-0.0030621605*Close[shift+64] 
-0.0027641559*Close[shift+65] 
-0.0024589320*Close[shift+66] 
-0.0021527365*Close[shift+67] 
-0.0018521222*Close[shift+68] 
-0.0015616524*Close[shift+69] 
-0.0012859688*Close[shift+70] 
-0.0010285368*Close[shift+71] 
-0.0007921495*Close[shift+72] 
-0.0005786502*Close[shift+73] 
-0.0003899810*Close[shift+74] 
-0.0002262453*Close[shift+75] 
-0.0000882844*Close[shift+76] 
+0.0000251537*Close[shift+77] 
+0.0001141964*Close[shift+78] 
+0.0001810281*Close[shift+79] 
+0.0002266104*Close[shift+80] 
+0.0002536520*Close[shift+81] 
+0.0002635807*Close[shift+82] 
+0.0002592130*Close[shift+83] 
+0.0014236495*Close[shift+84]; 


STLMBuffer[shift] = value3-value4; 
FTLMBuffer[shift] = value1-value2; 

shift--; 
} 
return(0); 
} 
//+------------------------------------------------------------------+ 

Comments