ASCTrend1sig_noSound_v1
Download scriptThis script is designed as a visual trading assistant for the MetaTrader platform, specifically engineered to identify potential market reversals by analyzing price momentum and volatility. Instead of providing a continuous line, it acts as a signaling tool that marks specific points on your chart with arrows to highlight where a trend might be shifting.
Core Logic & Methodology
The script operates by scanning historical price data to distinguish between standard market "noise" and significant structural moves. Here is the professional breakdown of its internal logic:
1. Volatility and Movement Analysis The tool begins by calculating the average price range over a specific look-back period. It uses this average to establish a baseline for what constitutes a "normal" move in the current market environment. By establishing this benchmark, the script can differentiate between minor price fluctuations and high-impact movements.
2. Momentum Filtering The logic employs two distinct checks to validate market strength:
- Gap Detection: It looks for significant jumps between opening and closing prices relative to the established volatility range.
- Trend Magnitude: It measures the distance covered by price movement over a specific window to determine if a trend is aggressive or weakening.
Based on these findings, the script dynamically adjusts its sensitivity. If the market shows high-strength movement, it modifies its calculation parameters to better capture the peak of that momentum; if the market is stagnant, it reverts to a standard sensitivity level.
3. Oscillator Integration The script feeds these adjusted parameters into a specialized oscillator (Percentage Range). This helps the tool identify "overbought" or "oversold" conditions. Essentially, it tracks how far the price has stretched in one direction compared to its recent history.
4. Signal Generation (The Arrows) The final step is the trigger logic. The script looks for a specific "breakout and reversal" pattern:
- Bearish Signals: If the momentum oscillator drops below a certain threshold and then moves back toward the center, the script identifies a potential top and places an arrow above the high of that candle.
- Bullish Signals: If the momentum oscillator rises above a specific threshold and then pulls back toward the center, it identifies a potential bottom and places an arrow below the low of that candle.
Summary for the User
In practical terms, this script filters out the "choppiness" of the market to find clear turning points. It waits for the price to move significantly in one direction, confirms that the movement has reached an extreme level based on recent volatility, and then alerts you with a visual signal when the momentum begins to shift back, suggesting a potential entry or exit point.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| ASCTrend1sig_noSound.mq4
//| Ramdass - Conversion only
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Magenta
#property indicator_color2 Aqua
//---- input parameters
extern int RISK=3;
extern int CountBars=300;
//---- buffers
double val1[];
double val2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicator line
IndicatorBuffers(2);
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,234);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,233);
SetIndexBuffer(0,val1);
SetIndexBuffer(1,val2);
//----
return(0);
}
//+------------------------------------------------------------------+
//| ASCTrend1sig |
//+------------------------------------------------------------------+
int start()
{
if (CountBars>=1000) CountBars=950;
SetIndexDrawBegin(0,Bars-CountBars+11+1);
SetIndexDrawBegin(1,Bars-CountBars+11+1);
int i,shift,counted_bars=IndicatorCounted();
int Counter,i1,value10,value11;
double value1,x1,x2;
double value2,value3;
double TrueCount,Range,AvgRange,MRO1,MRO2;
double Table_value2[1000];
value10=3+RISK*2;
x1=67+RISK;
x2=33-RISK;
value11=value10;
//----
if(Bars<=11+1) return(0);
//---- initial zero
if(counted_bars<11+1)
{
for(i=1;i<=0;i++) val1[CountBars-i]=0.0;
for(i=1;i<=0;i++) val2[CountBars-i]=0.0;
}
//----
shift=CountBars-11-1;
while(shift>=0)
{
Counter=shift;
Range=0.0;
AvgRange=0.0;
for (Counter=shift; Counter<=shift+9; Counter++) AvgRange=AvgRange+MathAbs(High[Counter]-Low[Counter]);
Range=AvgRange/10;
Counter=shift;
TrueCount=0;
while (Counter<shift+9 && TrueCount<1)
{if (MathAbs(Open[Counter]-Close[Counter+1])>=Range*2.0) TrueCount=TrueCount+1;
Counter=Counter+1;
}
if (TrueCount>=1) {MRO1=Counter;} else {MRO1=-1;}
Counter=shift;
TrueCount=0;
while (Counter<shift+6 && TrueCount<1)
{if (MathAbs(Close[Counter+3]-Close[Counter])>=Range*4.6) TrueCount=TrueCount+1;
Counter=Counter+1;
}
if (TrueCount>=1) {MRO2=Counter;} else {MRO2=-1;}
if (MRO1>-1) {value11=3;} else {value11=value10;}
if (MRO2>-1) {value11=4;} else {value11=value10;}
value2=100-MathAbs(iWPR(NULL,0,value11,shift)); // PercentR(value11=9)
Table_value2[shift]=value2;
val1[shift]=0;
val2[shift]=0;
value3=0;
if (value2<x2)
{i1=1;
while (Table_value2[shift+i1]>=x2 && Table_value2[shift+i1]<=x1){i1++;}
if (Table_value2[shift+i1]>x1)
{
value3=High[shift]+Range*0.5;
val1[shift]=value3;
}
}
if (value2>x1)
{i1=1;
while (Table_value2[shift+i1]>=x2 && Table_value2[shift+i1]<=x1){i1++;}
if (Table_value2[shift+i1]<x2)
{
value3=Low[shift]-Range*0.5;
val2[shift]=value3;
}
}
shift--;
}
return(0);
}
//+------------------------------------------------------------------+
Comments