iACfunc
Download scriptThis script is designed to perform a specific mathematical calculation used in financial analysis to help traders understand market momentum and price trends. It functions as a custom "indicator tool" that processes raw price data into a smoother, more readable value.
How the Logic Works
The script follows a multi-step process to filter out market "noise" and identify the underlying trend:
1. Data Gathering First, the script looks at the current financial asset (the symbol) and the specific timeframe you are viewing. It identifies the price points needed for its calculations based on the settings provided by the user.
2. Step One: Determining Momentum (The AO Component) Before calculating the final result, the script first calculates a "Momentum" value. It does this by comparing two different moving averages of the price. By subtracting a long-term average from a short-term average, it identifies whether the price is currently moving faster or slower than its historical norm.
3. Step Two: Smoothing the Momentum (The AC Component) Once the momentum value is established, the script performs a second layer of calculation. It takes that new momentum value and applies a third moving average to it. This acts as a stabilizer, smoothing out erratic jumps in the data to reveal a clearer picture of where the trend is heading.
4. The Final Output The result provided by this script is a single numerical value. This value represents the "Accelerated" trend. In simple terms:
- If the value is rising, it suggests strengthening momentum.
- If the value is falling, it suggests weakening momentum.
Key Features for the User
- Customizable Sensitivity: The script allows you to adjust various periods, meaning you can choose whether you want the indicator to react quickly to small price changes or more slowly to capture major long-term trends.
- Versatility: Because it is built as a function, it can be integrated into other trading tools to help automate decisions or provide visual cues on a chart.
- Precision: By using different "Moving Average" methods and price types (like close, open, or median prices), the script can be tuned to match your specific trading style.
//+------------------------------------------------------------------+
//| iACfunc.mq4 |
//| Author: paladin80 |
//| E-mail: forevex@mail.ru |
//+------------------------------------------------------------------+
#property copyright "paladin80"
#property link "forevex@mail.ru"
#property library
//--------------------------------------------- iACfunc() - start ------------------------------------------------------------
//+----------------------------------------------------------------------------+
//| Input parameters: |
//| Sy - Symbol. |
//| Tf - Timeframe. |
//| MA_mode - Applied MA method. |
//| Applied_price - Applied price. |
//| Period_1 , Period_2 , Period_3 - Periods for calculation of indicator |
//| (see formulas below) |
//| Shift - Index of the value taken from the indicator buffer. |
//+----------------------------------------------------------------------------+----+
//| Formulas for calculation standard AC (http://codebase.mql4.com/247) |
//| The function iACfunc() is calculated according formulas: |
//| AO = MA_mode (Applied_price, Period_1) - MA_mode (Applied_price, Period_2) |
//| AC = AO - MA_mode (AO, Period_3) |
//+---------------------------------------------------------------------------------+
double iACfunc(string Sy,int Tf,int MA_mode,int Applied_price,int Period_1,int Period_2,int Period_3,int Shift)
{
double AOBuffer[], AC;
if (Sy=="" || Sy=="0") Sy=Symbol();
int limit=MathMax(MathMax(Period_1,Period_2),Period_3)-1+Shift;
ArrayResize(AOBuffer,limit);
for (int i=0; i<=limit; i++)
{
AOBuffer[i]=iMA(Sy,Tf,Period_1,0,MA_mode,Applied_price,i)-iMA(Sy,Tf,Period_2,0,MA_mode,Applied_price,i);
}
ArraySetAsSeries(AOBuffer,true);
AC=AOBuffer[Shift]-iMAOnArray(AOBuffer,0,Period_3,0,MA_mode,Shift);
return(AC);
}
//--------------------------------------------- iACfunc() - end ------------------------------------------------------------
Comments