problem with iClose (I think)

 

Hi all,  I'm trying to send myself an alert when the difference between the closing price of the GBPJPY and EURJPY reaches a desired amount.  I trying to use iClose to reference the close of the EURJPY while on a GBPJPY chart.  I think the syntax is wrong, but I'm stuck.  Thank you in advance for the help.

 

//+------------------------------------------------------------------+
//|                                                  Hedge Alert.mq4 |
//|                        Copyright 2012, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Mark Arnold 2012"


#property indicator_chart_window
//--- input parameters
extern string SubSymbol = "EURJPY";
extern int    Timeframe=1;
extern int   GBPJPYprice=0;
extern int   EURJPYprice=0;
extern int   pips=10;
extern bool      Alerts=false;
extern bool   Text=false;
extern int NumBars=0;
datetime last_alert = 0;
datetime last_sendmail = 0;

int start()

  {
      double iClose("SubSymbol","timeframe",1);
  
      int counted_bars=IndicatorCounted();
  
      for(int i=NumBars; i>=0; i--)
      
      {
      if((Close[i+1]-iClose)>=(GBPJPYprice-EURJPYprice+(pips/100)))
   
      
      {if(Alerts==True && last_alert!=Time[1])
            {
            last_alert = Time[1];
            Alert(Symbol(), " ", Period()," Hedge");
               
            }
            
       if(Text==True && last_sendmail!=Time[1])
           {
           last_sendmail = Time[1];
            
            string subject   = StringConcatenate (Symbol(), " ", Period());
            string some_text = " Hedge";

               SendMail( subject,  some_text);
        }}
   }}
   return(0); 
 


Please edit your comment and re-post your code using SRC button. That way, your codes is much easier to read by other user and unnecessary error won't occur. 

 
phi.nuts:


Please edit your comment and re-post your code using SRC button. That way, your codes is much easier to read by other user and unnecessary error won't occur. 


okay  thanks I didn't know how to do that
 

Hi,

you have to put a variable her

double closevalue iClose("SubSymbol","timeframe",1);

And work with the closevalue variable.

But I think your code is strange.

Where are you getting the values for GBPJPYprice and EURJPYprice from??

 
Hi Sunshineh, Thanks for the help!  I'm entering the GBPJPYprice and EURJPYprice myself.  But now that you mention it, there is probably better way to do that.  Any advise in that regard would be great!