MQL5 structure

 

 I've made the overall code much simpler by avoiding candlestick type recognition, SLs etc but problem remains the same.  How do I avoid the print statement from repeating itself ?

//+-------------------------------------------------------------------------------------------------------+
//|  Global Variables                                                                                     |
//+-------------------------------------------------------------------------------------------------------+

double symbol_points[];
string symbol_loop[] = {"GBPUSD", "EURJPY"};
ENUM_TIMEFRAMES timeframe_loop[] = {PERIOD_M15, PERIOD_H1};


ulong posTicket;

datetime old_time;

//+-------------------------------------------------------------------------------------------------------+
//|  Include Files                                                                                        |
//+-------------------------------------------------------------------------------------------------------+

#include <Trade/Trade.mqh>
CTrade trade;

//+-------------------------------------------------------------------------------------------------------+
//|  On OnInit                                                                                            |
//+-------------------------------------------------------------------------------------------------------+

int OnInit()
  {

   return(INIT_SUCCEEDED);
  }

//+-------------------------------------------------------------------------------------------------------+
//|  OnTick                                                                                               |
//+-------------------------------------------------------------------------------------------------------+


void OnTick()
{  
   datetime GMT = iTime(_Symbol, PERIOD_M15, 1);
   if(GMT > old_time)
   {
      old_time = GMT;

      for(int i = 0; i < ArraySize(symbol_loop); i++)
      {
         string symbol = symbol_loop[i];

         for(int j = 0; j < ArraySize(timeframe_loop); j++)
         {
            ENUM_TIMEFRAMES timeframe = timeframe_loop[j];

      double Open = open(symbol, timeframe, 1);
      double Close = close(symbol, timeframe, 1);

   
      Print(symbol, " | ", Open, " | ", Close);
         }  
      }

   }
}


double open(string symbol, ENUM_TIMEFRAMES timeframe, int shift)
  {
   return iOpen(symbol, timeframe, shift);
  }

double close(string symbol, ENUM_TIMEFRAMES timeframe, int shift)
  {
   return iClose(symbol, timeframe, shift);
  }
Studying candlestick analysis techniques (part III): Library for pattern operations
Studying candlestick analysis techniques (part III): Library for pattern operations
  • www.mql5.com
The purpose of this article is to create a custom tool, which would enable users to receive and use the entire array of information about patterns discussed earlier. We will create a library of pattern related functions which you will be able to use in your own indicators, trading panels, Expert Advisors, etc.
 
Your print statement is not repeating itself. I find no problem in your code.
 

I agree. all works like as it should be. I can´t quite understand now what are you trying to do with it: ENUM_TIMEFRAMES timeframe_loop[] = {PERIOD_M15, PERIOD_H1}; as far I can predict you assume that H1 does not execute every 15 minutes or what? for the for loop, it is still 2, and it must iterate through both arrays anyway, because that´s exactly how you wrote it. Using a nested loop you get 2x2 execution per iteration cycle if both arrays have 2 elements and everything is correct.  

I don´t understand the nature of the problem and what exactly you want to achieve. If you want us to think along, say in more detail what you want to achieve and what outputs ja when you want to see ?