i4_DRF_v2_v1

Download script
Author: Copyright (c) 2005, goldenlion@ukr.net
i4_DRF_v2_v1

This tool is designed as a visual indicator for MetaTrader platforms, specifically created to help traders identify momentum and price trends by analyzing the relationship between current prices and historical price points over a specific timeframe.

Core Logic Overview

The script functions by scanning the market history to calculate a "momentum score." Instead of simply looking at where the price is moving in the immediate second, it evaluates the position of the most recent closing prices against a window of previous closing prices (defined by a specific lookback period).

How the Calculation Works

The logic follows a systematic three-step process:

  1. Data Collection: The script looks back at a set number of historical bars (the default is 21). It focuses on the closing prices of these candles to determine the "strength" of the current movement.
  2. Comparative Analysis: For every point in time, the script performs a series of comparisons. It compares the price of a specific candle against several preceding candles within that window.
    • If the price is higher than the previous candle, it registers as a positive move (incrementing a value).
    • If the price is lower than the previous candle, it registers as a negative move (decrementing a value).
  3. Resulting Visualization: The final result is a numerical value representing the net difference between these "ups" and "downs." This result is then plotted on a separate window below your main trading chart as a red line.

What This Tells the Trader

The resulting line acts as a trend sentiment indicator:

  • Positive Values: When the line moves upward, it suggests that, over the analyzed period, the price has consistently closed higher than its immediate predecessors, indicating bullish momentum.
  • Negative Values: When the line moves downward, it suggests that prices have been consistently closing lower, indicating bearish momentum.
  • Neutrality: When the line hovers near zero, it indicates a lack of clear directional trend, where upward and downward movements are balancing each other out.

By observing the fluctuations of this red line, a trader can better visualize whether the current market trend is strengthening, weakening, or reaching a point of equilibrium.

Miscellaneous
Implements a curve of type %1
16 Views
0 Downloads
0 Favorites
i4_DRF_v2_v1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+ 
//|                                                    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