ASCT1sig_v1

Download script
ASCT1sig_v1

This script is designed as a technical analysis tool for the MetaTrader platform, specifically created to identify potential entry points in a financial market by analyzing price momentum and volatility. It works by scanning historical price data to detect specific patterns of movement, ultimately providing visual signals (arrows) and real-time alerts on your chart.

Core Logic Overview

The script operates through a multi-layered filtering process to distinguish between "noise" and significant market movements:

1. Volatility Assessment Before making any calculations, the tool calculates the average price range of the recent candles. By measuring the distance between the high and low prices over a short window, it establishes a baseline for how much the market is currently "swinging." This helps the tool understand what constitutes a significant move versus a minor fluctuation.

2. Trend Strength Detection The script then looks for two specific types of price actions to confirm a trend:

  • Gap/Jump Detection: It checks if there has been a sharp enough jump between the opening and closing prices relative to the recent average volatility.
  • Momentum Analysis: It looks for sustained moves where the price closes significantly higher or lower than it was several bars ago.

Based on these findings, the script dynamically adjusts its internal settings. If it detects strong momentum, it switches to a "fast" mode; if the market is relatively flat, it reverts to a "slower" baseline to avoid false signals.

3. Oscillator Integration The tool combines the trend detection with a percentage-based oscillator (similar to a Williams %R). It transforms this data into a value that represents where the price sits relative to its recent highs and lows. By calculating how far the price has moved from its extremes, it determines whether the market is becoming "overextended" or is gaining heavy momentum in one direction.

Signal Generation

The final logic determines when to place an arrow on your chart based on a "crossover" concept:

  • Sell Signals (Magenta Arrows): These are triggered when the momentum indicator moves from a low state, passes through a neutral zone, and breaks above a specific high-intensity threshold. This suggests the upward move may be exhausted or a reversal is imminent.
  • Buy Signals (Aqua Arrows): These occur in the opposite scenario—when the momentum drops from a high state, passes through the neutral zone, and breaks below a specific low-intensity threshold, suggesting a downward move may be reaching its limit.

User Interaction

When these specific conditions are met, the script does two things:

  1. Visual Mapping: It places an arrow on the chart at the specific price point (adjusted slightly above or below the candle) to show you exactly where the signal occurred.
  2. Alerting: It triggers a pop-up notification on your screen, clearly stating "ASCT BUY" or "ASCT SELL" along with the currency pair and timeframe, ensuring you don't miss an entry point while away from the chart.
Indicators Used
Larry William percent range indicator
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
13 Views
0 Downloads
0 Favorites
ASCT1sig_v1
//+------------------------------------------------------------------+
//| ASCT1sig.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,108);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,108);
   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;
           }
        }
      if (val1[shift]>0) Alert(Symbol() + ":" + Period() + " - ASCT SELL");
      if (val2[shift]>0) Alert(Symbol() + ":" + Period() + " - ASCT BUY");
      shift--;
     }
   return(0);
  }
//+------------------------------------------------------------------+

Comments