VininI_Trend_V7

Download script
Author: Victor Nicolaev
VininI_Trend_V7

This tool is designed as a visual trading indicator that analyzes price movement trends to help identify potential market directions. Instead of simply following the current price, the logic focuses on calculating a weighted momentum average to filter out "noise" and highlight the underlying flow of the market.

How the Logic Works

1. Weighted Data Processing The script begins by performing a deep calculation of historical price data. Unlike a standard moving average that might give equal importance to all past prices, this logic applies a weighted calculation. It looks back over a significant number of data points (determined by the "Count" setting) and calculates a value based on the distance of those prices from the current closing point. This helps the indicator prioritize more relevant historical data over older, less significant information.

2. Trend Smoothing Once the weighted data is processed, the script applies a second layer of smoothing (a Simple Moving Average). This step is crucial because it removes minor, erratic price fluctuations, leaving behind a cleaner "trend line." By looking at this smoothed data, the tool identifies the primary direction in which the market is moving.

3. Directional Detection The final stage of the logic compares the current smoothed value against the previous one.

  • Upward Momentum: If the current trend value is higher than the previous one, the script registers this as upward momentum and displays it as a green histogram.
  • Downward Momentum: If the current trend value is lower than the previous one, the script identifies it as downward momentum and displays it as a red histogram.

Summary for the User

In simple terms, this indicator acts as a "momentum filter." It takes a large amount of historical price data, weights it to find the most important trends, smooths out the jagged movements of the market, and then tells you whether that trend is currently climbing or falling. The resulting visual helps you see whether the market is gaining strength in one direction or losing it in another.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
VininI_Trend_V7
//+------------------------------------------------------------------+
//|                                             Vinin HighLow v1.mq4 |
//|                                                  Victor Nicolaev |
//|                                                    vinin@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Victor Nicolaev"
#property link      "vinin@mail.ru"


#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red
//#property indicator_level1 0


extern int MA_Start=3;
extern int MA_Count=600;
extern int MA_Period=3;
extern int Limit=1440;
//---- buffers
double BufferUP[];
double BufferDN[];
double tmp[];
double MA[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init() {
//---- drawing settings
   IndicatorBuffers(4);
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(0,BufferUP);
   SetIndexBuffer(1,BufferDN);
   SetIndexBuffer(2,MA);
   SetIndexBuffer(3,tmp);
   

   return(0); }//int init() 
   
//+------------------------------------------------------------------+
int start() {
   int limit1, limit2;
   int counted_bars=IndicatorCounted();
   int i,j;
   double sum,av;
   double Res;
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit1=Bars-counted_bars;
   
   if (Limit>0) limit1=MathMin(Limit,limit1); 
   
   limit2=limit1;
   if (counted_bars==0) limit1=limit2+MA_Period;
   for (i = limit1;i>=0;i--){
      sum=0;
      Res=0;
      for (j=1;j<=MA_Count;j++) {
         Res+=(Close[i]-Close[j+i])*j;
      }
      MA[i]=Res/MA_Count;
   }
   for (i = limit2;i>=0;i--) {
      tmp[i]=iMAOnArray(MA,0,MA_Period,0,MODE_SMA,i);
      BufferUP[i]=0;
      BufferDN[i]=0;
      if (tmp[i]>tmp[i+1]) BufferUP[i]=tmp[i]; else BufferDN[i]=tmp[i];
   }
   

   return(0); 
}

   

Comments