Navigation:Home > Content >

xMeterMTF_IG.mq4

Time: 2015-06-24 | Download file:xMeterMTF_IG.mq4

/*
xMeterMTF.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"
#property  indicator_chart_window
#property  indicator_buffers 0

#include 
#include  

#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 corner=2;
/*extern*/ bool LoopOnInit=false;

/* You can change any of the following arrays */
   string aTradePair[]= {"GBPJPY"};
   string aPair[]   = {"EURUSD","GBPUSD","AUDUSD","USDJPY","USDCHF","USDCAD",
                       "EURJPY","EURGBP","EURCHF","EURAUD","GBPJPY","GBPCHF"};
                       
/* The following can also be changed but both must have the same dimension */
   string aMajor[] = {"USD","EUR","GBP","CHF","CAD","AUD","JPY"};
   int    aMajorPos[] = {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

int PairCount;
int CurrencyCount;
double aMeter[];
double aHigh[];
double aLow[];
double aBid[];
double aAsk[];
double aRatio[];
double aRange[];
double aLookup[];
double aStrength[];
int aIndex[2][];

//+------------------------------------------------------------------+
//     expert initialization function                                |       
//+------------------------------------------------------------------+
int init()
  {
   int err,lastError, ps;
   PairCount=ArrayRange(aPair,0);
   CurrencyCount=ArrayRange(aMajor,0);
   ps=ArrayRange(aMajorPos,0);
   if(CurrencyCount!=ps) Print("The size of array aMajor is not equals to aMajorPos");

   ArrayResize(aMeter,CurrencyCount);
   ArrayResize(aHigh,PairCount);
   ArrayResize(aLow,PairCount);
   ArrayResize(aBid,PairCount);
   ArrayResize(aAsk,PairCount);
   ArrayResize(aRatio,PairCount);
   ArrayResize(aRange,PairCount);
   ArrayResize(aLookup,PairCount);
   ArrayResize(aStrength,PairCount);
   
   init_tradepair_index();
  
//----
   initGraph();
   if (LoopOnInit)
   {
      while (true)                                                           // infinite loop for main program
      {
        if (IsConnected()) main();
        if (!IsConnected()) objectBlank();
        WindowRedraw();
        Sleep(1000);                                                          // give your PC a breath
      }
   }
//----
   return(0);                                                               // end of init function
  }
//+------------------------------------------------------------------+
//     expert deinitialization function                              |       
//+------------------------------------------------------------------+
int deinit()
  {
//----
   ObjectsDeleteAll(0,OBJ_LABEL);
   Print("shutdown error - ",ErrorDescription(GetLastError()));                               // system is detached from platform
//----
   return(0);                                                               // end of deinit function
  }
//+------------------------------------------------------------------+
//     expert start function                                         |       
//+------------------------------------------------------------------+
int start()
  {
//----
   if (!LoopOnInit) main();
//----
   return(0);                                                               // end of start funtion
  }
//+------------------------------------------------------------------+
//     expert custom function                                        |       
//+------------------------------------------------------------------+    
void main()                                                                 // this a control center
  {
//----
   double point;
   int    index, pindex, cnt;
   string mySymbol;
   double cmeter;
     
   for (index = 0; index < PairCount; 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]     = MarketInfo(mySymbol,MODE_HIGH); //iHigh(mySymbol,mTimeFrame,iHighest(mySymbol,mTimeFrame,MODE_HIGH,mPeriod,0));   // find highest
      aLow[index]      = MarketInfo(mySymbol,MODE_LOW); //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; pindex0) aMeter[pindex]=NormalizeDouble(cmeter / cnt,1); else aMeter[pindex]=-1;
     }
   }
             
   objectBlank();
   
   for (pindex=0; pindex 0) ObjectSet(aMajor[pindex]+"_5",OBJPROP_COLOR,Red);
  if (value > 2) ObjectSet(aMajor[pindex]+"_4",OBJPROP_COLOR,Orange);
  if (value > 4) ObjectSet(aMajor[pindex]+"_3",OBJPROP_COLOR,Gold);   
  if (value > 6) ObjectSet(aMajor[pindex]+"_2",OBJPROP_COLOR,Green);
  if (value > 7) ObjectSet(aMajor[pindex]+"_1",OBJPROP_COLOR,Lime);
  ObjectSet(aMajor[pindex],OBJPROP_COLOR,Blue);
  ObjectSetText(aMajor[pindex]+"p",DoubleToStr(value,1),8,"Arial Narrow",Black);
}
  
void paintLine()
  {
   ObjectSet("line1",OBJPROP_COLOR,Black);
   ObjectSet("line2",OBJPROP_COLOR,Black);
  }

Recommend