//+------------------------------------------------------------------+
//|                                         Chart_on_other_chart.mq4 |
//|                      Copyright © 2011, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
#property indicator_chart_window
#property indicator_buffers 3
extern string cPair = "USDJPY";
extern color  bar_color = Yellow;
int counted_bars,wbpc,wfvb,r_bar,i;
double maxP,minP,scale;
double highP[],lowP[];
string obj_name[];
//+------------------------------------------------------------------+
int init()
   {
   SetIndexBuffer(0,highP);
   SetIndexBuffer(1,lowP);
   SetIndexBuffer(2,obj_name);
   return(0);
   }
//+------------------------------------------------------------------+
int deinit()
   {
   for(i=r_bar; i<wfvb; i++)
      {
      obj_name[i] = "bar_"+cPair+"_"+i;
      ObjectDelete(obj_name[i]);
      }
   Comment("");
   return(0);
   }
//+------------------------------------------------------------------+
int start()
   {
//   counted_bars=IndicatorCounted();
   wbpc = WindowBarsPerChart();
   wfvb = WindowFirstVisibleBar();
   r_bar = wfvb-wbpc;
   if(r_bar<0) r_bar=0;
   maxP = iHigh(cPair,Period(),iHighest(cPair,Period(),MODE_HIGH,wfvb,r_bar));
   minP = iLow (cPair,Period(),iLowest (cPair,Period(),MODE_LOW, wfvb,r_bar));
   scale = (WindowPriceMax()-WindowPriceMin())/(maxP-minP);
   for(i=r_bar; i<wfvb; i++)
      {
      obj_name[i] = "bar_"+cPair+"_"+i;
      ObjectCreate(obj_name[i],OBJ_TREND,0,0,0,0,0);
      highP[i]=(iHigh(cPair,Period(),i)-minP)*scale+WindowPriceMin();
      lowP[i] =(iLow (cPair,Period(),i)-minP)*scale+WindowPriceMin();
      ObjectSet(obj_name[i],OBJPROP_COLOR,bar_color);
      ObjectSet(obj_name[i],OBJPROP_TIME1,Time[i]);
      ObjectSet(obj_name[i],OBJPROP_PRICE1,highP[i]);
      ObjectSet(obj_name[i],OBJPROP_TIME2,Time[i]);
      ObjectSet(obj_name[i],OBJPROP_PRICE2,lowP[i]);
      ObjectSet(obj_name[i],OBJPROP_STYLE,STYLE_SOLID); 
      ObjectSet(obj_name[i],OBJPROP_BACK,True);
      ObjectSet(obj_name[i],OBJPROP_RAY,False);
      }
   WindowRedraw();
   Comment("Other Currency Pair on Chart : ",cPair);
   return(0);
   }
//+------------------------------------------------------------------+
             
            
            
            
Comments