ASCTrend1sig

Download script
ASCTrend1sig

This tool is designed to identify potential turning points in market trends by analyzing price volatility and momentum. It works by scanning historical data to recognize specific patterns that suggest a shift from an ongoing trend toward a reversal.

Core Logic Overview

The script operates by looking at three primary factors: the average range of recent price movement, the intensity of recent price changes, and a percentage-based momentum calculation. Here is how it breaks down:

1. Volatility and Intensity Analysis The tool first calculates the "Average Range" of the market over a short period (the last 10 bars). It uses this average to determine what constitutes a significant move. It then searches for two types of high-intensity movements:

  • Gap Analysis: It looks for instances where the price jump between consecutive bars is double the average range.
  • Trend Strength: It looks for sharp moves where the price difference over a few bars is significantly higher than the average.

2. Dynamic Momentum Scoring Based on the intensity of the movements found in step one, the script adjusts a sensitivity value. If it detects high-intensity volatility, it modifies the "lookback" period used to calculate momentum. This allows the tool to react more quickly to sudden market shocks while remaining stable during periods of low activity.

3. Reversal Signal Generation The final stage uses a momentum oscillator (WPR) to determine if the asset is overbought or oversold. The logic looks for a specific "crossing" behavior:

  • Sell Signals: If the momentum drops below a certain threshold and then shows a sharp move back toward a higher level, it identifies a potential peak.
  • Buy Signals: If the momentum rises above a certain threshold and then shows a sharp move back toward a lower level, it identifies a potential trough.

Visual Output

When these specific conditions are met—combining high volatility, a specific momentum position, and a trend reversal—the script places visual markers (arrows) on your chart:

  • Magenta Arrows: Indicate a potential downward trend or sell opportunity.
  • Yellow Arrows: Indicate a potential upward trend or buy opportunity.

The "Risk" setting allows you to adjust these sensitivity thresholds, making the tool either more aggressive in identifying signals or more conservative by requiring larger price swings before a marker appears.

Indicators Used
Larry William percent range indicator
Miscellaneous
Implements a curve of type %1
16 Views
0 Downloads
0 Favorites
ASCTrend1sig
//+------------------------------------------------------------------+
//| ASCTrend1sig_noSound.mq4 
//| Ramdass - Conversion only
//+------------------------------------------------------------------+

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Magenta
#property indicator_color2 Yellow

//---- input parameters
extern int RISK=3;
extern int CountBars=100;

//---- 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[50000];
   
   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