ASCtrend+Koments

Download script
Author: Copyright � 2005, MetaQuotes Software Corp.
ASCtrend+Koments

This script functions as a technical analysis tool designed to identify potential trend reversals in financial markets. Instead of simply following price movement, it analyzes the relationship between price volatility, specific price "breaks," and momentum oscillators to provide visual signals on a trading chart.

Core Logic Overview

The script operates by scanning historical price data to establish a baseline for "normal" market behavior. It accomplishes this through several distinct logical steps:

1. Volatility and Range Analysis The tool first calculates the average size of price movements (the range) over a recent window of time. This establishes a dynamic benchmark; by knowing what a "normal" move looks like, the script can better identify when a price move is significant enough to be considered a trend shift rather than just standard market noise.

2. Significant Price Action Detection The logic searches for two specific types of price movements:

  • Breakout Momentum: It looks for instances where the gap between the current price and the previous close is significantly larger than the established average range.
  • Structural Shifts: It monitors for substantial price displacements over a slightly longer period to determine if a new trend structure is forming.

3. Momentum Filtering To prevent "fake-outs," the script utilizes a momentum oscillator (WPR). It adjusts the sensitivity of this oscillator based on the volatility and structural shifts detected in the previous steps. This allows the tool to confirm whether the market is becoming overextended or if it has enough strength to sustain a new direction.

4. Trend Reversal Signals The script identifies potential entries by looking for specific conditions:

  • Buy Signals: When momentum drops below a certain threshold and then begins to recover, suggesting a move from an oversold state toward an upward trend.
  • Sell Signals: When momentum rises above a specific threshold and starts to pull back, suggesting a move from an overbought state toward a downward trend.

User Experience Features

  • Visual Indicators: The script places specific symbols (arrows) on the chart to highlight exactly where it identifies a potential "Buy" or "Sell" opportunity.
  • Automated Alerts: For active traders, the script provides real-time notifications. When a new trend signal is confirmed on the most recent candles, it triggers an audible and visual alert on the platform to notify the user immediately.
  • Risk Customization: The logic includes a "Risk" parameter, which allows users to adjust the sensitivity of the detection zones, making the tool more conservative or more aggressive depending on the user's trading style.
Indicators Used
Larry William percent range indicator
Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
ASCtrend+Koments
//+------------------------------------------------------------------+ 
//|                                             ASCtrend+Koments.mq4 | 
//|                      Copyright © 2005, MetaQuotes Software Corp. | 
//|                                        http://www.metaquotes.net | 
//+------------------------------------------------------------------+ 
#property copyright "Copyright © 2005, MetaQuotes Software Corp." 
#property link      "http://www.metaquotes.net" 
#property indicator_chart_window 
#property indicator_buffers 2 
#property indicator_color1 Aqua 
#property indicator_color2 Magenta 

extern int RISK=4; 
extern int AllBars=2500; 
int up=0,dn=0; 
double val1buffer[]; 
double val2buffer[]; 
//+------------------------------------------------------------------+ 
//| Custom indicator initialization function                         | 
//+------------------------------------------------------------------+ 
int init() 
  { 
//---- indicators 
      SetIndexStyle(0,DRAW_ARROW,EMPTY); 
      SetIndexArrow(0,108); 
      SetIndexBuffer(0, val1buffer); 

      SetIndexStyle(1,DRAW_ARROW,EMPTY); 
      SetIndexArrow(1,108); 
      SetIndexBuffer(1, val2buffer); 
      return(0); 
  } 
//+------------------------------------------------------------------+ 
//| Custom indicator deinitialization function                       | 
//+------------------------------------------------------------------+ 
int deinit() 
   { 
     return(0); 
   } 
//+------------------------------------------------------------------+ 
//| Custom indicator iteration function                              | 
//+------------------------------------------------------------------+ 
// int    counted_bars=IndicatorCounted(); 

int start() 
{    
    
   double value2; 
   double value3; 
   double value10=10; 
   double value11; 
   double x1=70; 
   double x2=30; 
   int TrueCount; 
   int counter; 
   int MRO1; 
   int MRO2; 
   int i1; 
   double Range; 
   double AvgRange; 
   double val1; 
   double val2; 
   double Table_value2[500][2]; 
   int counted_bars=IndicatorCounted(); 
    
   value10=3+RISK*2; 
   x1=67+RISK; 
   x2=33-RISK; 
   value11=value10; 
  //---------------------------- 
    
   if(counted_bars<0) return (-1); 
   if(counted_bars>0) counted_bars--;       //last bar recounted 
   int i; 
   int shift = Bars-counted_bars-1; 
   if (shift > AllBars) shift = AllBars; 
          
  for(i=shift; i>0; i--) 
   { 
    


    
                  
      counter=i; 
      Range=0; 
      AvgRange=0; 
      for (counter=i ;counter<=i+9;counter++) 
      { 
         AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]); 
      } 
      Range=AvgRange/10; 
      
      
      counter=i; 
      TrueCount=0; 
      while (counter<i+9 && TrueCount<1) 
      { 
         if (MathAbs(Open[counter]-Close[counter+1])>=Range*2.0 ) 
               TrueCount++; 
         counter++; 
      } 

      if (TrueCount>=1) 
            MRO1=counter ; 
      else 
            MRO1=-1; 
            
      counter=i; 
      TrueCount=0; 
      while (counter<i+6 && TrueCount<1) 
      { 
           if(MathAbs(Close[counter+3]-Close[counter])>=Range*4.6) 
            {TrueCount++;} 
           counter++; 
      } 
      
      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,i)); 
      Table_value2[i][0]=i; 
      Table_value2[i][1]=value2; 
      val1=0; 
      val2=0; 
      value3=0; 
      //-------------------     val1  
      if (value2<x2 )  //  x2 = 30 
      { 
         i1=1; 
         while (Table_value2[i+i1][1]>=x2 && Table_value2[i+i1][1]<=x1) 
         {i1++;} 

         if (Table_value2[i+i1][1]>x1) 
         { 
            value3=High[i]+Range*0.5; 
            val1=value3; 
         } 
      } 
      
      //-------------------     val2  
      if ( value2>x1) // x1 = 70 
      {  
            i1=1; 
            while (Table_value2[i+i1][1]>=x2 && Table_value2[i+i1][1]<=x1) 
            {i1++;} 
            
            if (Table_value2[i+i1][1]< x2) 
            { 
               value3=Low[i]-Range*0.5; 
               val2=value3; 
            } 
      } 
      
      
        
      
      if (val2!=0 && up==0 ) 
      {      
           val1buffer[i]= val2-1*Point; 
           up=1; 
           dn=0; 
           if(shift<=2) 
           { 
            Alert (Symbol()," ",Period(),"M  Asctrend BUY "); 
            } 
      }  
      if (val1 !=0 && dn==0) 
      { 
      
            val2buffer[i]= val1+1*Point; 
            dn=1; 
            up=0; 
            if(shift<=2) 
            { 
            Alert (Symbol()," ",Period(),"M   Asctrend SELL "); 
            } 
       } 
    
   } 
return(0); 

}

Comments