sar_sto_ as_ao_stevejames_alert

Download script
sar_sto_ as_ao_stevejames_alert

This indicator is designed to identify potential trend reversal points or momentum shifts by combining three distinct technical analysis tools: the Stochastic Oscillator, the Parabolic SAR (Stop and Reverse), and the Awesome Oscillator (AO) / Accumulation/Distribution (AC).

Instead of relying on a single metric, the script looks for a "confluence" of conditions, meaning it only generates a signal when all three tools agree on the direction of the market movement simultaneously.

How the Logic Works

The script scans every price candle to check for two specific scenarios: Buy signals (indicated by upward arrows) and Sell signals (indicated by downward arrows).

1. The Buy Signal (Green Arrow)

For a buy signal to appear, the following four conditions must be met at the same time:

  • Momentum Alignment: The Stochastic Main line must be currently higher than its Signal line, suggesting upward momentum.
  • Trend Confirmation (SAR): The Parabolic SAR value must be positioned below or equal to the current opening price, which typically suggests a bullish environment.
  • Volume/Accumulation Support: The Accumulation/Distribution (AC) value of the current candle must be higher than the previous candle's value.
  • Previous Trend Context: The Parabolic SAR from the previous candle must have been above the previous opening price, highlighting a transition into a new upward move.

2. The Sell Signal (Red Arrow)

Conversely, for a sell signal to appear, the script looks for these opposing conditions:

  • Momentum Alignment: The Stochastic Main line must be lower than its Signal line, suggesting downward momentum.
  • Trend Confirmation (SAR): The Parabolic SAR value must be positioned above or equal to the current opening price, typically suggesting a bearish environment.
  • Volume/Accumulation Support: The Accumulation/Distribution (AC) value of the current candle must be lower than the previous candle's value.
  • Previous Trend Context: The Parabolic SAR from the previous candle must have been below the previous opening price, highlighting a transition into a new downward move.

Visual and Notification Features

  • On-Chart Arrows: When the logic requirements are met, the script automatically plots an arrow on the chart—placing it slightly below the candle for buys and slightly above the candle for sells to keep the visual workspace clean.
  • Alert System: The script includes an optional alert feature. If enabled in the settings, it will trigger a pop-up notification whenever a new signal appears, allowing you to monitor the market in real-time without staring at the screen constantly.
Price Data Components
Series array that contains open prices of each barSeries array that contains the lowest prices of each barSeries array that contains the highest prices of each bar
Indicators Used
Bill Williams Awesome oscillatorBill Williams Accelerator/Decelerator oscillatorStochastic oscillatorParabolic Stop and Reverse system
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
19 Views
0 Downloads
0 Favorites
sar_sto_ as_ao_stevejames_alert
//http://www.forexfactory.com/showthread.php?p=2181821#post2181821
#property indicator_chart_window
#property indicator_buffers 2

#property indicator_color1 RoyalBlue
#property indicator_color2 OrangeRed
#property indicator_width1 0
#property indicator_width2 0




extern bool AlertOn = false;
extern int SigOffset=15;               // pips above/below high/low to paint arrows

extern int StochK=5;                // Stochastic %K
extern int StochD=3;                // Stochastic %D 
extern int StochSlowing=3;          // Stochastic Slowing
extern int StochMethod=MODE_SMA;    // Stochastic Method
extern int StochPrice=0;            // Stochastic Price (0=low/high, 1=close/close)

extern double PSARStep=0.03;        // Parabolic SAR Step
extern double PSARMax=0.2;          // Parabolic SAR Maximum


datetime timenow = 0;
double SignalL[],SignalS[];

//===========================================================================================
//===========================================================================================
int init() 
{
 SetIndexBuffer(0,SignalL);
 SetIndexStyle(0, DRAW_ARROW);
 SetIndexArrow(0,SYMBOL_ARROWUP);
 SetIndexBuffer(1,SignalS);
 SetIndexStyle(1, DRAW_ARROW); 
 SetIndexArrow(1,SYMBOL_ARROWDOWN);
 
 
 return(0);
}
//===========================================================================================
//===========================================================================================
int deinit()
{
 return(0);
}
//===========================================================================================
//===========================================================================================

int start() 
{
 int i,imax,counted_bars=IndicatorCounted();
 double ao1,ac1,ao2,ac2,sm1,ss1,sm2,ss2,sar,sar2;
 if(counted_bars>0) imax=Bars-IndicatorCounted();
 else imax=Bars-1; 
 
 for(i=imax;i>=0;i--) 
 {
  SignalL[i]=EMPTY_VALUE;
  SignalS[i]=EMPTY_VALUE;
  
  ao1=iAO(NULL,0,i);
  ao2=iAO(NULL,0,i+1);
  ac1=iAC(NULL,0,i);
  ac2=iAC(NULL,0,i+1);
  
  sm1=iStochastic(NULL,0,StochK,StochD,StochSlowing,StochMethod,StochPrice,MODE_MAIN,i);
  sm2=iStochastic(NULL,0,StochK,StochD,StochSlowing,StochMethod,StochPrice,MODE_MAIN,i+1);  
  ss1=iStochastic(NULL,0,StochK,StochD,StochSlowing,StochMethod,StochPrice,MODE_SIGNAL,i);
  ss2=iStochastic(NULL,0,StochK,StochD,StochSlowing,StochMethod,StochPrice,MODE_SIGNAL,i+1);  
  
  sar=iSAR(NULL,0,PSARStep,PSARMax,i);
  sar2=iSAR(NULL,0,PSARStep,PSARMax,i+1);
 
  
 // Stochastic Notes

// Main = %K = Solid/Teal Line
// Signal = %D = Dashed/Red Line

// sm2<limit && sm1>limit = Main line crossed above limit 
// sm2>limit && sm1<limit = Main line crossed below limit 
// ss2<limit && ss1>limit = Signal line crossed above limit 
// ss2>limit && ss1<limit = Signal line crossed below limit

// sm1>ss1&&sm2<ss2 = Stochastic Cross Up
// sm1<ss1&&sm2>ss2 = Stochastic Cross Down

// AC & AO Notes

// ac1>ac2 = Green AC
// ac1<ac2 = Red AC
// ao1>ao2 = Green AO
// ao1<ao2 = Red AO
  
  if(sm1>ss1 && sar<=iOpen(NULL,0,i))
  {
   if(ac1>ac2 && sar2>=iOpen(NULL,0,i+1)) SignalL[i]=iLow(NULL,0,i)-SigOffset*Point;
  }
  
  else if(sm1<ss1 && sar>=iOpen(NULL,0,i))
  {
   if(ac1<ac2 && sar2<=iOpen(NULL,0,i+1))SignalS[i]=iHigh(NULL,0,i)+SigOffset*Point;
  }
  
 }

  if ( timenow != Time[0] && AlertOn )
   {
      if ( SignalL[0] != EMPTY_VALUE )
         {
            Alert( "Green Arrow on ", Symbol()," M",Period());
            timenow = Time[0];
         }    
      if ( SignalS[0] != EMPTY_VALUE )
         {
            Alert ( "Red Arrow on ", Symbol()," M",Period());
            timenow = Time[0];
         }      
   } 
 

 return(0);
}
//===========================================================================================
//===========================================================================================

Comments