//+------------------------------------------------------------------+
//|                                              DeltaCandlHedge.mq4 |
//|                               Copyright © 2012, Vladimir Hlystov |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2012, Vladimir Hlystov"
#property link      "cmillion@narod.ru"


#property indicator_separate_window

#property indicator_buffers 1
#property indicator_color1 Red
#property indicator_width1 4

#property indicator_level1	0
#property indicator_level2	7
#property indicator_level3	7
#property indicator_levelcolor	Silver
#property indicator_levelwidth	0
#property indicator_levelstyle	2

extern string SIMBOL2="";

double Delta[],POINT1,POINT2;
string SIMBOL1;
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
   SIMBOL1 = Symbol();
   if (SIMBOL1=="SILVER" && SIMBOL2=="") SIMBOL2="GOLD";
   if (SIMBOL1=="GOLD" && SIMBOL2=="") SIMBOL2="SILVER";
   if (SIMBOL1=="EURUSD" && SIMBOL2=="") SIMBOL2="GBPUSD";
   if (SIMBOL1=="GBPUSD" && SIMBOL2=="") SIMBOL2="EURUSD";
   
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,Delta);
   
   short_name="DeltaCandlHedge("+SIMBOL1+" "+SIMBOL2+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
   IndicatorDigits(0);
   POINT1 = MarketInfo(SIMBOL1,MODE_POINT);
   POINT2 = MarketInfo(SIMBOL2,MODE_POINT);
   return(0);
  }
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
int start()
{
   int counted_bars=IndicatorCounted();
   if(counted_bars>0) counted_bars--;
   int limit=Bars-counted_bars-1;
   for(int i=limit; i>=0; i--)
   {
      Delta[i] = (iClose(SIMBOL1,0,i)-iOpen(SIMBOL1,0,i))/POINT1-(iClose(SIMBOL2,0,i)-iOpen(SIMBOL2,0,i))/POINT2;
   }
   return(0);
}
//+------------------------------------------------------------------+

