Won't print to Journal

 

As someone with no programming experience I will have a lot of dumb questions. Here's one now.

Can someone please explain to me why I cannot get this to print to my journal. It's very important for me to see. I cannot get either the Comment function or the Print function to work and I'm not compiling with any errors or warnings.

//+------------------------------------------------------------------+
//|                               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
#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping

//---
   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[])

  {

//declare variables to hold the value of each individual currency strength
   int GBP = 0;
   int EUR = 0;
   int AUD = 0;
   int NZD = 0;
   int USD = 0;
   int CAD = 0;
   int CHF = 0;
   int JPY = 0;

//Gathers the EUR Symbol Values
   double EURGBP = SymbolInfoDouble("EURGBP",SYMBOL_ASK);
   double EURAUD = SymbolInfoDouble("EURAUD",SYMBOL_ASK);
   double EURNZD = SymbolInfoDouble("EURNZD",SYMBOL_ASK);
   double EURUSD = SymbolInfoDouble("EURUSD",SYMBOL_ASK);
   double EURCAD = SymbolInfoDouble("EURCAD",SYMBOL_ASK);
   double EURCHF = SymbolInfoDouble("EURCHF",SYMBOL_ASK);
   double EURJPY = SymbolInfoDouble("EURJPY",SYMBOL_ASK);
//Gathers the GBP Symbol Values
   double GBPAUD = SymbolInfoDouble("EURAUD",SYMBOL_ASK);
   double GBPNZD = SymbolInfoDouble("EURNZD",SYMBOL_ASK);
   double GBPUSD = SymbolInfoDouble("EURUSD",SYMBOL_ASK);
   double GBPCAD = SymbolInfoDouble("EURCAD",SYMBOL_ASK);
   double GBPCHF = SymbolInfoDouble("EURCHF",SYMBOL_ASK);
   double GBPJPY = SymbolInfoDouble("EURJPY",SYMBOL_ASK);
//Gathers the AUD Symbol Values
   double AUDNZD = SymbolInfoDouble("EURNZD",SYMBOL_ASK);
   double AUDUSD = SymbolInfoDouble("EURUSD",SYMBOL_ASK);
   double AUDCAD = SymbolInfoDouble("EURCAD",SYMBOL_ASK);
   double AUDCHF = SymbolInfoDouble("EURCHF",SYMBOL_ASK);
   double AUDJPY = SymbolInfoDouble("EURJPY",SYMBOL_ASK);
//Gathers the NZD Symbol Values
   double NZDUSD = SymbolInfoDouble("EURUSD",SYMBOL_ASK);
   double NZDCAD = SymbolInfoDouble("EURCAD",SYMBOL_ASK);
   double NZDCHF = SymbolInfoDouble("EURCHF",SYMBOL_ASK);
   double NZDJPY = SymbolInfoDouble("EURJPY",SYMBOL_ASK);
//Gathers the USD Symbol Values
   double USDCAD = SymbolInfoDouble("EURCAD",SYMBOL_ASK);
   double USDCHF = SymbolInfoDouble("EURCHF",SYMBOL_ASK);
   double USDJPY = SymbolInfoDouble("EURJPY",SYMBOL_ASK);
//Gathers the CAD Symbol Values
   double CADCHF = SymbolInfoDouble("EURCHF",SYMBOL_ASK);
   double CADJPY = SymbolInfoDouble("EURJPY",SYMBOL_ASK);
//Gathers the CHF Symbol Values
   double CHFJPY=SymbolInfoDouble("EURJPY",SYMBOL_ASK);

//declare an array to store symbol values
   double eurTOgbp[];
//storing EUR values in array
   ArrayFill(eurTOgbp,0,0,EURGBP);
   ArrayFill(eurTOgbp,1,1,EURAUD);
   ArrayFill(eurTOgbp,2,2,EURNZD);
   ArrayFill(eurTOgbp,3,3,EURUSD);
   ArrayFill(eurTOgbp,4,4,EURCAD);
   ArrayFill(eurTOgbp,5,5,EURCHF);
   ArrayFill(eurTOgbp,6,6,EURJPY);
//storing GBP values in array
   ArrayFill(eurTOgbp,7,7,GBPAUD);
   ArrayFill(eurTOgbp,8,8,GBPNZD);
   ArrayFill(eurTOgbp,9,9,GBPUSD);
   ArrayFill(eurTOgbp,10,10,GBPCAD);
   ArrayFill(eurTOgbp,11,11,GBPCHF);
   ArrayFill(eurTOgbp,12,12,GBPJPY);
//storing AUD values in array
   ArrayFill(eurTOgbp,13,13,AUDNZD);
   ArrayFill(eurTOgbp,14,14,AUDUSD);
   ArrayFill(eurTOgbp,15,15,AUDCAD);
   ArrayFill(eurTOgbp,16,16,AUDCHF);
   ArrayFill(eurTOgbp,17,17,AUDJPY);
//storing NZD values in array
   ArrayFill(eurTOgbp,18,18,NZDUSD);
   ArrayFill(eurTOgbp,19,19,NZDCAD);
   ArrayFill(eurTOgbp,20,20,NZDCHF);
   ArrayFill(eurTOgbp,21,21,NZDJPY);
//storing USD values in array
   ArrayFill(eurTOgbp,22,22,USDCAD);
   ArrayFill(eurTOgbp,23,23,USDCHF);
   ArrayFill(eurTOgbp,24,24,USDJPY);
//storing CAD values in array
   ArrayFill(eurTOgbp,25,25,CADCHF);
   ArrayFill(eurTOgbp,26,26,CADJPY);
//storing CHF values in array
   ArrayFill(eurTOgbp,27,27,CHFJPY);

//Compares all the EUR currency pairs to all the GBP currency pairs and asigns a value to the EUR variable
   for(int i=0; i < eurTOgbp[7]; i++){
      if(GBPAUD > eurTOgbp[i])
        {
         EUR++;
        }
      else if(GBPAUD < eurTOgbp[i])
         {
         EUR--;
         }
         
      if(GBPNZD > eurTOgbp[i])
        {
         EUR++;
        }
      else if(GBPNZD < eurTOgbp[i])
         {
         EUR--;
         }
         
      if(GBPUSD > eurTOgbp[i])
        {
         EUR++;
        }
      else if(GBPUSD < eurTOgbp[i])
         {
         EUR--;
         }
         
      if(GBPCAD > eurTOgbp[i])
        {
         EUR++;
        }
      else if(GBPCAD < eurTOgbp[i])
         {
         EUR--;
         }
         
      if(GBPCHF > eurTOgbp[i])
        {
         EUR++;
        }
      else if(GBPCHF < eurTOgbp[i])
         {
         EUR--;
         }
         
      if(GBPJPY > eurTOgbp[i])
        {
         EUR++;
        }
      else if(GBPJPY < eurTOgbp[i])
         {
         EUR--;
         }
}
//Trying to print out the result but it wont show up in the journal
Print("The strength of the EUR compared to the GBP is: ", DoubleToStr(EUR,Digits));


/*


                  double EURGBP = SymbolInfoDouble("EURGBP",SYMBOL_ASK);
                  Comment("The ASk price of the EURGBP is ", DoubleToString(EURGBP,Digits));

*/
//--- return value of prev_calculated for next call

   return(rates_total);
  }
//+------------------------------------------------------------------+
 
SirFency:

As someone with no programming experience I will have a lot of dumb questions. Here's one now.

Can someone please explain to me why I cannot get this to print to my journal. It's very important for me to see. I cannot get either the Comment function or the Print function to work and I'm not compiling with any errors or warnings.

Look in the Experts tab, not the Journal tab.

You won't see your Print() statement there, but you will see your error message. It looks something like this:

2018.03.30 07:18:30.914 Fency EURJPY,H1: array out of range in 'Fency.mq4' (87,14)

The problem: you didn't set dimensions for your array.

Also . . . are you using ArrayFill() correctly with respect to count? For each of your statements, you are filling the array with more and more values. For example, CHFJPY, you are filling the array starting at position 27 with 27 values. Maybe you meant to fill it with 1 value.

At a minimum, with the code you have right now, you need to dimension eurTOgbp to a size of 54 to get your Print() statement to work.

You might want to pick up an introductory book on MQL4 programming.

 
Anthony Garot:

Look in the Experts tab, not the Journal tab.

You won't see your Print() statement there, but you will see your error message. It looks something like this:

The problem: you didn't set dimensions for your array.

Also . . . are you using ArrayFill() correctly with respect to count? For each of your statements, you are filling the array with more and more values. For example, CHFJPY, you are filling the array starting at position 27 with 27 values. Maybe you meant to fill it with 1 value.

At a minimum, with the code you have right now, you need to dimension eurTOgbp to a size of 54 to get your Print() statement to work.

You might want to pick up an introductory book on MQL4 programming.

Thank you. Yes my array is wrong. all I really want is an array filled with all the currency pairs however when I tried this earlier it gave me an error saying that the variables were already defined. I will continue to look into this. My work around was to mimic a push command like they have in javascript and fill the array with the currency pairs however I see that I'm doing it wrong. The documentation on this language is very difficult for me to understand. Now that I know where to look for my print out I should be able to troubleshoot many of my issues. Thank you very much.