ASCTrend1sig_v1
Download scriptThis script is designed to analyze market price action and identify specific turning points by monitoring volatility, momentum, and price trends. It functions as a visual signal generator that places markers on your chart to highlight potential shifts in the market direction.
Core Logic Overview
The tool operates by scanning historical price data (the last several hundred candles) to perform three primary types of analysis:
1. Volatility and Range Measurement Instead of looking at prices in isolation, the script first calculates a "Normal Range" for the market. It does this by averaging the distance between the highs and lows over a rolling 10-candle window. This ensures that the signals are relative to current market conditions—meaning it adapts whether the market is moving in small increments or large swings.
2. Significant Movement Detection The script looks for two specific types of "True Movements" to determine if a trend is actually gaining strength:
- Price Gaps/Spikes: It checks if there are sudden jumps between opening and closing prices that significantly exceed the normal range.
- Momentum Shifts: It looks for sustained moves where the price changes by a specific multiple of the normal range over a short period. If these movements are detected, the script adjusts its internal sensitivity to better capture the speed of the current trend.
3. Momentum Calculation (WPR) The script uses a specialized momentum oscillator (Weighted Price Ratio) to determine where the price sits relative to its recent history. It converts this into a percentage-based value to identify "overbought" or "oversold" conditions.
How Signals Are Generated
The final output—the markers you see on the chart—is produced through a "rebound" logic:
- Sell/Bearish Signals: The script identifies when the momentum has dropped significantly below a specific threshold (the bottom of the range). It then looks forward to see if the momentum successfully crosses back into a neutral zone. If it does, it marks a point at the high of that candle, suggesting a potential reversal or price peak.
- Buy/Bullish Signals: Conversely, it identifies when momentum has surged above a specific upper threshold. It then monitors for the momentum to drop back down into the neutral zone. When this happens, it marks a point at the low of that candle, suggesting a potential move upward.
Summary for the User
In plain terms, this tool filters out "market noise" by measuring what a normal price movement looks like in the current environment. It only creates a signal when the market experiences a significant momentum surge followed by a cooling-off period. This logic aims to highlight moments where the market is exhausted and likely to reverse, providing visual cues for potential entry or exit points.
//+------------------------------------------------------------------+
//| ASCTrend1sig_noSound.mq4
//| Ramdass - Conversion only
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Magenta
#property indicator_color2 Yellow
#property indicator_width1 2
#property indicator_width2 2
//---- input parameters
extern int RISK=3;
extern int CountBars=500;
//---- 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,x67,x33;
double value2,value3;
double TrueCount,Range,AvgRange,MRO1,MRO2;
double Table_value2[50000];
value10=3+RISK*2;
x67=67+RISK;
x33=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<x33)
{
i1=1;
while (Table_value2[shift+i1]>=x33 && Table_value2[shift+i1]<=x67){i1++;}
if (Table_value2[shift+i1]>x67)
{
value3=High[shift]+Range*0.5;
val1[shift]=value3;
}
}
if (value2>x67)
{
i1=1;
while (Table_value2[shift+i1]>=x33 && Table_value2[shift+i1]<=x67){i1++;}
if (Table_value2[shift+i1]<x33)
{
value3=Low[shift]-Range*0.5;
val2[shift]=value3;
}
}
shift--;
}
return(0);
}
//+------------------------------------------------------------------+
Comments