Navigation´╝ÜHome > Content >

Twiggs_Money_Flow_ORG.mq4

Time: 2012-03-08 | Download file:Twiggs_Money_Flow_ORG.mq4

//+------------------------------------------------------------------+
//|                                            Twiggs Money Flow.mq4 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright " Mr. Colin Twiggs"
#property link      "http://www.incrediblecharts.com/technical/twiggs_money_flow.php"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Lime

#property indicator_level1 0
#property indicator_level2 0.1
#property indicator_level3 0.25
#property indicator_level4 -0.1
#property indicator_level5 -0.25


//---- input parameters
extern int       Prd=21;
//---- buffers
double ExtMapBuffer1[];
double WildersBuffer[];
double WVBuffer[];
double ADVBuffer[];
double SmV[];
double SmA[];


bool startup;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(6);

   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexBuffer(1,WildersBuffer);
   SetIndexBuffer(2,WVBuffer);
   SetIndexBuffer(3,ADVBuffer);
   SetIndexBuffer(4,SmV);
   SetIndexBuffer(5,SmA);
   
//----
   startup=true;

   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   startup=false;
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   
   double TRH, TRL, TR, ADV, WV, Wilders;
   int N1=1, N2=1;

   
   int counted_bars=IndicatorCounted();
   
   if (counted_bars<0) return(-1);      // check for possible errors
   if (counted_bars>0) counted_bars--;  // last counted bar will be recounted
   int limit= Bars - counted_bars;
//----





   for(int i = 0; i < limit; i++)
   {
      TRH= iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, N1, i)) + N2*Point;
      TRL= iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, N1, i)) - N2*Point;
      TR=  TRH-TRL;
      if (TR==0)
      {
         ADV= ((Close[i]-TRL)-(TRH-Close[i]))/ (999999)*Volume[i];
         ADVBuffer[i]=ADV;
      }
      else
      {
         ADV= ((Close[i]-TRL)-(TRH-Close[i]))/ (TR)*Volume[i];
         ADVBuffer[i]=ADV;
      }
      
      WV= Volume[i] + (iVolume(NULL,0,i-1)*0);
      WVBuffer[i]= WV;         

      Wilders=iMA(NULL,0,(Prd*2)-1,0,MODE_EMA,PRICE_CLOSE,i);
      WildersBuffer[i]= Wilders;
      
                     
      //UpperBuf[i] = iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, N, i)) + N2*Point;
     // LowerBuf[i] = iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, N, i)) - N2*Point;
   }



 for(i = 0; i < limit; i++)
   {
                  
      SmV[i]= iMAOnArray(WVBuffer,0,(Prd*2)-1,0,MODE_EMA,i);
      SmA[i]= iMAOnArray(ADVBuffer,0,(Prd*2)-1,0,MODE_EMA,i);
      
      if (WV!=0)
      {
         ExtMapBuffer1[i]=SmA[i]/SmV[i];
      }
 
                  
      //UpperBuf[i] = iHigh(NULL, 0, iHighest(NULL, 0, MODE_HIGH, N, i)) + N2*Point;
     // LowerBuf[i] = iLow(NULL, 0, iLowest(NULL, 0, MODE_LOW, N, i)) - N2*Point;
   }
   
   
   

   startup=false;

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


Recommend