MA_Dash_Cobra_v1
Download scriptThis custom trading indicator is designed to provide visual guidance on price movements by utilizing a Moving Average (MA) calculation. It focuses on identifying specific trends and potential shifts in momentum by analyzing the relationship between historical price data and moving averages.
Core Functionality
The script operates by processing price information based on three primary user-defined criteria: the timeframe/number of candles to analyze (Period), the mathematical method used to calculate the average (such as Simple, Exponential, etc.), and the specific price point (such as Close, High, or Low) to be measured.
How It Works
The logic follows a two-step process to display information on your chart:
- Base Trend Calculation: The script constantly calculates a standard Moving Average based on your preferences. This serves as the foundational data point for understanding where the price is heading in the short to medium term.
- Dynamic Visual Filtering: Unlike a standard moving average line that appears as a continuous, unbroken string, this tool applies a specific logic to its visual output. It checks the sequence of previous data points. If it detects a continuous "flow" of existing data across several preceding bars, it intentionally hides the indicator's line for that specific moment.
Purpose and Visual Behavior
The primary goal of this logic is to filter out "noise." Instead of showing a constant line that can sometimes clutter the chart or lead to over-analysis, the indicator highlights specific segments of the moving average. It effectively acts as a visual "interrupt," only appearing at specific intervals or transition points where the data sequence changes. This allows traders to focus on new movements rather than being distracted by established trends that have already been established.
//+------------------------------------------------------------------+
//| MAÂÏÿòíûøêó.mq4 |
//| * |
//|Integer * |
//+------------------------------------------------------------------+
#property copyright "*"
#property link "*"
//----
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 CLR_NONE
#property indicator_color2 Yellow
//---- input parameters
extern int MAPeriod=14;
extern int MAMethod=0; // 0-SMA, 1-EMA, 2-SMMA, 3-LWMA
extern int MAPrice=0; // 0-Close, 1-Open, 2-High, 3-Low, 4-Median, 5-Typical, 6-Weighted
//----
#property indicator_width1 3
#property indicator_width2 3
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexBuffer(1,ExtMapBuffer2);
//----
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);
if(ExtMapBuffer2[i+1]!=EMPTY_VALUE &&
ExtMapBuffer2[i+2]!=EMPTY_VALUE &&
ExtMapBuffer2[i+3]!=EMPTY_VALUE )
{
ExtMapBuffer2[i]=EMPTY_VALUE;
}
else
{
ExtMapBuffer2[i]=ExtMapBuffer1[i];
}
}
return(0);
}
//+------------------------------------------------------------------+
Comments