My indicator does not work on yen pairs!?

 

Has anybody ever run into this before, I searched the forums but nothing came up. Any help is appreciated. Thanks.

 
 
//+------------------------------------------------------------------+
//|                                               IndicatorAR(1).mq4 |
//|                              Thomas Brittain (thomas@pamexx.com) |
//|                                                   www.pamexx.com |
//+------------------------------------------------------------------+
#property copyright "Thomas Brittain (thomas@pamexx.com)"
#property link      "www.pamexx.com"

#property indicator_chart_window
#property indicator_buffers 5
#property indicator_color1 Purple
#property indicator_color2 Blue
#property indicator_color3 Blue
#property indicator_color4 Red
#property indicator_color5 Red

// Arrays for indicator buffers
double BufferArrayClose[], BufferArrayUpper[], BufferArrayLower[], BufferArrayHighStop[], BufferArrayLowStop[];  

double phi0, phi1;
double rbar;
double rsum;
double rbar_back1;
double rsum_back1;
double a;
double b;
double forecast0;
int i;
double variance;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
  SetIndexBuffer(0, BufferArrayClose);
  SetIndexStyle(0,DRAW_ARROW,STYLE_SOLID,2);
  
  SetIndexBuffer(1, BufferArrayUpper);
  SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID,2);
  
  SetIndexBuffer(2, BufferArrayLower);
  SetIndexStyle(2,DRAW_ARROW,STYLE_SOLID,2);
  
  SetIndexBuffer(3, BufferArrayHighStop);
  SetIndexStyle(3,DRAW_ARROW,STYLE_SOLID,2);
  
  SetIndexBuffer(4, BufferArrayLowStop);
  SetIndexStyle(4,DRAW_ARROW,STYLE_SOLID,2);
  
   return(0);
  }
  
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
  
  rsum=0;
  rsum_back1=0;
  a=0;
  b=0;
  variance=0;

   double ReturnArray[121];
   ReturnArray[0]=0;
   
   // for loop that is used to populate the array ReturnArray
 for(i=1; i<121; i++)   // i=120 is the 121st element of the array
 {
 ReturnArray[i] = ReturnRate(Close[i], Open[i]);
 }
 
 // Calcuate the return over the last 100 periods, i.e. candles 1 - 100
 for(i=1; i<101; i++)
   {
   rsum = ReturnArray[i] + rsum;
   }
 rbar = rsum / 100;
 
 // Calculate the return over the candle periods 2-101
 for(i=2; i<102; i++)
   {
    rsum_back1 = ReturnArray[i] + rsum_back1;
   }
   
 rbar_back1 = rsum_back1 / 100;
 
 // Find the value of phi1
 for(i=1; i<101; i++)
   {
    a = ((ReturnArray[i+1] - rbar_back1)*(ReturnArray[i]-rbar)) + a;
    b = ((ReturnArray[i+1]-rbar_back1)*(ReturnArray[i+1]-rbar_back1)) + b;
      if (i==100)
         {
          phi1 = a/b;
         }
   }

 // Find the value of phi0
 phi0 = rbar - (phi1*rbar_back1);

 // detemine forecasts for candle 0 and the five candles that follow it forward in time
  double r0 = phi0 + phi1*ReturnArray[1];
  forecast0 = Close[1]*(1+r0);
  
 //-------- Calculate a Confidence Interval of two standard deviations --------
 // First calculate the variance
 for(int t=2; t<101; t++)
   {
    variance = (ReturnArray[t] - (phi0 + phi1*ReturnArray[t+1]))*(ReturnArray[t] - (phi0 + phi1*ReturnArray[t+1])) + variance;
   }
 
 variance = variance / (97);
 double std_dev = MathSqrt(variance);
 
 // The upper, and lower bounds for a 2 and 3 standard deviations, NOTE: alpha is currently not used
 double UpperBound = forecast0 + (2*std_dev);
 double LowerBound = forecast0 - (2*std_dev);
 double HighStop = forecast0 + (3*std_dev);
 double LowStop = forecast0 - (3*std_dev);
 
  // Plot Dots indicating the forecast price, and the bounds for a 95% confidence interval
  BufferArrayClose[0] = forecast0;
  BufferArrayUpper[0] = UpperBound;
  BufferArrayLower[0] = LowerBound;
  BufferArrayHighStop[0] = HighStop;
  BufferArrayLowStop[0] = LowStop;

  // Note: UpperBound and LowerBound are two standard deviations away from the current forecast price.
  Comment("r_t = ", phi0, " + ", phi1, " * ", ReturnArray[1], "        The forecast close price is: ", forecast0, " Upper Bound: ", UpperBound, " Lower Bound: ", LowerBound);

  if (Ask < LowerBound)
   {
   Alert("The Ask is two standard deviations below forecast! A market buy order should have a Stop of :", LowStop, " and a Take Profit of: ", forecast0);
   }
   
  if (Bid > UpperBound)
   {
    Alert("The Bid is two standard deviations above forecast! A market sell order should have a Stop of :", HighStop, " and a Take Profit of: ", forecast0);
   }
   
   return(0);
  }
  
//+------------------------------------------------------------------+
//| Custom Functions                                                 |
//+------------------------------------------------------------------+

  // Input a new price and an old price into the function which will retrun the value of the rate of return
double ReturnRate (double newprice, double oldprice)
{
double R = (newprice - oldprice) / oldprice;
return(R);
}
  
//+------------------------------------------------------------------+
I am thinking that I just may need to truncate the points for yen pairs since they have three instead of five. But other than that I have no clue why it wont work.
 
pamexx:
I am thinking that I just may need to truncate the points for yen pairs since they have three instead of five. But other than that I have no clue why it wont work.
  // Plot Dots indicating the forecast price, and the bounds for a 95% confidence interval
  BufferArrayClose[0] = forecast0;      //=> Why it is 0.?? It should be calculation bar shift. [0] will always update the same array value
  BufferArrayUpper[0] = UpperBound;     
  BufferArrayLower[0] = LowerBound;
  BufferArrayHighStop[0] = HighStop;
  BufferArrayLowStop[0] = LowStop;

why it is 0.?? It should be bar shift..

Reason: