Author: *
ima

This custom indicator is designed to provide a visual aid for traders by smoothing out the frequent fluctuations of market price data. By calculating a specific moving average, it helps identify the underlying trend of an asset more clearly than raw price action alone.

Core Functionality

The tool functions by analyzing historical price data over a set timeframe. Instead of looking at just the most recent candle, it takes into account a specific number of previous data points (the period). It then calculates an average value based on these points to produce a continuous line on your trading chart.

Key Components and Logic

  • Trend Smoothing: The primary goal of this script is to "filter out" market noise. By creating a moving average line, it allows you to see the general direction of the market—whether it is trending upward, downward, or remaining sideways—without getting distracted by minor, temporary price spikes.
  • Customizable Parameters: The logic is flexible and can be adjusted based on your specific trading style:
    • Period: You can choose how many past candles to include in the calculation. A larger period will create a smoother, slower-reacting line, while a smaller period will make the line more responsive to quick price changes.
    • Calculation Method: The script allows for different mathematical approaches to calculating the average (such as Simple or Exponential), giving you control over how much weight is given to recent versus older data.
    • Price Source: You can define which specific price data the indicator should follow, such as the opening price, the closing price, or a combination of several prices.

Visual Representation

On your trading platform, this script generates a solid red line. As new price data arrives, the indicator updates automatically, recalculating the average in real-time. This provides a dynamic visual reference that moves along with the market, helping you stay aligned with current momentum.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
ima
//+------------------------------------------------------------------+
//|                                                          ima.mq4 |
//|                                                                * |
//|                                                                * |
//+------------------------------------------------------------------+
#property copyright "*"
#property link      "*"

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red
//---- input parameters
extern int       maPeriod=14;
extern int       maMethod=1;
extern int       maPrice=0;

//---- buffers
double ExtMapBuffer1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit=Bars-IndicatorCounted();
      for(int i=limit-1;i>=0;i--){
         ExtMapBuffer1[i]=iMA(NULL,0,maPeriod,0,maMethod,maPrice,i);
      }
   return(0);
  }
//+------------------------------------------------------------------+

Comments