FXSniperMA_SW





//+------------------------------------------------------------------+
//|                                                   FX Sniper's MA |
//|                                      Copyright © 2006, FX Sniper |
//|FXSniperMA_SW                                                     |
//|Mod. by a1ra                                                      |
//+------------------------------------------------------------------+
#property  copyright "Copyright © 2006, FX Sniper "
#property  link      "http://www.metaquotes.net/"

//---- indicator settings
#property indicator_separate_window
#property  indicator_buffers 2
#property indicator_color1 Red    
#property indicator_color2 Lime
#property indicator_width1 1
#property indicator_width2 1
#property indicator_maximum 2
#property indicator_minimum 0
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[],ma[];
string objectma1;

extern double  IndicatorValue = 1;
extern string note1 = "Moving Average Type";
extern string note2 = "0=Simple,1=Exponential";
extern string note3 = "2=Smooth,3=Linear Weighted";
extern int MAType = 3;
extern string note4 = "Moving Average Period";
extern int MAPeriod = 3;
extern int MAShift = 0;
extern int PriceType=0; 


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- 2 additional buffers are used for counting.
   IndicatorBuffers(5);
   
//---- drawing settings
   SetIndexBuffer(0,ExtMapBuffer1); SetIndexStyle(0,DRAW_ARROW); SetIndexArrow(0,167);
   SetIndexBuffer(1,ExtMapBuffer2); SetIndexStyle(1,DRAW_ARROW); SetIndexArrow(1,167);
   SetIndexBuffer(2,ma);   
   
   switch(MAType)
     {
      case 1 : short_name="EMA";  break;
      case 2 : short_name="SMMA"; break;
      case 3 : short_name="LWMA"; break;
      default :
         MAType=0;
         short_name="SMA";
     }
   string shortname = "FXSniperMA ("+short_name+","+MAPeriod+","+PriceType+")";
   IndicatorShortName (shortname);
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
int deinit()
  {
  ObjectDelete(objectma1);  
  return(0);
  }
//+------------------------------------------------------------------+
int start()

  {  
      for(int i = Bars-10; i >= 0; i--)
           {
               ma[i]=iMA(NULL,0,MAPeriod,MAShift,MAType,PriceType,i);
           }     
     
     for(int shift = Bars-10; shift >= 0; shift--)
     {  
       ExtMapBuffer1[shift] = IndicatorValue; 
       ExtMapBuffer2[shift] = IndicatorValue; 
       //Print (ma[shift]);
        if (ma[shift] > ma[shift+1])
        {
        ExtMapBuffer1[shift] = EMPTY_VALUE;
        ExtMapBuffer2[shift+1] =IndicatorValue; 
        
        }
       else if (ma[shift] < ma[shift+1]) 
        {
        ExtMapBuffer2[shift] = EMPTY_VALUE; 
        ExtMapBuffer1[shift+1] =IndicatorValue; 
        }

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







Sample





Analysis



Market Information Used:



Indicator Curves created:

Implements a curve of type DRAW_ARROW


Indicators Used:

Moving average indicator


Custom Indicators Used:

Order Management characteristics:

Other Features: