Deprecated: Assigning the return value of new by reference is deprecated in /home/forex/public_html/wp-settings.php on line 520

Deprecated: Assigning the return value of new by reference is deprecated in /home/forex/public_html/wp-settings.php on line 535

Deprecated: Assigning the return value of new by reference is deprecated in /home/forex/public_html/wp-settings.php on line 542

Deprecated: Assigning the return value of new by reference is deprecated in /home/forex/public_html/wp-settings.php on line 578

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/forex/public_html/wp-settings.php on line 18
V :forex decode

V Archives

VTS_VG_TS_setka.mq4

//+------------------------------------------------------------------+
//|                                                          VTS.mq4 |
//|                                                             IZZY |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "IZZY"
#property link      ""

#define MAXBARSCOUNT 150000

#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Aqua
#property indicator_color2 Magenta
#property indicator_color3 Aqua
#property indicator_color4 Magenta
#property indicator_color5 Aqua
#property indicator_color6 Magenta
#property indicator_color7 Blue
#property indicator_color8 Red
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
//extern int Sb = 300;
extern int    PeriodAtr = 10;
extern double kATR      = 2.0;
extern int    GrupNum   = 4;

double VTS[MAXBARSCOUNT];
double VTS1[MAXBARSCOUNT];
double VTS2[MAXBARSCOUNT];
double VTS3[MAXBARSCOUNT];
double VTS4[MAXBARSCOUNT];
double VTS5[MAXBARSCOUNT];
double VTS6[MAXBARSCOUNT];
double VTS7[MAXBARSCOUNT];

double VTS8[MAXBARSCOUNT];
double VTS9[MAXBARSCOUNT];
double VTS10[MAXBARSCOUNT];
double VTS11[MAXBARSCOUNT];
double VTS12[MAXBARSCOUNT];
double VTS13[MAXBARSCOUNT];
double VTS14[MAXBARSCOUNT];
double VTS15[MAXBARSCOUNT];

double VTS16[MAXBARSCOUNT];
double VTS17[MAXBARSCOUNT];
double VTS18[MAXBARSCOUNT];
double VTS19[MAXBARSCOUNT];
double VTS20[MAXBARSCOUNT];
double VTS21[MAXBARSCOUNT];
double VTS22[MAXBARSCOUNT];
double VTS23[MAXBARSCOUNT];

double VTS24[MAXBARSCOUNT];
double VTS25[MAXBARSCOUNT];
double VTS26[MAXBARSCOUNT];
double VTS27[MAXBARSCOUNT];
double VTS28[MAXBARSCOUNT];
double VTS29[MAXBARSCOUNT];
double VTS_TS[MAXBARSCOUNT];
double VTS_TS1[MAXBARSCOUNT];

int init()
  {
//---- indicators
   IndicatorBuffers(8);
   if(GrupNum==1){
   SetIndexBuffer(0, VTS);
   SetIndexBuffer(1, VTS1);
   SetIndexBuffer(2, VTS2);
   SetIndexBuffer(3, VTS3);
   SetIndexBuffer(4, VTS4);
   SetIndexBuffer(5, VTS5);
   SetIndexBuffer(6, VTS6);
   SetIndexBuffer(7, VTS7);
   }
   if(GrupNum==2){
   SetIndexBuffer(0, VTS8);
   SetIndexBuffer(1, VTS9);
   SetIndexBuffer(2, VTS10);
   SetIndexBuffer(3, VTS11);
   SetIndexBuffer(4, VTS12);
   SetIndexBuffer(5, VTS13);
   SetIndexBuffer(6, VTS14);
   SetIndexBuffer(7, VTS15);
   }
   if(GrupNum==3){
   SetIndexBuffer(0, VTS16);
   SetIndexBuffer(1, VTS17);
   SetIndexBuffer(2, VTS18);
   SetIndexBuffer(3, VTS19);
   SetIndexBuffer(4, VTS20);
   SetIndexBuffer(5, VTS21);
   SetIndexBuffer(4, VTS22);
   SetIndexBuffer(5, VTS23);
   }
   if(GrupNum==4){
   SetIndexBuffer(0, VTS24);
   SetIndexBuffer(1, VTS25);
   SetIndexBuffer(2, VTS26);
   SetIndexBuffer(3, VTS27);
   SetIndexBuffer(4, VTS28);
   SetIndexBuffer(5, VTS29);
   SetIndexBuffer(6, VTS_TS);
   SetIndexStyle(6,DRAW_ARROW);
   SetIndexArrow(6,159);
   SetIndexBuffer(7, VTS_TS1);
   SetIndexStyle(7,DRAW_ARROW);
   SetIndexArrow(7,159);
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

int start()
  {
   int    counted_bars=IndicatorCounted();
//----

int    StartBars = Bars - counted_bars+2;
   //if (StartBars<Sb) StartBars = Sb;
   for(int i = StartBars; i>=0; i--){
       VTS[i] = (Close[i]-kATR*iATR(NULL,0,PeriodAtr,i));
       VTS1[i]= (Close[i]+kATR*iATR(NULL,0,PeriodAtr,i));
       }
   for(i = StartBars-1; i>0; i--){
       VTS2[i]= MathMax(VTS[i],VTS[i+1]);
       VTS3[i]= MathMin(VTS1[i],VTS1[i+1]);
       VTS4[i]= MathMax(VTS2[i],VTS2[i+1]);//VTS2[i+1];
       VTS5[i]= MathMin(VTS3[i],VTS3[i+1]);//VTS3[i+1];
       VTS6[i]= MathMax(VTS4[i],VTS4[i+1]);//VTS4[i+1];
       VTS7[i]= MathMin(VTS5[i],VTS5[i+1]);//VTS5[i+1];
       if (GrupNum >= 2){
          VTS8[i]= MathMax(VTS6[i],VTS6[i+1]);//VTS6[i+1];
          VTS9[i]= MathMin(VTS7[i],VTS7[i+1]);//VTS7[i+1];
          VTS10[i]= MathMax(VTS8[i],VTS8[i+1]);//VTS8[i+1];
          VTS11[i]= MathMin(VTS9[i],VTS9[i+1]);//VTS9[i+1];
          VTS12[i]= MathMax(VTS10[i],VTS10[i+1]);//VTS10[i+1];
          VTS13[i]= MathMin(VTS11[i],VTS11[i+1]);//VTS11[i+1];
          VTS14[i]= MathMax(VTS12[i],VTS12[i+1]);//VTS10[i+1];
          VTS15[i]= MathMin(VTS13[i],VTS13[i+1]);//VTS11[i+1];
          }
       if (GrupNum >= 3){
          VTS16[i]= MathMax(VTS14[i],VTS14[i+1]);//VTS6[i+1];
          VTS17[i]= MathMin(VTS15[i],VTS15[i+1]);//VTS7[i+1];
          VTS18[i]= MathMax(VTS16[i],VTS16[i+1]);//VTS6[i+1];
          VTS19[i]= MathMin(VTS17[i],VTS17[i+1]);//VTS7[i+1];
          VTS20[i]= MathMax(VTS18[i],VTS18[i+1]);//VTS6[i+1];
          VTS21[i]= MathMin(VTS19[i],VTS19[i+1]);//VTS7[i+1];
          VTS22[i]= MathMax(VTS20[i],VTS20[i+1]);//VTS6[i+1];
          VTS23[i]= MathMin(VTS21[i],VTS21[i+1]);//VTS7[i+1];
          }
       if (GrupNum >= 4){
          VTS24[i]= MathMax(VTS22[i],VTS22[i+1]);//VTS6[i+1];
          VTS25[i]= MathMin(VTS23[i],VTS23[i+1]);//VTS7[i+1];
          VTS26[i]= MathMax(VTS24[i],VTS24[i+1]);//VTS6[i+1];
          VTS27[i]= MathMin(VTS25[i],VTS25[i+1]);//VTS7[i+1];
          VTS28[i]= MathMax(VTS26[i],VTS26[i+1]);//VTS6[i+1];
          VTS29[i]= MathMin(VTS27[i],VTS27[i+1]);//VTS7[i+1];
          VTS_TS[i]  = VTS_TS[i+1];
          VTS_TS1[i] = VTS_TS1[i+1];
          if (Close[i]>VTS29[i]) {
              VTS_TS[i] = VTS28[i];
              VTS_TS1[i] = 0;//VTS_TS[i+1];
              }
          if (Close[i]<VTS28[i]) {
              VTS_TS1[i]= VTS29[i];
              VTS_TS[i] = 0;//VTS_TS1[i+1];
              }
          }
       }

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

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

VTS_VG_TS.mq4

//+------------------------------------------------------------------+
//|                                                          VTS.mq4 |
//|                                                                  |
//+------------------------------------------------------------------+
#define MAXBARSCOUNT 15000

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
//extern int Sb = 300;
extern int    PeriodAtr = 10;
extern double kATR      = 2.0;

double VTS[MAXBARSCOUNT];
double VTS1[MAXBARSCOUNT];
double VTS2[MAXBARSCOUNT];
double VTS3[MAXBARSCOUNT];
double VTS4[MAXBARSCOUNT];
double VTS5[MAXBARSCOUNT];
double VTS6[MAXBARSCOUNT];
double VTS7[MAXBARSCOUNT];

double VTS8[MAXBARSCOUNT];
double VTS9[MAXBARSCOUNT];
double VTS10[MAXBARSCOUNT];
double VTS11[MAXBARSCOUNT];
double VTS12[MAXBARSCOUNT];
double VTS13[MAXBARSCOUNT];
double VTS14[MAXBARSCOUNT];
double VTS15[MAXBARSCOUNT];

double VTS16[MAXBARSCOUNT];
double VTS17[MAXBARSCOUNT];
double VTS18[MAXBARSCOUNT];
double VTS19[MAXBARSCOUNT];
double VTS20[MAXBARSCOUNT];
double VTS21[MAXBARSCOUNT];
double VTS22[MAXBARSCOUNT];
double VTS23[MAXBARSCOUNT];

double VTS24[MAXBARSCOUNT];
double VTS25[MAXBARSCOUNT];
double VTS26[MAXBARSCOUNT];
double VTS27[MAXBARSCOUNT];
double VTS28[MAXBARSCOUNT];
double VTS29[MAXBARSCOUNT];
double VTS_TS[MAXBARSCOUNT];
double VTS_TS1[MAXBARSCOUNT];

int init()
  {
//---- indicators
   IndicatorBuffers(2);
   SetIndexBuffer(0, VTS_TS);
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,159);
   SetIndexBuffer(1, VTS_TS1);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,159);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

int start()  {
   int    counted_bars=IndicatorCounted();
//----

int    StartBars = Bars - counted_bars+2;
   //if (StartBars<Sb) StartBars = Sb;
   for(int i = StartBars; i>=0; i--){
       VTS[i] = (Close[i]-kATR*iATR(NULL,0,PeriodAtr,i));
       VTS1[i]= (Close[i]+kATR*iATR(NULL,0,PeriodAtr,i));
       }
   for(i = StartBars-1; i>0; i--){
       VTS2[i]= MathMax(VTS[i],VTS[i+1]);
       VTS3[i]= MathMin(VTS1[i],VTS1[i+1]);
       VTS4[i]= MathMax(VTS2[i],VTS2[i+1]);//VTS2[i+1];
       VTS5[i]= MathMin(VTS3[i],VTS3[i+1]);//VTS3[i+1];
       VTS6[i]= MathMax(VTS4[i],VTS4[i+1]);//VTS4[i+1];
       VTS7[i]= MathMin(VTS5[i],VTS5[i+1]);//VTS5[i+1];
       VTS8[i]= MathMax(VTS6[i],VTS6[i+1]);//VTS6[i+1];
       VTS9[i]= MathMin(VTS7[i],VTS7[i+1]);//VTS7[i+1];
       VTS10[i]= MathMax(VTS8[i],VTS8[i+1]);//VTS8[i+1];
       VTS11[i]= MathMin(VTS9[i],VTS9[i+1]);//VTS9[i+1];
       VTS12[i]= MathMax(VTS10[i],VTS10[i+1]);//VTS10[i+1];
       VTS13[i]= MathMin(VTS11[i],VTS11[i+1]);//VTS11[i+1];
       VTS14[i]= MathMax(VTS12[i],VTS12[i+1]);//VTS10[i+1];
       VTS15[i]= MathMin(VTS13[i],VTS13[i+1]);//VTS11[i+1];
       VTS16[i]= MathMax(VTS14[i],VTS14[i+1]);//VTS6[i+1];
       VTS17[i]= MathMin(VTS15[i],VTS15[i+1]);//VTS7[i+1];
       VTS18[i]= MathMax(VTS16[i],VTS16[i+1]);//VTS6[i+1];
       VTS19[i]= MathMin(VTS17[i],VTS17[i+1]);//VTS7[i+1];
       VTS20[i]= MathMax(VTS18[i],VTS18[i+1]);//VTS6[i+1];
       VTS21[i]= MathMin(VTS19[i],VTS19[i+1]);//VTS7[i+1];
       VTS22[i]= MathMax(VTS20[i],VTS20[i+1]);//VTS6[i+1];
       VTS23[i]= MathMin(VTS21[i],VTS21[i+1]);//VTS7[i+1];
       VTS24[i]= MathMax(VTS22[i],VTS22[i+1]);//VTS6[i+1];
       VTS25[i]= MathMin(VTS23[i],VTS23[i+1]);//VTS7[i+1];
       VTS26[i]= MathMax(VTS24[i],VTS24[i+1]);//VTS6[i+1];
       VTS27[i]= MathMin(VTS25[i],VTS25[i+1]);//VTS7[i+1];
       VTS28[i]= MathMax(VTS26[i],VTS26[i+1]);//VTS6[i+1];
       VTS29[i]= MathMin(VTS27[i],VTS27[i+1]);//VTS7[i+1];
       VTS_TS[i]  = VTS_TS[i+1];
       VTS_TS1[i] = VTS_TS1[i+1];
       if (Close[i]>VTS29[i]) {
           VTS_TS[i] = VTS28[i];
           VTS_TS1[i] = 0;//VTS_TS[i+1];
           }
       if (Close[i]<VTS28[i]) {
           VTS_TS1[i]= VTS29[i];
           VTS_TS[i] = 0;//VTS_TS1[i+1];
           }
       }//for(i = StartBars; i>0; i--){

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

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

VSI.mq4

/*
 * Filename:    VSI.mq4
 * Author:      DriverDan
 * Date:        Oct 20, 2005
 *
 * Description: Indicator that calculates volume per second (or period) and the corresponding MA.
 *              Uses volume per second since it will be uniform for all chart periods.
 *              Indicator seems to work best on 15m to 4h charts. IMHO, 1m and 5m periods are
 *              too short for valid results and 1d+ will show low periods for partial days on MT4.
 *
 * Version:     1.0
 *              Initial release
 */

#property copyright         "Copyright ?2005, DriverDan"
#property link              "superfunman2000@yahoo.com"

#property indicator_separate_window
#property indicator_minimum 0
#property indicator_buffers 2
#property indicator_color1  DodgerBlue
#property indicator_color2  Red

#define    SECINMIN         60  //Number of seconds in a minute

extern int vsiMAPeriod    = 7;  //Period for the moving average.
extern int vsiMAType      = 1;  //Moving average type. 0 = SMA, 1 = EMA, 2 = SMMA, 3 = LWMA
extern int showPerPeriod  = 0;  //0 = volume per second, 1 = volume per chart period
                                /* Volume per second allows you to compare values for different
                                   chart periods. Otherwise the values it will show will only be
                                   valid for the chart period you are viewing. The graph will
                                   look exactly the same but the values will be different. */

double vsiBuffer[];
double vsiMABuffer[];

/**
 * Initialization function
 */
int init() {
   string vsiTitle = "VSI(" + vsiMAPeriod + ")";
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(0, vsiBuffer);
   SetIndexBuffer(1, vsiMABuffer);
   IndicatorShortName(vsiTitle);
   SetIndexLabel(0, vsiTitle);
   SetIndexLabel(1, "vsiMA(" + vsiMAPeriod + ")");
   SetIndexDrawBegin(1, vsiMAPeriod);
   return(0);
}

/**
 * Main program
 */
int start() {
   int i, limit, timeDiff;
   int counted_bars = IndicatorCounted();

   if(counted_bars >= 0) {

      //If counted bars is greater than zero we must subtract 1 so we get in the right position
      if(counted_bars > 0) {
         counted_bars--;
      }

      //Only count bars we haven't already drawn
      limit = Bars - counted_bars;

      for(i = 0; i < limit; i++) {
         //Difference between the current time and the bar start
         timeDiff = CurTime() - Time[i];

         //If we are in the current bar and the tick doesn't fall exactly on the '00:00' min & sec
         if(i == 0 && timeDiff > 0) {
            vsiBuffer[i] = Volume[i] / timeDiff;
         } else {
            //Otherwise calculate the total bar volume divided by the total bar seconds
            vsiBuffer[i] = Volume[i] / (Time[i - 1] - Time[i]);
         }

         if(showPerPeriod == 1) {
            vsiBuffer[i] = vsiBuffer[i] * Period() * SECINMIN;
         }
      }

      //Fill the moving average buffer
      for(i = 0; i < limit; i++) {
         vsiMABuffer[i] = iMAOnArray(vsiBuffer, Bars, vsiMAPeriod, 0, vsiMAType, i);
      }
   }

   return(0);
}

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

volumeMA.mq4

//+------------------------------------------------------------------+
//|                            Volume with Custom Moving Average.mq4 |
//|                      Copyright ?2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2004, MetaQuotes Software Corp. Modified RonT"
#property link      "http://www.metaquotes.net/"

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 Green
#property indicator_color3 White

// User input
extern int MA_Period=13;
extern int MA_Shift=0;
extern int MA_Method=0;

// Buffers
double VolBuffer1[];  // value down
double VolBuffer2[];  // value up
double VolBuffer3[];  // moving average

//----
int ExtCountedBars=0;
int lastcolor=0;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   int    draw_begin;
   string short_name;

   // indicator buffers mapping, drawing settings and Shift

   // Histogram downArrow Red
   SetIndexBuffer(0,VolBuffer1);
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexShift(0,MA_Shift);

   // Histogram upArrow Green
   SetIndexBuffer(1,VolBuffer2);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexShift(1,MA_Shift);

   // Moving average line white
   SetIndexBuffer(2,VolBuffer3);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexShift(2,MA_Shift);

   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));

   if(MA_Period<2) MA_Period=2;
   draw_begin=MA_Period-1;

   switch(MA_Method)
     {
      case 1  : short_name="EMA(" ;  draw_begin=0; break;
      case 2  : short_name="SMMA(";                break;
      case 3  : short_name="LWMA(";                break;
      default : short_name="SMA(" ;  MA_Method=0;
     }
   IndicatorShortName(short_name+MA_Period+")");

   SetIndexDrawBegin(0,draw_begin);

   return(0);
  }

//+------------------------------------------------------------------+
//| Main                                                             |
//+------------------------------------------------------------------+
int start()
  {

   if(Bars<=MA_Period) return(0);
   ExtCountedBars=IndicatorCounted();

// check for possible errors
   if (ExtCountedBars<0) return(-1);

// last counted bar will be recounted
   if (ExtCountedBars>0) ExtCountedBars--;

   switch(MA_Method)
     {
      case 0 : sma();  break;
      case 1 : ema();  break;
      case 2 : smma(); break;
      case 3 : lwma();
     }
   return(0);
  }

//+------------------------------------------------------------------+
//| Simple Moving Average                                            |
//+------------------------------------------------------------------+
void sma()
  {
   double sum=0;
   int    i,pos=Bars-ExtCountedBars-1;

   // initial accumulation
   if(pos<MA_Period) pos=MA_Period;
   for(i=1;i<MA_Period;i++,pos--)
      sum+=Volume[pos];

   while(pos>=0)
     {
      sum+=Volume[pos];
      VolBuffer3[pos]=sum/MA_Period;
	   sum-=Volume[pos+MA_Period-1];
	   Vcolor(pos);
 	   pos--;
     }

   // zero initial bars
   if(ExtCountedBars<1)
      for(i=1;i<MA_Period;i++) VolBuffer1[Bars-i]=0;
  }

//+------------------------------------------------------------------+
//| Exponential Moving Average                                       |
//+------------------------------------------------------------------+
void ema()
  {
   double pr=2.0/(MA_Period+1);
   int    pos=Bars-2;

   if(ExtCountedBars>2) pos=Bars-ExtCountedBars-1;

   while(pos>=0)
     {
      if(pos==Bars-2) VolBuffer3[pos+1]=Volume[pos+1];
      VolBuffer3[pos]=Volume[pos]*pr+VolBuffer3[pos+1]*(1-pr);
      Vcolor(pos);
 	   pos--;
     }
  }

//+------------------------------------------------------------------+
//| Smoothed Moving Average                                          |
//+------------------------------------------------------------------+
void smma()
  {
   double sum=0;
   int    i,k,pos=Bars-ExtCountedBars+1;

   pos=Bars-MA_Period;
   if(pos>Bars-ExtCountedBars) pos=Bars-ExtCountedBars;
   while(pos>=0)
     {
      if(pos==Bars-MA_Period)
        {
         // initial accumulation
         for(i=0,k=pos;i<MA_Period;i++,k++)
           {
            sum+=Volume[k];
            // zero initial bars
            VolBuffer3[k]=0;
           }
        }
      else sum=VolBuffer3[pos+1]*(MA_Period-1)+Volume[pos];
      VolBuffer3[pos]=sum/MA_Period;
 	   pos--;
     }
  }

//+------------------------------------------------------------------+
//| Linear Weighted Moving Average                                   |
//+------------------------------------------------------------------+
void lwma()
  {
   double sum=0.0,lsum=0.0;
   double price;
   int    i,weight=0,pos=Bars-ExtCountedBars-1;
//---- initial accumulation
   if(pos<MA_Period) pos=MA_Period;
   for(i=1;i<=MA_Period;i++,pos--)
     {
      price=Volume[pos];
      sum+=price*i;
      lsum+=price;
      weight+=i;
     }
//---- main calculation loop
   pos++;
   i=pos+MA_Period;
   while(pos>=0)
     {
      VolBuffer3[pos]=sum/weight;
      if(pos==0) break;
      pos--;
      i--;
      price=Volume[pos];
      sum=sum-lsum+price*MA_Period;
      lsum-=Volume[i];
      lsum+=price;
     }
//---- zero initial bars
   if(ExtCountedBars<1)
      for(i=1;i<MA_Period;i++) VolBuffer3[Bars-i]=0;
  }

//+------------------------------------------------------------------+
//| Color depends on gain or loss and previous volume                |
//+------------------------------------------------------------------+
// 1 - histo down red
// 2 - histo up green
// 3 - line white

void Vcolor(int p)
  {

   if (Volume[p+1]>Volume[p])
     {
      VolBuffer1[p]=Volume[p];
      VolBuffer2[p]=0;
      lastcolor=Red;
     }

   if (Volume[p+1]<Volume[p])
     {
      VolBuffer1[p]=0;
      VolBuffer2[p]=Volume[p];
      lastcolor=Green;
     }

   if (Volume[p+1]==Volume[p])
     {
      if ( lastcolor==Red )
        {
         VolBuffer1[p]=Volume[p];
         VolBuffer2[p]=0;
        }
      if ( lastcolor==Green )
        {
         VolBuffer1[p]=0;
         VolBuffer2[p]=Volume[p];
        }
     }
  }

//+------------------------------------------------------------------+

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

Volume with custom MA.mq4

//+------------------------------------------------------------------+
//|                            Volume with Custom Moving Average.mq4 |
//|                      Copyright ?2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2004, MetaQuotes Software Corp. Modified RonT"
#property link      "http://www.metaquotes.net/"

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 Green
#property indicator_color3 White

// User input
extern int MA_Period=13;
extern int MA_Shift=0;
extern int MA_Method=0;

// Buffers
double VolBuffer1[];  // value down
double VolBuffer2[];  // value up
double VolBuffer3[];  // moving average

//----
int ExtCountedBars=0;
int lastcolor=0;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   int    draw_begin;
   string short_name;

   // indicator buffers mapping, drawing settings and Shift

   // Histogram downArrow Red
   SetIndexBuffer(0,VolBuffer1);
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexShift(0,MA_Shift);

   // Histogram upArrow Green
   SetIndexBuffer(1,VolBuffer2);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexShift(1,MA_Shift);

   // Moving average line white
   SetIndexBuffer(2,VolBuffer3);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexShift(2,MA_Shift);

   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));

   if(MA_Period<2) MA_Period=2;
   draw_begin=MA_Period-1;

   switch(MA_Method)
     {
      case 1  : short_name="EMA(" ;  draw_begin=0; break;
      case 2  : short_name="SMMA(";                break;
      case 3  : short_name="LWMA(";                break;
      default : short_name="SMA(" ;  MA_Method=0;
     }
   IndicatorShortName(short_name+MA_Period+")");

   SetIndexDrawBegin(0,draw_begin);

   return(0);
  }

//+------------------------------------------------------------------+
//| Main                                                             |
//+------------------------------------------------------------------+
int start()
  {

   if(Bars<=MA_Period) return(0);
   ExtCountedBars=IndicatorCounted();

// check for possible errors
   if (ExtCountedBars<0) return(-1);

// last counted bar will be recounted
   if (ExtCountedBars>0) ExtCountedBars--;

   switch(MA_Method)
     {
      case 0 : sma();  break;
      case 1 : ema();  break;
      case 2 : smma(); break;
      case 3 : lwma();
     }
   return(0);
  }

//+------------------------------------------------------------------+
//| Simple Moving Average                                            |
//+------------------------------------------------------------------+
void sma()
  {
   double sum=0;
   int    i,pos=Bars-ExtCountedBars-1;

   // initial accumulation
   if(pos<MA_Period) pos=MA_Period;
   for(i=1;i<MA_Period;i++,pos--)
      sum+=Volume[pos];

   while(pos>=0)
     {
      sum+=Volume[pos];
      VolBuffer3[pos]=sum/MA_Period;
   sum-=Volume[pos+MA_Period-1];
   Vcolor(pos);
    pos--;
     }

   // zero initial bars
   if(ExtCountedBars<1)
      for(i=1;i<MA_Period;i++) VolBuffer1[Bars-i]=0;
  }

//+------------------------------------------------------------------+
//| Exponential Moving Average                                       |
//+------------------------------------------------------------------+
void ema()
  {
   double pr=2.0/(MA_Period+1);
   int    pos=Bars-2;

   if(ExtCountedBars>2) pos=Bars-ExtCountedBars-1;

   while(pos>=0)
     {
      if(pos==Bars-2) VolBuffer3[pos+1]=Volume[pos+1];
      VolBuffer3[pos]=Volume[pos]*pr+VolBuffer3[pos+1]*(1-pr);
      Vcolor(pos);
    pos--;
     }
  }

//+------------------------------------------------------------------+
//| Smoothed Moving Average                                          |
//+------------------------------------------------------------------+
void smma()
  {
   double sum=0;
   int    i,k,pos=Bars-ExtCountedBars+1;

   pos=Bars-MA_Period;
   if(pos>Bars-ExtCountedBars) pos=Bars-ExtCountedBars;
   while(pos>=0)
     {
      if(pos==Bars-MA_Period)
        {
         // initial accumulation
         for(i=0,k=pos;i<MA_Period;i++,k++)
           {
            sum+=Volume[k];
            // zero initial bars
            VolBuffer3[k]=0;
           }
        }
      else sum=VolBuffer3[pos+1]*(MA_Period-1)+Volume[pos];
      VolBuffer3[pos]=sum/MA_Period;
    pos--;
     }
  }

//+------------------------------------------------------------------+
//| Linear Weighted Moving Average                                   |
//+------------------------------------------------------------------+
void lwma()
  {
   double sum=0.0,lsum=0.0;
   double price;
   int    i,weight=0,pos=Bars-ExtCountedBars-1;
//---- initial accumulation
   if(pos<MA_Period) pos=MA_Period;
   for(i=1;i<=MA_Period;i++,pos--)
     {
      price=Volume[pos];
      sum+=price*i;
      lsum+=price;
      weight+=i;
     }
//---- main calculation loop
   pos++;
   i=pos+MA_Period;
   while(pos>=0)
     {
      VolBuffer3[pos]=sum/weight;
      if(pos==0) break;
      pos--;
      i--;
      price=Volume[pos];
      sum=sum-lsum+price*MA_Period;
      lsum-=Volume[i];
      lsum+=price;
     }
//---- zero initial bars
   if(ExtCountedBars<1)
      for(i=1;i<MA_Period;i++) VolBuffer3[Bars-i]=0;
  }

//+------------------------------------------------------------------+
//| Color depends on gain or loss and previous volume                |
//+------------------------------------------------------------------+
// 1 - histo down red
// 2 - histo up green
// 3 - line white

void Vcolor(int p)
  {

   if (Volume[p+1]>Volume[p])
     {
      VolBuffer1[p]=Volume[p];
      VolBuffer2[p]=0;
      lastcolor=Red;
     }

   if (Volume[p+1]<Volume[p])
     {
      VolBuffer1[p]=0;
      VolBuffer2[p]=Volume[p];
      lastcolor=Green;
     }

   if (Volume[p+1]==Volume[p])
     {
      if ( lastcolor==Red )
        {
         VolBuffer1[p]=Volume[p];
         VolBuffer2[p]=0;
        }
      if ( lastcolor==Green )
        {
         VolBuffer1[p]=0;
         VolBuffer2[p]=Volume[p];
        }
     }
  }

//+------------------------------------------------------------------+

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

Volatility.Pivot.mq4

//+------------------------------------------------------------------+
//|                                             Volatility.Pivot.mq4 |
//+------------------------------------------------------------------+
#property copyright "thanks to S.B.T. (Japan)"
#property link      "http://sufx.core.t3-ism.net/" //<<< convert this from VT, thanks mate !!!

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 DarkSeaGreen
//---- input parameters
extern double     atr_range=100;
extern double     ima_range = 10;
extern double     atr_factor=3;
extern int        Mode = 0;
extern double     DeltaPrice = 30;

//---- buffers
double TrStop[];
double ATR[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0, DRAW_LINE,STYLE_SOLID,1);
   SetIndexBuffer(0, TrStop);

   SetIndexStyle(1, DRAW_NONE);
   SetIndexBuffer(1, ATR);

   string short_name = "!! RisenbergVolatilityCapture";
   IndicatorShortName(short_name);
   SetIndexLabel(1,"range base");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars = IndicatorCounted();
   int limit;
   int i;

   double DeltaStop;

   limit = Bars;

   for(i = 0; i < limit; i ++) {
      ATR[i] = iATR(NULL,0,atr_range,i);
   }

   for(i = limit - 1; i >= 0; i --) {
      if (Mode == 0) {
         DeltaStop = iMAOnArray(ATR,0,ima_range,0,MODE_EMA,i) * atr_factor;
         //DeltaStop = iATR(NULL,0,atr_range,i) * atr_factor;
      } else {
         DeltaStop = DeltaPrice*Point;
      }

      if (Close[i] == TrStop[i + 1]) {
         TrStop[i] = TrStop[i + 1];
      } else {
         if (Close[i+1]<TrStop[i+1] && Close[i]<TrStop[i+1]) {
            TrStop[i] = MathMin(TrStop[i + 1], Close[i] + DeltaStop);
         } else {
            if (Close[i+1]>TrStop[i+1] && Close[i]>TrStop[i+1]) {
               TrStop[i] = MathMax(TrStop[i+1], Close[i] - DeltaStop);
            } else {
               if (Close[i] > TrStop[i+1]) TrStop[i] = Close[i] - DeltaStop; else TrStop[i] = Close[i] + DeltaStop;
            }
         }
      }
   }

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

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

VMesquita.mq4

#property  copyright "VMesquita"
#property  indicator_chart_window        // an indicator is drawn in the main chart window
#property  indicator_buffers 1
int limit;

int init ()
  {
   return(0);
  }

int deinit()
  {
   return(0);
  }

int start()
      {
   double O,C,H,L,O1,C1,H1,L1,O2,C2,H2,L2;
   string text;
   int counted_bars=IndicatorCounted();
   limit=Bars-counted_bars;

   if(counted_bars<0) {
        Alert("No Bars..");
        return(-1);
   }

   for(int i=1; i<limit; i++) {
        O=iOpen(NULL,0,i);
        C=iClose(NULL,0,i);
        H=iHigh(NULL,0,i);
        L=iLow(NULL,0,i);

        O1=iOpen(NULL,0,i-1);
        C1=iClose(NULL,0,i-1);
        H1=iHigh(NULL,0,i-1);
        L1=iLow(NULL,0,i-1);

        O2=iOpen(NULL,0,i+1);
        C2=iClose(NULL,0,i+1);
        H2=iHigh(NULL,0,i+1);
        L2=iLow(NULL,0,i+1);

        text="";
        if(((H-L)>4*(O-C))&&((C-L)/(0.001+H-L)>=0.75)&&((O-L)(0.001+H-L)>=0.75)) text="Hang";
        if(((H-L)>3*(O-C))&&((C-L)/(0.001+H-L)>0.6)&&((O-L)(0.001+H-L)>0.6)) text="Hammer";
        if(((H-L)>3*(O-C))&&((H-C)/(0.001+H-L)>0.6)&&((H-O)(0.001+H-L)>0.6)) text="IHammer";
        if((O2>C2)&&((O2-C2)/(0.001+H2-L2)>0.6)&&(C2>O1)&&(O1>C1)&&((H1-L1)>(3*(C1-O1)))&&(C>O)&&(O>O1)) text="MStar";
        if((O>C)&&(H==0)&&(C==L)) text="LMarubozu";
        if((C>O)&&(H==C)&&(O==L)) text="HMarubozu";
        if((C1==O1)&&(C2>O2)&&(O>C)&&(L1>H2)&&(L1>H)) text="ABaby";
        if((C1==O1)&&(O2>C2)&&(C>O)&&(L2>H1)&&(L>H1)) text="ABaby";
        if((C2>O2)&&((C2-O2)/(0.001+H2-L2)>0.6)&&(C2<O1)&&(C1>O1)&&((H1-L1)>(3*(C1-O1)))&&(O>C)&&(O<O1)) text="EStar";
        if((C1>O1)&&(((C1+O1)/2)>C)&&(O>C)&&(O>C1)&&(C>O1)&&((O-C)(0.001+(H-L))>0.6)) text="DCloud";
        if((C1>O1)&&(O>C)&&(O>=C1)&&(O1>=C)&&((O-C)>(C1-O1))) text="Engulf";
        if((O1>C1)&&(C>O)&&(C>=O1)&&(C1>=0)&&((C-O)>(O1-C1))) text="Engulf";
        if((O1>C1)&&(C>O)&&(C<=O1)&&(C1<=0)&&((C-O)<(O1-C1))) text="Harami";
        if((C1>O1)&&(O>C)&&(O<=C1)&&(O1<=C)&&((O-C)<(C1-O1))) text="Harami";
        if((C1<O1)&&(((O1+C1)/2)<C)&&(O<C)&&(O<C1)&&(C<O1)&&((C-O)(.001+(H-L))>0.6)) text="Piercing";
        if((C>O*1.01)&&(C1>O1*1.01) &&(C2>O2*1.01) &&(C>C1) && (C1>C2) &&(O<C1&&O>O1) &&(O1<C2&&O1>O2) &&(((H-C)/(H-L))<0.2) &&(((H1-C1)/(H1-L1))<0.2)&&(((H2-C2)/(H2-L2))<0.2))  text="Three White Soldiers";
        if(((H-L)>4*(O-C))&&((H-C)/(0.001+H-L)>= 0.75)&&((H-O)(0.001+H-L)>=0.75)) text="SStar";
        if(C==0) text="Doji";
        //If we found a special candlem write in the Chart
        if(text!="")
        {
        ObjectCreate(DoubleToStr(i,0)+" label", OBJ_TEXT, 0, Time[i], H);
        ObjectSetText(DoubleToStr(i,0)+" label", text, 10, "Arial", Yellow);
        }
      }
}

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

Vertical Line.mq4

//+------------------------------------------------------------------+
//|                                                Vertical Line.mq4 |
//|                              Copyright ?2006, fxid10t@yahoo.com |
//|                               http://www.forexprogramtrading.com |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2006, fxid10t@yahoo.com"
#property link      "http://www.forexprogramtrading.com"
#property indicator_chart_window

extern int Place.Line.Bars.Back=1;
extern color Line.Color=Orange;
extern int Line.Style=1;
extern int Line.Width=1;
extern bool Draw.as.Background=true;

int init(){return(0);}
int deinit(){ObjectDelete("V-Line"); return(0);}
int start(){
ObjectDelete("V-Line");
ObjectCreate("V-Line",OBJ_VLINE,0,Time[Place.Line.Bars.Back],Bid);
ObjectSet("V-Line",OBJPROP_COLOR,Line.Color);
ObjectSet("V-Line",OBJPROP_STYLE,Line.Style);
ObjectSet("V-Line",OBJPROP_WIDTH,Line.Width);
ObjectSet("V-Line",OBJPROP_BACK,Draw.as.Background);
return(0);}
//+------------------------------------------------------------------+

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

Vegas1HR.mq4

//+------------------------------------------------------------------+
//|                                                        Vegas.mq4 |
//|                                                           Mr.Bah |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Mr.Bah"
#property link      ""

#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Green
#property indicator_color2 Blue
#property indicator_color3 Red
#property indicator_color4 Red
#property indicator_color5 Red
#property indicator_color6 Red
#property indicator_color7 Red
#property indicator_color8 Red
//---- input parameters
extern bool      Alerts=true;
extern int       RiskModel=1;
extern int       MA1=144;
extern int       MA2=169;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
double ExtMapBuffer6[];
double ExtMapBuffer7[];
double ExtMapBuffer8[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,ExtMapBuffer4);
   SetIndexStyle(4,DRAW_LINE);
   SetIndexBuffer(4,ExtMapBuffer5);
   SetIndexStyle(5,DRAW_LINE);
   SetIndexBuffer(5,ExtMapBuffer6);
   SetIndexStyle(6,DRAW_LINE);
   SetIndexBuffer(6,ExtMapBuffer7);
   SetIndexStyle(7,DRAW_LINE);
   SetIndexBuffer(7,ExtMapBuffer8);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int    counted_bars=IndicatorCounted();
  //---- check for possible errors
   if(counted_bars<0) return(-1);
  //---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
  //---- main loop
     for(int i=0; i<limit; i++)
       {
        //---- ma_shift set to 0 because SetIndexShift called abowe
         ExtMapBuffer1[i]=iMA(NULL,0,144,0,MODE_EMA,PRICE_CLOSE,i);
         ExtMapBuffer2[i]=iMA(NULL,0,169,0,MODE_EMA,PRICE_CLOSE,i);

         //Model #1 34,55,89
         if(RiskModel==1)
         {
            ExtMapBuffer3[i]=ExtMapBuffer2[i]+34*Point;
            ExtMapBuffer4[i]=ExtMapBuffer2[i]+55*Point;
            ExtMapBuffer5[i]=ExtMapBuffer2[i]+89*Point;

            ExtMapBuffer6[i]=ExtMapBuffer2[i]-34*Point;
            ExtMapBuffer7[i]=ExtMapBuffer2[i]-55*Point;
            ExtMapBuffer8[i]=ExtMapBuffer2[i]-89*Point;
         }

         //Model #2 55,89,144
         if(RiskModel==2)
         {
            ExtMapBuffer3[i]=ExtMapBuffer2[i]+55*Point;
            ExtMapBuffer4[i]=ExtMapBuffer2[i]+89*Point;
            ExtMapBuffer5[i]=ExtMapBuffer2[i]+144*Point;

            ExtMapBuffer6[i]=ExtMapBuffer2[i]-55*Point;
            ExtMapBuffer7[i]=ExtMapBuffer2[i]-88*Point;
            ExtMapBuffer8[i]=ExtMapBuffer2[i]-144*Point;
         }

          //Model #3 89,144,233
         if(RiskModel==3)
         {
            ExtMapBuffer3[i]=ExtMapBuffer2[i]+89*Point;
            ExtMapBuffer4[i]=ExtMapBuffer2[i]+144*Point;
            ExtMapBuffer5[i]=ExtMapBuffer2[i]+233*Point;

            ExtMapBuffer6[i]=ExtMapBuffer2[i]-89*Point;
            ExtMapBuffer7[i]=ExtMapBuffer2[i]-144*Point;
            ExtMapBuffer8[i]=ExtMapBuffer2[i]-233*Point;
         }

          //Model #4 144,233,377
         if(RiskModel==4)
         {
            ExtMapBuffer3[i]=ExtMapBuffer2[i]+144*Point;
            ExtMapBuffer4[i]=ExtMapBuffer2[i]+233*Point;
            ExtMapBuffer5[i]=ExtMapBuffer2[i]+377*Point;

            ExtMapBuffer6[i]=ExtMapBuffer2[i]-144*Point;
            ExtMapBuffer7[i]=ExtMapBuffer2[i]-233*Point;
            ExtMapBuffer8[i]=ExtMapBuffer2[i]-377*Point;
         }

         Comment("\nRISK MODEL #",RiskModel," (1-4)\n\nEMA144 - ",ExtMapBuffer1[limit],"\nEMA169 - ",ExtMapBuffer2[limit],
         "\n\nF+1 - ",ExtMapBuffer3[limit],"\nF+2 - ",ExtMapBuffer4[limit],
         "\nF+3 - ",ExtMapBuffer5[limit],"\n\nF-1 - ",ExtMapBuffer6[limit],
         "\nF-2 - ",ExtMapBuffer7[limit],"\nF-3 - ",ExtMapBuffer8[limit]);
       }

       //+--------------------------------------------------------------------------+
       //-                          ALERTS    PlaySound("alert.wav");               -
       //+--------------------------------------------------------------------------+
      if(Alerts)
      {
         if(Close[i]==ExtMapBuffer1[i] || Close[i]==ExtMapBuffer2[i])
         {
            PlaySound("alert.wav");
         }
         if(Close[i]==ExtMapBuffer3[i] || Close[i]==ExtMapBuffer4[i] || Close[i]==ExtMapBuffer5[i])
         {
            PlaySound("alert.wav");
         }
         if(Close[i]==ExtMapBuffer6[i] || Close[i]==ExtMapBuffer7[i] || Close[i]==ExtMapBuffer8[i])
         {
            PlaySound("alert.wav");
         }
      }

  //---- done

//----

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

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

Var Mov Avg.mq4

//+------------------------------------------------------------------+
//|                                                   AMA&AMAsig.mq4 |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2004, by GOODMAN & Mstera ?AF "

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Sienna
#property indicator_color2 Yellow
#property indicator_color3 Magenta

//---- input parameters
extern int       periodAMA=52;
extern int       nfast=5;
extern int       nslow=20;
extern double    G=2.0;
extern double    dK=2.0;

//---- buffers
double kAMAbuffer[];
double kAMAupsig[];
double kAMAdownsig[];

//+------------------------------------------------------------------+

int    cbars=0, prevbars=0, prevtime=0;

double slowSC,fastSC;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE,0,2);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,159);
   SetIndexStyle(2,DRAW_ARROW);
   SetIndexArrow(2,159);
   //SetIndexDrawBegin(0,nslow+nfast);
   SetIndexBuffer(0,kAMAbuffer);
   SetIndexBuffer(1,kAMAupsig);
   SetIndexBuffer(2,kAMAdownsig);

   IndicatorDigits(4);

   //slowSC=0.064516;
   //fastSC=0.2;
   //cbars=IndicatorCounted();
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    i,pos=0;
   double noise=0.000000001,AMA,AMA0,signal,ER;
   double dSC,ERSC,SSC,ddK;

   if (prevbars==Bars) return(0);

//---- TODO: add your code here
   slowSC=(2.0 /(nslow+1));
   fastSC=(2.0 /(nfast+1));
   cbars=IndicatorCounted();
   if (Bars<=(periodAMA+2)) return(0);
//---- check for possible errors
   if (cbars<0) return(-1);
//---- last counted bar will be recounted
   if (cbars>0) cbars--;
   pos=Bars-periodAMA-2;
   AMA0=Close[pos+1];
   while (pos>=0)
     {
      if(pos==Bars-periodAMA-2) AMA0=Close[pos+1];
      signal=MathAbs(Close[pos]-Close[pos+periodAMA]);
      noise=0.000000001;
      for(i=0;i<periodAMA;i++)
       {
        noise=noise+MathAbs(Close[pos+i]-Close[pos+i+1]);
       }
      ER =signal/noise;
      dSC=(fastSC-slowSC);
      ERSC=ER*dSC;
      SSC=ERSC+slowSC;
      AMA=AMA0+(MathPow(SSC,G)*(Close[pos]-AMA0));
      kAMAbuffer[pos]=AMA;

      ddK=(AMA-AMA0);
      if ((MathAbs(ddK)) > (dK*Point) && (ddK > 0)) kAMAupsig[pos] =AMA; else kAMAupsig[pos]=0;
      if ((MathAbs(ddK)) > (dK*Point) && (ddK < 0)) kAMAdownsig[pos]=AMA; else kAMAdownsig[pos]=0;

      AMA0=AMA;
      pos--;
     }
//----
   prevbars=Bars;
   return(0);
  }

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

 Page 1 of 2  1  2 »

Tweet This Post links powered by Tweet This v1.3.9, a WordPress plugin for Twitter.