mymql_new_ma

Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
mymql_new_ma
//+------------------------------------------------------------------+
//|                                     mymql_new_ma.mq4             |
//|                                    Copyright © 2012 Deleu Sergey |
//|                                             http://www.mymql.ru  |
//+------------------------------------------------------------------+
//#property copyright "Copyright © 2012 Deleu Sergey"
//#property link      "http://www.mymql.ru"


#property indicator_chart_window    
#property indicator_buffers 2      
#property indicator_color1 Blue  
#property indicator_color2 Red


extern int pr=10;   // Period
extern int level=100;
extern string  method="close"; // open, close, high, low
extern int shift1=0;
extern int shift2=0;

double Buf_0[],Buf_1[];
int md;
//--------------------------------------------------------------------
int init()
  {
   md=StringGetChar(method,0);

   SetIndexBuffer(0,Buf_0);
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
   SetIndexShift(0,shift1);

   SetIndexBuffer(1,Buf_1);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
   SetIndexShift(1,shift2);
   return;
  }
//--------------------------------------------------------------------
int start()
  {
   int i,Counted_bars,k,ks=0;
   double mamod1,pc;

   int counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   int limit=Bars-counted_bars;
   if(counted_bars==0) limit-=1+pr;

   i=limit;

   while(i>=0)
     {
      mamod1=0;  ks=0; pc=0;

      for(k=0;k<pr;k++)
        {

         switch(md) // Âûáîð ìåòîäà âû÷èñëåíèÿ
           {
            case 'c': pc=Close[i+k];
            break;
            case 'o' : pc=Open[i+k];
            break;
            case 'l' : pc=Low[i+k];
            break;
            case  'h' : pc=High[i+k];
            break;
           }
         //--------------
         mamod1+=((pr-k)*pc);  // Ðåàëèçàöèÿ ôîðìóëû
         ks+=(pr-k);
        }

      mamod1/=ks;
      // ----------------  
      Buf_0[i]=mamod1; //Blue
      Buf_1[i]=mamod1+level*Point;// Red      

      i--;
     }
   return;
  }
//--------------------------------------------------------------------

Comments