Why cant I read another symbol off chart?

 

In the following why is it when I input another symbol different to the chart the Indicator is placed on to it doesn't return that symbol?

#property indicator_chart_window
#property indicator_buffers 1

extern color LabelColor  = LightSkyBlue;
extern int Corner        = 1;
extern color UpColor     = LimeGreen;
extern color DownColor   = Red;
extern color NetralColor = Silver;

int TF[]={43200,10080,1440,240,60,30,15,5,1};
string Label[]={"MN","W1","D1","H4","H1","M30","M15","M5","M1"};
double ExtBuff[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexBuffer(0,ExtBuff,INDICATOR_DATA);
   
   for(int i=0;i<=8;i++)   // 9 times we set something ? probably each timeframe
   {
      ObjectCreate(Label[i],OBJ_LABEL,0,0,0);   // We use typical ObjectCreate  with enumeration OBJ_LABEL
      ObjectCreate(Label[i]+" ARROW",OBJ_LABEL,0,0,0);
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   for(int i=0;i<=8;i++)
   {
      ObjectDelete(Label[i]);
      ObjectDelete(Label[i]+" ARROW");
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

double OCandle(int tf){double OC=iOpen("GBPUSD",tf,0);return(OC);}
double CCandle(int tf){double CC=iClose("GBPUSD",tf,0);return(CC);}

void ObSetLabel(string name,string text,int x,int y)
   {
      ObjectSetText(name,text,10,"Impact",LabelColor);
      ObjectSet(name,OBJPROP_CORNER,Corner);
      ObjectSet(name,OBJPROP_XDISTANCE,x);
      ObjectSet(name,OBJPROP_YDISTANCE,y);
      ObjectSet(name,OBJPROP_BACK,0);
   }
void ObSetArrow(string name,int code,int x,int y,color clr)
   {
      ObjectSetText(name,CharToStr(code),14,"Wingdings",clr);      
      ObjectSet(name,OBJPROP_CORNER,Corner);
      ObjectSet(name,OBJPROP_XDISTANCE,x);
      ObjectSet(name,OBJPROP_YDISTANCE,y);
      ObjectSet(name,OBJPROP_BACK,0);
   }

int start()
  {
   
//----
   
   int X_Start=0;
   int Y_Start=20;
   color clr;
   for(int i=0;i<=8;i++)
      {
         X_Start=X_Start+30;        
         
         ObSetLabel(Label[i],Label[i],X_Start,Y_Start);
         
         if(CCandle(TF[i])>OCandle(TF[i])){clr=UpColor;ExtBuff[i]=1;}
         else if(CCandle(TF[i])<OCandle(TF[i])){clr=DownColor;ExtBuff[i]=2;}
         else {clr=NetralColor;ExtBuff[i]=0;}
         
         ObSetArrow(Label[i]+" ARROW",110,X_Start,Y_Start+20,clr);
       }
//----
   return(0);
  }
 

Does the symbol exist?

Does it have a prefix or suffix?

 
Print(tf);
 
Keith Watford:

Does the symbol exist?

Does it have a prefix or suffix?


Im not sure what you mean? The symbol GBPUSD is for the pound to the dollar market? It is as shown on MT4 platform. 
 
Stephen Reynolds: Im not sure what you mean? The symbol GBPUSD is for the pound to the dollar market? It is as shown on MT4 platform. 
  1. Not necessary. Broker's use a variety of naming patterns: EURUSD, EURUSDm, EURUSDi, "EURUSD.", "EURUSD..", "EUR.USD", "EUR/USD", "EURUSD.stp", EURUSDct, "EURUSD.G", "EURUSD+", EURUSDc, and EURUSDpro at least. If your market isn't exactly "GBPUSD" then it can't work.
  2. If your chart isn't the cable, then you have to handle 4066/4073 errors. See Download history in MQL4 EA - MQL4 and MetaTrader 4 - MQL4 programming forum
 

Thanks guys for the help. But, Ive sort of found the problem? Why is it when I use 1 as the shift value of 3rd parameter

EG iOpen("GBPUSD",tf,1);

it actually works okay with any other symbol. But when I use 0 it only works with the chart its put onto. EG if chart EURUSD and I input EURUSD into the parameter it works fine?

Could anyone explain this?

This is a problem ive noticed in the past in my coding but ive always accepted it and entered 1 instead of 0.

I say it again The shift values don't seem to work at 0 (the current bar) but are okay 1 and all other previous bars?

 
iClose("GBPUSD",tf,0)

You want to know the close price of the current bar ?

Trying to look into the future?

The current bar 0 is usually always open and when it closes its shifted to the next (open) bar.

 
Marco vd Heijden:

You want to know the close price of the current bar ?

Trying to look into the future?

The current bar 0 is usually always open and when it closes its shifted to the next (open) bar.


Thanks ofcourse! I couldn't see for looking!
 
Stephen Reynolds: it only works
  1. "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here.
  2. You have to handle 4066/4073 errors as already mentioned.


Marco vd Heijden:

You want to know the close price of the current bar ?

Trying to look into the future?

The current bar 0 is usually always open and when it closes its shifted to the next (open) bar.

Close[0] is the current Bid, always. No future required.
 
whroeder1:





Close[0] is the current Bid, always. No future required.

Then tell me the Close of today's D1.

It just may differ from the current Bid.

 
Marco vd Heijden: Then tell me the Close of today's D1.
  1. I can't predict the future, but if there are no more ticks today, Close[0] (any timeframe,) which is exactly the Bid, will be today's D1 close. Period!
  2. iClose("GBPUSD",tf,0)
    You've missed the point. Let me say it again, ""Close[0] is the current Bid, always." There is nothing wrong what that code.
Reason: