MA_PriceCcross





//+------------------------------------------------------------------+
//|                                                            MA_xP |
//+------------------------------------------------------------------+
//2008fxtsd  ki  
#property copyright ""
#property link      ""

#property indicator_chart_window
#property indicator_buffers 3

#property indicator_color1 DarkOliveGreen
#property indicator_color2 Red
#property indicator_color3 Aqua



extern int ma_period =9;
extern int ma_method =1;
extern int ma_price  =0;

extern int price     =0;
extern int breakBars =1;

extern bool PriceHiLoBreak = false;
extern bool drawLine       = false;

extern string   note_price = "0C 1O 2H 3L 4Md 5Tp 6WghC: Md(HL/2)4,Tp(HLC/3)5,Wgh(HLCC/4)6";
extern string   ma_method_ = "SMA0 EMA1 SMMA2 LWMA3";



double MA[];
double Buffer2[];
double Buffer3[];
double Price[];
double bbreak[];



//+---

int init()
  {
  IndicatorBuffers(5);
  
  SetIndexBuffer(0,MA);       SetIndexStyle(0,DRAW_LINE); 
  SetIndexBuffer(1,Buffer2);  SetIndexStyle(1,DRAW_LINE); 
  SetIndexBuffer(2,Buffer3);  SetIndexStyle(2,DRAW_LINE);
  
   if (drawLine)  {SetIndexStyle(1,DRAW_LINE);SetIndexStyle(2,DRAW_LINE);}
   else           {
   SetIndexStyle(1,DRAW_ARROW); SetIndexArrow(1,158); SetIndexEmptyValue (1,EMPTY_VALUE);
   SetIndexStyle(2,DRAW_ARROW); SetIndexArrow(2,158); SetIndexEmptyValue (2,EMPTY_VALUE);
                   }

  SetIndexBuffer(3,Price);    
  SetIndexBuffer(4,bbreak);    
  
  SetIndexDrawBegin(0,MA);
  SetIndexDrawBegin(1,MA);
  SetIndexDrawBegin(2,MA);


   return(0);
  }

//+----
int deinit()
{
   return(0);
}


int start()
{
   int i,limit;
   int counted_bars=IndicatorCounted();

   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;

   limit = Bars-counted_bars;

   for(i=limit; i>=0; i--)
   {

   MA[i]    =iMA(NULL,0,ma_period,0,ma_method,ma_price,i) ;
   Price[i] =iMA(NULL,0,1,0,1,price,i) ;


      
    bbreak[i]=EMPTY_VALUE;

if (PriceHiLoBreak)  {    
   if (High[i]<MA[i])   bbreak[i]=1;
   if (Low [i]>MA[i])   bbreak[i]=-1; 
                     } 
else  {
   if (Price[i]<MA[i])     bbreak[i]=1;
   if (Price[i]>MA[i])     bbreak[i]=-1;
      }


   double result = EMPTY_VALUE;

   if (breakBars<=0)breakBars=0;
   if (breakBars>=2)breakBars=2;

   if (breakBars==0)  {    
   if  (bbreak[i]>0)  result = 1;
   if  (bbreak[i]<0)  result =-1;
                      }
   if (breakBars==1)  {
   if  (bbreak[i]>0 && bbreak[i+1]>0)result = 1;
   if  (bbreak[i]<0 && bbreak[i+1]<0)result =-1;
                      }
   if (breakBars==2)  {
   if  (bbreak[i]>0 && bbreak[i+1]>0 && bbreak[i+2]>0)result = 1;
   if  (bbreak[i]<0 && bbreak[i+1]<0 && bbreak[i+2]<0)result =-1;
                      }



   Buffer2[i]  = EMPTY_VALUE; 
   Buffer3[i]  = EMPTY_VALUE;

   if (result>0)  Buffer2[i]= MA[i];
   if (result<0)  Buffer3[i]= MA[i];

   }
 
  
   return(0);
}
//+---------------



Sample





Analysis



Market Information Used:

Series array that contains the highest prices of each bar


Indicator Curves created:

Implements a curve of type DRAW_LINE

Implements a curve of type DRAW_ARROW

Indicators Used:

Moving average indicator


Custom Indicators Used:

Order Management characteristics:

Other Features: