MQL4 problem with code

 

I have problem with mql4 code.

When I start code in  tester of strategy, program sometimes lost data.

The program should print the information every 30 minutes.

It starts at 00:00 and then prints 01:00 (lost 0:30) or prints only part of the data.

Typically, the error is at the beginning of the data.

I do not know why it appears that this situation.

Can you help?

The code is simple. 

 

//////////// code

 

//+------------------------------------------------------------------+

//|                                                         Test.mq4 |

//|                        Copyright 2016, MetaQuotes Software Corp. |

//|                                             https://www.mql5.com |

//+------------------------------------------------------------------+

#property copyright "Copyright 2016, MetaQuotes Software Corp."

#property link      "https://www.mql5.com"

#property version   "1.00"

#property strict

int period = PERIOD_M30;

double zysk = 40;

double strata = -100;

int ryzyko;

int EUR, EUR1, EUR2, EUR3, EUR4, EUR5, EUR6, EUR7;

int USD, USD1, USD2, USD3, USD4, USD5, USD6, USD7;

int GBP, GBP1, GBP2, GBP3, GBP4, GBP5, GBP6, GBP7;

int JPY, JPY1, JPY2, JPY3, JPY4, JPY5, JPY6, JPY7;

int AUD, AUD1, AUD2, AUD3, AUD4, AUD5, AUD6, AUD7;

int CHF, CHF1, CHF2, CHF3, CHF4, CHF5, CHF6, CHF7;

int CAD, CAD1, CAD2, CAD3, CAD4, CAD5, CAD6, CAD7;

int NZD, NZD1, NZD2, NZD3, NZD4, NZD5, NZD6, NZD7;

int waluta1, konsolidacja;

double kierunek;

datetime czas = TimeCurrent() - 60 * 60;

datetime nowy_czas;


//+------------------------------------------------------------------+

//| Expert initialization function                                   |

//+------------------------------------------------------------------+

int OnInit()

  {

//---

   

//---

   return(INIT_SUCCEEDED);

  }

//+------------------------------------------------------------------+

//| Expert deinitialization function                                 |

//+------------------------------------------------------------------+

void OnDeinit(const int reason)

  {

//---

   

  }

//+------------------------------------------------------------------+

//| Expert tick function                                             |

//+------------------------------------------------------------------+

void OnTick()

  {

  nowy_czas = iTime("EURUSD",period,1);

  if (nowy_czas != czas && (Seconds() >= 5 || Seconds() <= 10)){

  konsolidacja = 0;

  czas = nowy_czas;

  /////////////////////////////EURUSD

  EUR1 = umocnienie("EURUSD");

  Print("EUR1 " + IntegerToString(EUR1));

  if (EUR1 == 0) {USD1 = 1;}

  if (EUR1 == 1) {USD1 = 0;}

  if (EUR1 == 3) {konsolidacja = 1;}

  

  /////////////////////////////GBPUSD

  GBP1 = umocnienie("GBPUSD");

  Print("GBP1 " + IntegerToString(GBP1));

  if (GBP1 == 0) {USD2 = 1;}

  if (GBP1 == 1) {USD2 = 0;}

  if (GBP1 == 3) {konsolidacja = 1;}

  

  /////////////////////////////USDJPY

  USD3 = umocnienie("USDJPY");

  Print("USD3 " + IntegerToString(USD3));

  if (USD3 == 0) {JPY1 = 1;}

  if (USD3 == 1) {JPY1 = 0;}

  if (USD3 == 3) {konsolidacja = 1;}

  

  /////////////////////////////AUDUSD

  AUD1 = umocnienie("AUDUSD");

  Print("AUD1 " + IntegerToString(AUD1));

  if (AUD1 == 0) {USD4 = 1;}

  if (AUD1 == 1) {USD4 = 0;}

  if (AUD1 == 3) {konsolidacja = 1;}

  

  /////////////////////////////USDCHF

  USD5 = umocnienie("USDCHF");

  Print("USD5 " + IntegerToString(USD5));

  if (USD5 == 0) {CHF1 = 1;}

  if (USD5 == 1) {CHF1 = 0;}

  if (USD5 == 3) {konsolidacja = 1;}

  

  

  

  }

  

  

  

//---

   

  }

//+------------------------------------------------------------------+

int umocnienie(string para) {


  kierunek = iOpen(para,period,1) - iClose(para,period,1);

  if (kierunek > 0) {  /// świeca malejąca

  waluta1 = 0;

  } else

  if (kierunek < 0) {   /// świeca rosnąca

  waluta1 = 1;

  } else 

  if (kierunek == 0) {

  waluta1 = 3;

  }

  return(waluta1);

Automated Trading and Strategy Testing
Automated Trading and Strategy Testing
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions