syst_ ao_sto__m260_sig_alert1.2

syst_ ao_sto__m260_sig_alert1.2
Price Data Components
Series array that contains the lowest prices of each barSeries array that contains the highest prices of each bar
Indicators Used
Bill Williams Awesome oscillatorStochastic oscillatorIndicator of the average true range
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
0 Views
0 Downloads
0 Favorites
syst_ ao_sto__m260_sig_alert1.2
//http://www.forexfactory.com/showthread.php?p=2181821#post2181821
//syst_ha_ma_sto_stevejames_alert.mq4

//http://www.fxfisherman.com/forums/forex-metatrader/trading-systems/5310-stochastic-trading-system-highly-profitable.html
//2009fxtsd

#property indicator_chart_window
#property indicator_buffers 6

#property indicator_color1 RoyalBlue
#property indicator_color2 OrangeRed
#property indicator_color3 Blue
#property indicator_color4 Red
#property indicator_color5 RoyalBlue
#property indicator_color6 OrangeRed





#property indicator_width1 0
#property indicator_width2 0




extern bool    AlertOn = false;
extern double  arrOffset=0.7;      // above/below high/low to paint arrows

extern int StochK=10;               // Stochastic %K
extern int StochD=1;                // 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 int StoObLv =60;           
extern int StoOsLv =40;           

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


datetime timenow;
   static datetime extime;
double SignalL[],SignalS[];
double SignalLlv[],SignalSlv[];
double SignalLex[],SignalSex[];

//===========================================================================================
//===========================================================================================
int init() 
{
 SetIndexBuffer(0,SignalL);
 SetIndexBuffer(1,SignalS);
 
 SetIndexStyle(0, DRAW_ARROW);
 SetIndexStyle(1, DRAW_ARROW); 

 SetIndexArrow(0,SYMBOL_ARROWUP);
 SetIndexArrow(1,SYMBOL_ARROWDOWN);
  
 SetIndexEmptyValue(0,EMPTY_VALUE);
 SetIndexEmptyValue(1,EMPTY_VALUE);



 SetIndexBuffer(2,SignalLex);
 SetIndexBuffer(3,SignalSex);
 
 SetIndexStyle(2, DRAW_ARROW);
 SetIndexStyle(3, DRAW_ARROW); 

 SetIndexArrow(2,SYMBOL_STOPSIGN);
 SetIndexArrow(3,SYMBOL_STOPSIGN);
  
 SetIndexEmptyValue(2,EMPTY_VALUE);
 SetIndexEmptyValue(3,EMPTY_VALUE);


 SetIndexStyle(4, DRAW_LINE);
 SetIndexStyle(5, DRAW_LINE); 

  SetIndexBuffer(4,SignalLlv);
  SetIndexBuffer(5,SignalSlv);

 
 
                        
 
 
 return(0);
}
//===========================================================================================
//===========================================================================================
int deinit()
{
 return(0);
}
//===========================================================================================
//===========================================================================================

int start() 
{
 int i,limit,counted_bars=IndicatorCounted();
// double ac0,ac1,ao0,ao1,ss0,ss1,sm0,sm1,ss2,sar0,sar1;
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
           limit=Bars-counted_bars;
  
  for(i=limit; i>=0; i--)
  {
  
//  double   ac0=iAC(NULL,0,i);
//  double   ac1=iAC(NULL,0,i+1);
  double ao0=iAO(NULL,0,i);
  double ao1=iAO(NULL,0,i+1);
  double ao2=iAO(NULL,0,i+2);

//  double   sar0=iSAR(NULL,0,PSARStep,PSARMax,i);
//  double   sar1=iSAR(NULL,0,PSARStep,PSARMax,i+1);
  
  double   sm0=iStochastic(NULL,0,StochK,StochD,StochSlowing,StochMethod,StochPrice,MODE_MAIN,i);
  double   sm1=iStochastic(NULL,0,StochK,StochD,StochSlowing,StochMethod,StochPrice,MODE_MAIN,i+1);  
  double   ss0=iStochastic(NULL,0,StochK,StochD,StochSlowing,StochMethod,StochPrice,MODE_SIGNAL,i);
  double   ss1=iStochastic(NULL,0,StochK,StochD,StochSlowing,StochMethod,StochPrice,MODE_SIGNAL,i+1);  
  
//--- 

   bool paup=false;
      if    (Close[i]>Close[i+1])   paup=true;  else paup=false;

   bool padn=false;
      if    (Close[i]<Close[i+1])   padn=true;  else padn=false;
 
  
 // 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
  
          
      SignalL[i]=EMPTY_VALUE;
      SignalS[i]=EMPTY_VALUE;
      SignalLlv[i]=SignalLlv[i+1];
      SignalSlv[i]=SignalSlv[i+1];
 
//  if(sar0<iOpen(NULL,0,i)&& sar1>iOpen(NULL,0,i+1))
//      {}
      if( sm0>StoObLv && sm1<StoObLv && paup ) //ao0>ao1  &&
      {
                        SignalL[i]  = iLow(NULL,0,i)-arrOffset*iATR(NULL,0,7,i);
                SignalLlv[i]= iHigh(NULL,0,i)+10*Point;SignalSlv[i]= EMPTY_VALUE;

      }
   //     else           SignalL[i]= EMPTY_VALUE;
  
  
//  if(sar0>iOpen(NULL,0,i)&& sar1<iOpen(NULL,0,i+1))
//      {}
      if (  sm0<StoOsLv && sm1>StoOsLv  )//  && ao0<ao1
         {
                        SignalS[i]  = iHigh(NULL,0,i)+arrOffset*iATR(NULL,0,7,i);
                SignalSlv[i]= iLow(NULL,0,i)-10*Point; SignalLlv[i]= EMPTY_VALUE;


          }

if (SignalLlv[i]!= EMPTY_VALUE && ao2<ao1 && ao1>ao0)SignalLex[i]= iLow(NULL,0,i)-10*Point;
if (SignalSlv[i]!= EMPTY_VALUE && ao2>ao1 && ao1<ao0)SignalSex[i]= iHigh(NULL,0,i)+10*Point;


 
 //       else            SignalS[i]= EMPTY_VALUE; 

   if(AlertOn)
   {
 
      if ( timenow != Time[0])
         {
         if ( SignalL[0] != EMPTY_VALUE )
            {
            Alert( "StoAO: EntryLongSignal ", Symbol()," M",Period());
            timenow = Time[0];
            }    
         if ( SignalS[0] != EMPTY_VALUE )
            {
            Alert ( "StoAO: EntryShortSignal ", Symbol()," M",Period());
            timenow = Time[0];
            }      
         }
   
   
      if (extime != Time[0] )
         {
         if ( SignalLex[0] != EMPTY_VALUE )
            {
            Alert( "StoAO: ExitLongSignal ", Symbol()," M",Period());
            extime = Time[0];
            }    
         if ( SignalSex[0] != EMPTY_VALUE )
            {
            Alert ( "StoAO: ExitShortSignal ", Symbol()," M",Period());
            extime = Time[0];
            }      
         } 
   }


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

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---