Author: Copyright (c) 2005, goldenlion@ukr.net
i4_DRF_v2

This technical tool is designed to provide traders with a visual representation of price momentum by analyzing specific historical patterns in the market. Instead of looking at a single price point, the script evaluates the relationship between current prices and those from the recent past to determine the underlying "strength" or direction of the trend.

How the Logic Works

1. Data Processing Window The tool operates on a fixed timeframe defined by a specific period (set to 21 units by default). It scans back through the price history, ensuring there is enough historical data available before it begins its calculations to maintain accuracy.

2. The Comparison Mechanism The core logic relies on a comparative loop. For every point on the chart, the script looks at a specific window of recent price action (a 10-unit span). It compares the closing price of each bar in that window against the preceding bars.

3. Scoring System The indicator assigns a value to each comparison:

  • If the current price is higher than the previous price in the sequence, it registers as a positive movement.
  • If the current price is lower than the previous price, it registers as a negative movement.

By summing these results together, the script calculates a "net score." If there are more upward movements than downward ones within that window, the resulting value is positive; if there are more downward movements, the value becomes negative.

4. Visual Representation The final output is displayed in a separate window below your main price chart as a continuous line.

  • When the line moves above zero, it indicates that the recent price trend has a net upward bias.
  • When the line dips below zero, it suggests a net downward bias.
  • When the line sits at zero, it signifies a state of equilibrium where the upward and downward pressures are perfectly balanced.

Summary for Traders

Essentially, this tool acts as a momentum oscillator. It filters out minor market noise to show you whether the prevailing "mood" of the price action over the last 21 periods is leaning bullish, bearish, or neutral. It provides a mathematical way to see if the market is gaining strength in one direction or struggling against a counter-trend.

Miscellaneous
Implements a curve of type %1
16 Views
0 Downloads
0 Favorites
i4_DRF_v2
//+------------------------------------------------------------------+ 
//|                                                    i4_DRF_v2.mq4 | 
//|                                               goldenlion@ukr.net | 
//|                                      http://GlobeInvestFund.com/ | 
//+------------------------------------------------------------------+ 
#property copyright "Copyright (c) 2005, goldenlion@ukr.net" 
#property link      "http://GlobeInvestFund.com/" 

#property indicator_separate_window 

#property indicator_buffers 1 
#property indicator_color1 Red 

//---- input parameters 

//---- buffers 
double Buffer1[]; 

int MyPeriod = 21; 

//--------- 

//+------------------------------------------------------------------+ 
//| Custom indicator initialization function                         | 
//+------------------------------------------------------------------+ 
int init() 
  { 
   string short_name; 

//---- indicator line 
   SetIndexStyle(0,DRAW_LINE); 
   SetIndexBuffer(0,Buffer1); 

//---- name for DataWindow and indicator subwindow label 
   short_name="i4_DRF_v1.mq4("+MyPeriod+")"; 
   IndicatorShortName(short_name); 
   SetIndexLabel(0,short_name); 

//---- 
   SetIndexDrawBegin(0,0); 
    
//---- 
   return(0); 
  } 
  
//+------------------------------------------------------------------+ 
//|    
//+------------------------------------------------------------------+ 
int start() 
  { 
  int d, i, ii, counted_bars=IndicatorCounted(); 

//---- 
   if( Bars <= MyPeriod ) return(0); 
  
   ii=Bars-MyPeriod*1.1; 

   if( counted_bars >= MyPeriod ) ii=Bars-MyPeriod*1.1; 
    
   while( ii>=0 ) 
     { 
     d=0; 

     for( i=11 ; i < 21;  i++) 
       if( Close[ii] >= Close[ii+i] ) d=d+1; else d=d-1; 
        
     //if d=0 then d=0.0000001; 

     Buffer1[ii]=d; 

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

Comments