xMeterMTF_Ind





/*
xMeterMTF_Ind.mq4     
Copyright © 2007, MetaQuotes Software Corp.     
Price Meter System™ ©GPL     

Hartono Setiono
   5/17/2007 Redsigned based on xMeter_mini.mq4 indicator
*/

#property copyright "x Meter System™ ©GPL"
#property link      "forex-tsd dot com"
#include <stdlib.mqh>
#include <stderror.mqh> 

#define ARRSIZE  12                     // number of pairs !!!DON'T CHANGE THIS NUMBER!!!
#define PAIRSIZE 7                      // number of currencies !!!DON'T CHANGE THIS NUMBER!!!
#define TABSIZE  10                     // scale of currency's power !!!DON'T CHANGE THIS NUMBER!!!
#define ORDER    2                      // available type of order !!!DON'T CHANGE THIS NUMBER!!!

extern bool AccountIsIBFXmini = false;
extern int mTimeFrame = 1440;
extern int mPeriod=3;

   string aPair[ARRSIZE]   = {"EURUSD","GBPUSD","AUDUSD","USDJPY","USDCHF","USDCAD",
                              "EURJPY","EURGBP","EURCHF","EURAUD","GBPJPY","GBPCHF"};
   string aMajor[PAIRSIZE] = {"USD","EUR","GBP","CHF","CAD","AUD","JPY"};
   color  aColor[PAIRSIZE] = {Red, Yellow, DarkOrange, DodgerBlue, Aqua, Magenta, DeepPink};
   int    aMajorPos[PAIRSIZE] = {130, 110, 90, 70, 50, 30, 10};
   string aOrder[ORDER]    = {"BUY ","SELL "};
   int    aTable[TABSIZE]  = {0,3,10,25,40,50,60,75,90,97};                 // grade table for currency's power
   
double curr1[];
double curr2[];
double curr3[];
double curr4[];
double curr5[];
double curr6[];
double curr7[];

//+------------------------------------------------------------------+
//     expert initialization function                                |       
//+------------------------------------------------------------------+
int init()
  {
   int i;
   
   IndicatorBuffers(PAIRSIZE);

   SetIndexBuffer(0,curr1);
   SetIndexBuffer(1,curr2);
   SetIndexBuffer(2,curr3);
   SetIndexBuffer(3,curr4);
   SetIndexBuffer(4,curr5);
   SetIndexBuffer(5,curr6);
   SetIndexBuffer(6,curr7);
   
   for(i=0; i<PAIRSIZE; i++) 
   { 
     SetIndexStyle(i, DRAW_LINE, STYLE_SOLID, 1, aColor[i]);
     SetIndexLabel(i, aPair[i]);
   }

   return(0);                                                               // end of init function
  }
//+------------------------------------------------------------------+
//     expert deinitialization function                              |       
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);                                                               // end of deinit function
  }
//+------------------------------------------------------------------+
//     expert start function                                         |       
//+------------------------------------------------------------------+
int start()
  {
   double aMeter[PAIRSIZE];
   double aHigh[ARRSIZE];
   double aLow[ARRSIZE];
   double aBid[ARRSIZE];
   double aAsk[ARRSIZE];
   double aRatio[ARRSIZE];
   double aRange[ARRSIZE];
   double aLookup[ARRSIZE];
   double aStrength[ARRSIZE];
   double point;
   int    index, pindex, cnt;
   string mySymbol;
   double cmeter;
   int i,j,limit,counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   
   for(i=0; i<limit; i++)
   {
     
    for (index = 0; index < ARRSIZE; index++)                                // initialize all pairs required value 
      {
      RefreshRates();                                                       // refresh all currency's instrument
      if (AccountIsIBFXmini)
         mySymbol = aPair[index]+'m';                                       // Add "m for IBFX mini
      else
         mySymbol = aPair[index];                        
      point            = GetPoint(mySymbol);                                // get a point basis
      aHigh[index]     = iHigh(mySymbol,mTimeFrame,iHighest(mySymbol,mTimeFrame,MODE_HIGH,mPeriod,0));   // find highest
      aLow[index]      = iLow(mySymbol,mTimeFrame,iLowest(mySymbol,mTimeFrame,MODE_LOW,mPeriod,0));   // find lowest
      aBid[index]      = MarketInfo(mySymbol,MODE_BID);                 // set a last bid
      aAsk[index]      = MarketInfo(mySymbol,MODE_ASK);                 // set a last ask
      aRange[index]    = MathMax((aHigh[index]-aLow[index])/point,1);       // calculate range today
      aRatio[index]    = (aBid[index]-aLow[index])/aRange[index]/point;     // calculate pair ratio
      aLookup[index]   = iLookup(aRatio[index]*100);                        // set a pair grade
      aStrength[index] = 9-aLookup[index];                                  // set a pair strengh
      } 

   // calculate all currencies meter         
   for (pindex=0; pindex<PAIRSIZE; pindex++)
   { 
     cnt=0; 
     cmeter=0;
     for (index = 0; index < ARRSIZE; index++)                                // initialize all pairs required value 
     {
       if (StringSubstr(aPair[index],0,3)==aMajor[pindex])
       {
        cnt++;
        cmeter = cmeter + aLookup[index];
       }
       if (StringSubstr(aPair[index],3,3)==aMajor[pindex])
       {
        cnt++;
        cmeter = cmeter + aStrength[index];
       }
       if (cnt>0) aMeter[pindex]=NormalizeDouble(cmeter / cnt,1); else aMeter[pindex]=-1;
       //Print(aMajor[pindex],":",StringSubstr(aPair[index],1,3),":",StringSubstr(aPair[index],4,3),":",cmeter,":",cnt);
     }
   }
 }
 return(0);                                                               // end of start funtion
}
//+------------------------------------------------------------------+
//     expert custom function                                        |       
//+------------------------------------------------------------------+    
  
double GetPoint(string mSymbol)
{
 double myPoint = 0.0001, YenPoint = 0.01;
 string mySymbol;
 if (StringSubstr(mySymbol,3,3) == "JPY") return (YenPoint);
 return(myPoint);

}
  
int iLookup(double ratio)                                                   // this function will return a grade value
  {                                                                         // based on its power.
   int   index=-1, i;
   
   if      (ratio <= aTable[0]) index = 0;
   else {
     for (i=1; i<TABSIZE; i++) if(ratio < aTable[i]) {index=i-1;  break; }
     if(index==-1) index=9;
   }
   return(index);                                                           // end of iLookup function
  }
  





Sample





Analysis



Market Information Used:

Series array that contains the highest prices of each bar
Series array that contains the lowest prices of each bar


Indicator Curves created:


Implements a curve of type DRAW_LINE

Indicators Used:



Custom Indicators Used:

Order Management characteristics:

Other Features: