Help with iCustom for Drawing lines I'm hitting a wall and its killing me.

 

I'm having a difficult time figuring out why my iCustom lines are only using one value and drawing straight across the window. From everything I can tell it should be changing on each candle. Could someone please help me identify the problem that is causing my lines to only use one value? I dont care about the arrows for now. I cant seem to figure out the lines.


I have attached both files needed and commented everything so it should not be too difficult to see what I'm trying to do.

"My_Currency_Strength_Indicator_TroublShoot.mql4" calls on the "My_CSI_Arrow_Calculator_TroubleShoot.mql4 file. 

Both files compile and give no errors.

 
  1.    for(int i=1; i <= limit; i++){
          EUR_Band[i] = iCustom(NULL, PERIOD_M15, "My_CSI_Arrow_Calculator", 0, i);
    

    Unless you are running on the M15 chart, you are mixing apples and oranges.

  2. int timeframe = PERIOD_M15;
    
    lookBackEURGBP[i] = iClose("EURGBP",timeframe,lookBack);
    
    On MT4: Unless the current chart is that specific pair/TF referenced, you must handle 4066/4073 errors.
              Download history in MQL4 EA - MQL4 and MetaTrader 4 - MQL4 programming forum

 
whroeder1:
  1. Unless you are running on the M15 chart, you are mixing apples and oranges.

  2. On MT4: Unless the current chart is that specific pair/TF referenced, you must handle 4066/4073 errors.
              Download history in MQL4 EA - MQL4 and MetaTrader 4 - MQL4 programming forum

OK I switched this:

   for(int i=1; i <= limit; i++){
      EUR_Band[i] = iCustom(NULL, PERIOD_M15, "My_CSI_Arrow_Calculator", 0, i);

To this:

   for(int i=1; i <= limit; i++){
      EUR_Band[i] = iCustom(NULL, 0, "My_CSI_Arrow_Calculator", 0, i);


Then this:

int timeframe = PERIOD_M15;

lookBackEURGBP[i] = iClose("EURGBP",timeframe,lookBack);


To this:

int timeframe = PERIOD_CURRENT;

lookBackEURGBP[i] = iClose("EURGBP",timeframe,lookBack);


I have added the suggested code for the download history and I have a few warnings. I fixed the errors I was recieving.


Possible Loss of Data due to type conversion:

return( when % HR2400 ); 


implicit enum conversion:

if(period == PERIOD_CURRENT)  period = _Period;


After making the changes to the Main indicator file none of this has seemed to help me understand why my line is still being drawn striaght. I do apreciate your help. I know it cant be easy looking through so much code that someone else wrote poorly and try to understand whats happening.

 

I have completely stripped this down to the bare bones to try and isolate the issue I'm having. The oscillator line is flat. Can someone please point out why? It should be using data from each of the candles to draw the line but I'm only getting one value.


//+------------------------------------------------------------------+
//|                               My_Currency_Strength_Indicator.mq4 |
//|                                               Erick_Fenstermaker |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Erick_Fenstermaker"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

//Opening a separate window and setting the parameters of the window extents
#property indicator_separate_window
#property indicator_maximum 20000
#property indicator_minimum -20000
#property indicator_level1 0

//Setting up the memory allocation and default settings for the indicator lines
#property indicator_buffers 1
#property indicator_color1 clrPurple

//setting width of lines
#property indicator_width1 2

//Declaring the array that will draw the line for the indicator
double EUR_Band[];

//Declaration of the Arrays to store past values (Base Value)
double lookBackEURGBP[100];
double lookBackEURAUD[100];
double lookBackEURNZD[100];
double lookBackEURUSD[100];
double lookBackEURCAD[100];
double lookBackEURCHF[100];
double lookBackEURJPY[100];

//Declaration of Arrays to store the current value of the EUR Symbols
double EURGBP[100];
double EURAUD[100];
double EURNZD[100];
double EURUSD[100];
double EURCAD[100];
double EURCHF[100];
double EURJPY[100];

//Declaration of Arrays to store percent change from Base value to the Current Value.
double perEURGBP[100];
double perEURAUD[100];
double perEURNZD[100];
double perEURUSD[100];
double perEURCAD[100];
double perEURCHF[100];
double perEURJPY[100];

//Declaration of Array to store the true strength of the EUR
double perEUR[100];


//Array buffers for arrows
double uparrow[];
double downarrow[];

//Sets how far you look into the past (15 min incremints 4 = 1hr)
int lookBack = 16 + 1;
int timeframe = NULL;


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

int OnInit()
  {
//--- indicator buffers mapping for EUR
   SetIndexBuffer(0,EUR_Band);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexLabel(0,"EUR Band: ");

//--- indicator buffers mapping for buy arrows
   SetIndexBuffer(1,uparrow);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,233);
   SetIndexLabel(1,"Buy Signal");

//--- indicator buffers mapping for sell arrows
   SetIndexBuffer(2,downarrow);
   SetIndexStyle(2,DRAW_ARROW);
   SetIndexArrow(2,234);
   SetIndexLabel(2,"Buy Signal");
   
//---
   return(INIT_SUCCEEDED);
  }
  
  
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[]){

//looking at older bars
   //int counted_bars,limit;
   //counted_bars = IndicatorCounted();
   //if(!counted_bars)limit = Bars - 2;
   //else limit = Bars - counted_bars - 1;

   for(int i=1; i <= lookBack; i++)
     {
     
//Gathers the EUR Symbol close values from the past (Base Values)   
lookBackEURGBP[i] = iClose("EURGBP",timeframe,lookBack);
lookBackEURAUD[i] = iClose("EURAUD",timeframe,lookBack);
lookBackEURNZD[i] = iClose("EURNZD",timeframe,lookBack);
lookBackEURUSD[i] = iClose("EURUSD",timeframe,lookBack);
lookBackEURCAD[i] = iClose("EURCAD",timeframe,lookBack);
lookBackEURCHF[i] = iClose("EURCHF",timeframe,lookBack);
lookBackEURJPY[i] = iClose("EURJPY",timeframe,lookBack);

//Gathers the current EUR Symbol Ask Values
EURGBP[i] = SymbolInfoDouble("EURGBP", SYMBOL_ASK);
EURAUD[i] = SymbolInfoDouble("EURAUD", SYMBOL_ASK);
EURNZD[i] = SymbolInfoDouble("EURNZD", SYMBOL_ASK);
EURUSD[i] = SymbolInfoDouble("EURUSD", SYMBOL_ASK);
EURCAD[i] = SymbolInfoDouble("EURCAD", SYMBOL_ASK);
EURCHF[i] = SymbolInfoDouble("EURCHF", SYMBOL_ASK);
EURJPY[i] = SymbolInfoDouble("EURJPY", SYMBOL_ASK);

     
//Calcualtes the percent change from the past open till the current ask of the EUR values
perEURGBP[i] = (EURGBP[i] - (lookBackEURGBP[i] + (0.0000000001))/(lookBackEURGBP[i] + (0.0000000001)))*100;
perEURAUD[i] = (EURAUD[i] - (lookBackEURAUD[i] + (0.0000000001))/(lookBackEURAUD[i] + (0.0000000001)))*100;
perEURNZD[i] = (EURNZD[i] - (lookBackEURNZD[i] + (0.0000000001))/(lookBackEURNZD[i] + (0.0000000001)))*100;
perEURUSD[i] = (EURUSD[i] - (lookBackEURUSD[i] + (0.0000000001))/(lookBackEURUSD[i] + (0.0000000001)))*100;
perEURCAD[i] = (EURCAD[i] - (lookBackEURCAD[i] + (0.0000000001))/(lookBackEURCAD[i] + (0.0000000001)))*100;
perEURCHF[i] = (EURCHF[i] - (lookBackEURCHF[i] + (0.0000000001))/(lookBackEURCHF[i] + (0.0000000001)))*100;
perEURJPY[i] = (EURJPY[i] - (lookBackEURJPY[i] + (0.0000000001))/(lookBackEURJPY[i] + (0.0000000001)))*100;

     
//Calculates true strength of the EUR
perEUR[i] = (perEURGBP[i] + perEURAUD[i] + perEURNZD[i] + perEURUSD[i] + perEURCAD[i] + perEURCHF[i] + perEURJPY[i]);

     
      EUR_Band[i] = perEUR[i];


     }
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
SirFency: . The oscillator line is flat. Can someone please point out why?
You are computing percentage (+/-100) on a window with limits of +/-20000.
 
whroeder1:
You are computing percentage (+/-100) on a window with limits of +/-20000.

The value on the line is the same all the way down. Even if you zoom in using window min max values that are much closer to that of the number the line is being drawn at its still a straight line.

 

OK let me ask this. In order to get the information from each candle does the Array have to be an index Buffer Array?

I tried to make all my arrays buffer arrays earlier however, I ran into trouble with array out of range and I assume it was due to having too many buffers. I had 8 that worked fine then on the nineth it gave me the array out of range error.

I'm not sure if it's still the case but is 8 still the limit?

If these arrays need to be buffer arrays and the limit is 8 then I will need some clever trickery to build this indicator.

 
Still lost as to why I'm not getting a different value for each candle
Reason: