KG FI V.1.0

Download script
Author: Copyright � 2004, MetaQuotes Software Corp.
KG FI V.1.0

This tool is a specialized technical indicator designed to analyze market momentum by synthesizing two primary factors: trading volume and price movement dynamics. Instead of just looking at how high or low a price goes, this script evaluates the "energy" behind those movements to identify whether a trend is gaining strength or losing steam.

How the Logic Works

1. Volume and Price Momentum Correlation The core logic begins by calculating the percentage change in a Moving Average (a smoothed average of price) over a specific timeframe. This percentage change represents the speed and direction of price movement. The script then multiplies this value by the actual trading volume. By doing this, the indicator filters out "noise" (small price movements with no interest) and highlights significant actions where high volume accompanies a clear shift in price direction.

2. Smoothing and Filtering To ensure that the data remains readable and doesn't react too erratically to every minor tick, the script applies a secondary smoothing layer (a Linear Weighted Moving Average). This creates a cleaner "flow" line on your chart, making it easier to see the underlying trend without being distracted by momentary spikes.

3. Trend Identification The logic categorizes the market into three distinct states based on the resulting calculation:

  • Up Trend Area: When the calculated momentum is positive, suggesting bullish pressure.
  • Down Trend Area: When the calculation is negative, suggesting bearish pressure.
  • Neutral Area: When the movement is stagnant or lacks significant directional bias.

User Experience and Alerts

The tool provides real-time visual feedback by updating its name on the chart to reflect the current trend status (e.g., "Up," "Down," or "Flat").

Furthermore, it includes an automated notification system. The script monitors for "crossovers"—the exact moment the data flips from a positive value to a negative one (or vice versa). When these transitions occur, the script can trigger an instant alert on your platform, notifying you immediately when the market shifts from an Up Trend Area into a Down Trend Area, or vice versa. This allows for quicker reaction times without needing to constantly watch the screen.

Indicators Used
Moving average indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
4 Views
1 Downloads
0 Favorites
KG FI V.1.0
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"

#property indicator_separate_window
#property indicator_levelcolor DarkSlateGray
#property indicator_buffers 1
#property indicator_color1 Blue

extern double KG_FI_Period = 4.0;
extern int MA_Mode = 3;
extern double Price_Type = 0.0;
extern double Filter = 4.0;
extern bool Alert_ON = FALSE;
int gi_unused_108 = 0;
string gs_112;
string gs_120;
double g_ibuf_128[];
int gi_132 = 0;
int gi_136 = 0;

int init() {
   SetIndexStyle(0, DRAW_LINE);
   SetIndexBuffer(0, g_ibuf_128);
   string ls_0 = "KG FI";
   IndicatorShortName(ls_0);
   SetIndexLabel(0, ls_0);
   SetIndexDrawBegin(0, KG_FI_Period);
   return (0);
}

int start() {
   int l_ind_counted_4 = IndicatorCounted();
   if (Bars <= KG_FI_Period) return (0);
   if (l_ind_counted_4 < 1) for (int li_0 = 1; li_0 <= KG_FI_Period; li_0++) g_ibuf_128[Bars - li_0] = 0.0;
   li_0 = Bars - KG_FI_Period - 1.0;
   if (l_ind_counted_4 >= KG_FI_Period) li_0 = Bars - l_ind_counted_4 - 1;
   while (li_0 >= 0) {
      g_ibuf_128[li_0] = Volume[li_0] * (100.0 * iMA(NULL, 0, KG_FI_Period, 0, MA_Mode, Price_Type, li_0) / iMA(NULL, 0, KG_FI_Period, 0, MA_Mode, Price_Type, li_0 + 1) - 100.0);
      li_0--;
   }
   int li_8 = Bars - l_ind_counted_4;
   for (int li_12 = 0; li_12 < li_8; li_12++) {
      g_ibuf_128[li_12] = iMAOnArray(g_ibuf_128, Bars, Filter, 0, MODE_LWMA, li_12);
      if (g_ibuf_128[li_12] > g_ibuf_128[li_12 + 1]) gs_112 = "Up";
      if (g_ibuf_128[li_12] < g_ibuf_128[li_12 + 1]) gs_112 = "Down";
      if (g_ibuf_128[li_12] == g_ibuf_128[li_12 + 1]) gs_112 = "Flat";
      if (g_ibuf_128[li_12] > 0.0) gs_120 = "UP_TREND AREA";
      else {
         if (g_ibuf_128[li_12] < 0.0) gs_120 = "DOWN_TREND AREA";
         else gs_120 = "NEUTRAL AREA";
      }
      if (g_ibuf_128[li_12] < 0.0 && g_ibuf_128[li_12 + 1] >= 0.0) {
         if (li_12 == 0 && gi_136 == FALSE) {
            gi_136 = TRUE;
            gi_132 = FALSE;
            if (Alert_ON) Alert("KG_FI Go To DOWN TREND AREA");
         }
      }
      if (g_ibuf_128[li_12] > 0.0 && g_ibuf_128[li_12 + 1] <= 0.0) {
         if (li_12 == 0 && gi_132 == FALSE) {
            gi_132 = TRUE;
            gi_136 = FALSE;
            if (Alert_ON) Alert("KG_FI Go To UP TREND AREA");
         }
      }
      IndicatorShortName("KG FI   (" + gs_112 + ")    " + gs_120 + "    ");
   }
   return (0);
}

Comments