//+------------------------------------------------------------------+
//| MODIFIED BY AVERY T. HORTON, JR AKA THERUMPLEDONE                |
//|   
// FPI DEVELOPED MY MICHAL KRESLIK WWW.KRESLIK.COM                   |
//|           FPI – Fractional Product Inefficiency                  |
//|                                                          FPI.mq4 |
//|                                         Developed by Coders Guru |
//|                                            http://www.xpworx.com |
//+------------------------------------------------------------------+

#property link      "http://www.xpworx.com"
#property copyright "Coders' Guru" 


#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Yellow


#property indicator_level1 1.0
#property indicator_levelcolor DimGray
#property indicator_levelwidth 1
#property indicator_levelstyle 0


extern string iPair1 = "GBPUSD" ;
extern string iPair2 = "USDJPY" ;
extern string iPair3 = "GBPJPY" ;  


double Main[] , PAIR1[] ,PAIR2[] ,PAIR3[] ;

//+------------------------------------------------------------------+
int init()
  {
   IndicatorBuffers(4); 
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,Main);
   
   SetIndexBuffer(1,PAIR1);
   SetIndexBuffer(2,PAIR2);
   SetIndexBuffer(3,PAIR3);

   ArrayInitialize(PAIR1,EMPTY_VALUE);
   ArrayInitialize(PAIR2,EMPTY_VALUE);
   ArrayInitialize(PAIR3,EMPTY_VALUE);
   ArrayInitialize(Main,EMPTY_VALUE);

   return(0);
  }

//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }

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

   ArrayCopySeries(PAIR1,MODE_CLOSE,iPair1,Period());
   ArrayCopySeries(PAIR2,MODE_CLOSE,iPair2,Period());
   ArrayCopySeries(PAIR3,MODE_CLOSE,iPair3,Period());

   int counted_bars=IndicatorCounted();
   int i = 0;

   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   int limit=Bars-counted_bars;
   
   for(i=0; i<limit; i++)
   {
       Main[i] = PAIR1[i]* PAIR2[i]* (1/PAIR3[i]);
   }

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