test_3expert
Download scriptThis custom indicator is designed to provide visual cues on your trading charts by identifying specific trend movements based on price action. Rather than looking at raw price alone, it calculates a customized "average" value for each bar to smooth out market noise and determine the direction of the momentum.
How it Works
The script functions by analyzing three consecutive bars on your chart to establish a clear pattern of movement:
- Trend Calculation: For every bar, the tool calculates a specific data point by averaging the High, Low, and Closing prices. By focusing on these figures, the indicator attempts to find the "true" center of price action for that period.
- Down Trend Detection: The logic looks for a consistent decline. If the average value of two bars ago is higher than the previous bar, and that bar is higher than the current bar, the tool identifies a downward trend. When this happens, it places a visual marker on the chart to alert you to the falling momentum.
- Up Trend Detection: Conversely, the script looks for a consistent climb. If the average value from two bars ago is lower than the previous bar, and that bar is lower than the current bar, it identifies an upward trend. In these instances, it places a different visual marker to signal rising momentum.
Visual Output
To make this information easy to read at a glance, the indicator uses colored arrows directly on your price chart:
- Downward Signals: When a steady decrease in price is detected across three points, the script highlights this move with specific red markings.
- Upward Signals: When a steady increase in price is confirmed, it provides white markings to highlight the bullish movement.
By filtering the market's "noise" and only highlighting consistent, sequential movements, this tool helps traders visually distinguish between temporary price fluctuations and established trend directions.
//+------------------------------------------------------------------+
//| test.mq4 |
//+------------------------------------------------------------------+
#property copyright "Ron T"
#property link "http://www.lightpatch.com"
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 White
#property indicator_color2 Red
#property indicator_color3 Red
#property indicator_color4 White
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
// User Input
extern double Gap_Size=0.0030;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//|------------------------------------------------------------------|
int init()
{
SetIndexStyle(0,DRAW_ARROW);
SetIndexBuffer(0, ExtMapBuffer1);
SetIndexArrow(0,233); //up red
SetIndexStyle(1,DRAW_ARROW);
SetIndexBuffer(1, ExtMapBuffer2);
SetIndexArrow(1,234); //down white
SetIndexStyle(2,DRAW_ARROW);
SetIndexBuffer(2, ExtMapBuffer3);
SetIndexArrow(2,168); // Red
SetIndexStyle(3,DRAW_ARROW);
SetIndexBuffer(3, ExtMapBuffer4);
SetIndexArrow(3,168); // White
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
int i;
for( i=0; i<Bars; i++ ) ExtMapBuffer1[i]=0;
for( i=0; i<Bars; i++ ) ExtMapBuffer2[i]=0;
for( i=0; i<Bars; i++ ) ExtMapBuffer3[i]=0;
for( i=0; i<Bars; i++ ) ExtMapBuffer4[i]=0;
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
double oTYP0=0, oTYP1=0, oTYP2=0, oTYP3=0, oTYP4=0, oTYP5=0;
int pos=Bars;
while(pos>=0)
{
oTYP0=(High[pos+0]+Low[pos+0]+Close[pos+0]+Close[pos+0])/4;
oTYP1=(High[pos+1]+Low[pos+1]+Close[pos+1]+Close[pos+1])/4;
oTYP2=(High[pos+2]+Low[pos+2]+Close[pos+2]+Close[pos+2])/4;
// down trend
if(oTYP2 > oTYP1 && oTYP1 > oTYP0)
{
ExtMapBuffer1[pos]=0;
ExtMapBuffer2[pos]=oTYP0-0.0010; //down red
}
// up trend
if(oTYP2 < oTYP1 && oTYP1 < oTYP0)
{
ExtMapBuffer1[pos]=oTYP0+0.0010; //up white
ExtMapBuffer2[pos]=0;
}
pos--;
}
return(0);
}
//+------------------------------------------------------------------+
Comments