ASCTrend1sig_v4
Download scriptThis script is a technical analysis tool designed to identify potential trend reversals by analyzing price movements and momentum. Instead of simply looking at where the price is currently going, it evaluates the "strength" and "volatility" of the market to predict when a move might be exhausting itself.
Core Logic Breakdown
1. Volatility and Range Analysis The tool begins by measuring the average range of price movement (the distance between highs and lows) over a specific period of recent bars. This allows the script to understand the "normal" behavior of the market at that moment. It uses this average as a baseline to determine what constitutes a significant move versus standard market noise.
2. Detecting Significant Price Action The logic then looks for two specific types of significant movements:
- Price Gaps/Jumps: It checks if the price has moved significantly compared to its recent average range.
- Momentum Shifts: It monitors whether the distance between current prices and previous prices exceeds certain multipliers of that average range.
Depending on which of these movements occur, the script adjusts its internal sensitivity settings. If the market shows high volatility or a sharp momentum shift, it changes how it calculates technical indicators to better reflect the current environment.
3. Momentum Calculation (WPR) The script utilizes a modified version of the Williams Percent Range (WPR) indicator. By dynamically adjusting the "period" of this indicator based on the market conditions found in the previous step, the tool can stay responsive. It effectively "speeds up" or "slows down" its analysis to match whether the market is trending aggressively or moving sideways.
4. Trend Reversal Signals The final step involves identifying when the momentum has pushed the price into an extreme zone.
- If the momentum indicator shows that the market has moved too far in one direction (hitting a "ceiling" or "floor"), the script looks for a point where that momentum begins to break.
- When this reversal is detected, the tool places visual markers on the chart:
- Upward Signals: Placed above the high of a bar when the market shows signs of recovering from an oversold state.
- Downward Signals: Placed below the low of a bar when the market shows signs of falling from an overbought state.
Summary for the User
In simple terms, this script acts as a "momentum exhaustion" detector. It calculates the average "breath" of the market and watches for moments where the price moves too far, too fast. When it detects that a move is becoming overextended and is likely to pull back or reverse, it marks those specific areas on your chart with arrows to highlight potential entry or exit points.
//+------------------------------------------------------------------+
//| ASCTrend1sig_noSound.mq4 |
//| Ramdass - Conversion only |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
//---- 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, 0, 1);
SetIndexArrow(0, 234);
SetIndexStyle(1, DRAW_ARROW, 0, 1);
SetIndexArrow(1, 233);
SetIndexBuffer(0, val1);
SetIndexBuffer(1, val2);
if(CountBars >= 1000)
CountBars=950;
SetIndexDrawBegin(0, Bars - CountBars + 11 + 1);
SetIndexDrawBegin(1, Bars - CountBars + 11 + 1);
//----
return(0);
}
//+------------------------------------------------------------------+
//| ASCTrend1sig |
//+------------------------------------------------------------------+
int start()
{
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