Errors, bugs, questions - page 811

 
abeiks:

Good afternoon.

I'm trying to use MQL5.I have disassembled exp_tema.mq5 and modified the code. Now I should print in log MA of each candle (last 20). But I don't understand why some entries are missing in the log. I noticed that if ma[3] is missing in log, then there is no ma[13]. Why is this happening? Where is the error there?

Here it is.

if(CopyBuffer(Handle[Number],0,0,20,ma)<0)

is obviously missing a check:

  1. BarsCalculated >= 20
  2. CopyBuffer==20
Files:
exp_tema.mq5  27 kb
 
sergeev:

No need for a video.

Do a detailed Print in the code, so that we can see in the log what the intermediate variables are equal to.

#property copyright "Copyright 2011, "

#property link      "http://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   double Vhod=0;
      Print("Начало_Vhod="+DoubleToString(Vhod,2));
   Vhod=linfunc(15);
      Print("Конец_Vhod="+DoubleToString(Vhod,2));
//---
   return(0);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---

  }
//+------------------------------------------------------------------+
double  linfunc(double b) // имя функции и список параметров
  {
   double a=1;

   while((a/b)<1 && !IsStopped())//-------------------
     {
      Print("а="+DoubleToString(a,2)+", b="+DoubleToString(b,2)+", a/b="+DoubleToString(a/b,2));
      a=a+1;
     }
   Print("а="+DoubleToString(a,2)+", b="+DoubleToString(b,2)+", a/b="+DoubleToString(a/b,2));
   Print("a+b="+DoubleToString(a+b,2));
         double f=a+b;
         // составной оператор
         return(f);           // возвращаемое значение
         }
//+------------------------------------------------------------------+

Here is the code.

Here is its print

GM 0 1 (EURUSD,M1) 18:11:11 Start_Vhod=0.00
FO 0 1 (EURUSD,M1) 18:11:13 a=1.00, b=15.00, a/b=0.07
JF 0 1 (EURUSD,M1) 18:11:13 a=2.00, b=15.00, a/b=0.13
CQ 0 1 (EURUSD,M1) 18:11:13 a=3.00, b=15.00, a/b=0.20
EH 0 1 (EURUSD,M1) 18:11:13 a=4.00, b=15.00, a/b=0.27
KS 0 1 (EURUSD,M1) 18:11:13 a=5.00, b=15.00, a/b=0.33
PJ 0 1 (EURUSD,M1) 18:11:13 a=6.00, b=15.00, a/b=0.40
PE 0 1 (EURUSD,M1) 18:11:13 a=7.00, b=15.00, a/b=0.47
HL 0 1 (EURUSD,M1) 18:11:13 a=8.00, b=15.00, a/b=0.53
MF 0 1 (EURUSD,M1) 18:11:13 a=9.00, b=15.00, a/b=0.60
JR 0 1 (EURUSD,M1) 18:11:13 a=10.00, b=15.00, a/b=0.67
FK 0 1 (EURUSD,M1) 18:11:13 a=11.00, b=15.00, a/b=0.73
OP 0 1 (EURUSD,M1) 18:11:13 a=12.00, b=15.00, a/b=0.80
MI 0 1 (EURUSD,M1) 18:11:13 a=13.00, b=15.00, a/b=0.87
KF 0 1 (EURUSD,M1) 18:11:13 a=14.00, b=15.00, a/b=0.93
EO 0 1 (EURUSD,M1) 18:11:13 a=15.00, b=15.00, a/b=1.00
DJ 0 1 (EURUSD,M1) 18:11:14 a+b=30.00
RL 0 1 1 (EURUSD,M1) 18:11:17 End_Vhod=0.00
NH 2 1 (EURUSD,M1) 18:11:24 debugging terminated

 
Fia:


If you run the debug EX5 not from the editor, but directly in the terminal - the same result?

Can you attach the debug EX5?

 
Fia:

Here's his print

GM 0 1 (EURUSD,M1) 18:11:11 Start_Vhod=0.00
FO 0 1 (EURUSD,M1) 18:11:13 a=1.00, b=15.00, a/b=0.07
JF 0 1 (EURUSD,M1) 18:11:13 a=2.00, b=15.00, a/b=0.13
CQ 0 1 (EURUSD,M1) 18:11:13 a=3.00, b=15.00, a/b=0.20
EH 0 1 (EURUSD,M1) 18:11:13 a=4.00, b=15.00, a/b=0.27
KS 0 1 (EURUSD,M1) 18:11:13 a=5.00, b=15.00, a/b=0.33
PJ 0 1 (EURUSD,M1) 18:11:13 a=6.00, b=15.00, a/b=0.40
PE 0 1 (EURUSD,M1) 18:11:13 a=7.00, b=15.00, a/b=0.47
HL 0 1 (EURUSD,M1) 18:11:13 a=8.00, b=15.00, a/b=0.53
MF 0 1 (EURUSD,M1) 18:11:13 a=9.00, b=15.00, a/b=0.60
JR 0 1 (EURUSD,M1) 18:11:13 a=10.00, b=15.00, a/b=0.67
FK 0 1 (EURUSD,M1) 18:11:13 a=11.00, b=15.00, a/b=0.73
OP 0 1 (EURUSD,M1) 18:11:13 a=12.00, b=15.00, a/b=0.80
MI 0 1 (EURUSD,M1) 18:11:13 a=13.00, b=15.00, a/b=0.87
KF 0 1 (EURUSD,M1) 18:11:13 a=14.00, b=15.00, a/b=0.93
EO 0 1 (EURUSD,M1) 18:11:13 a=15.00, b=15.00, a/b=1.00
DJ 0 1 (EURUSD,M1) 18:11:14 a+b=30.00
RL 0 1 1 (EURUSD,M1) 18:11:17 End_Vhod=0.00
NH 2 1 (EURUSD,M1) 18:11:24 debugging terminated

It doesn't play.

2012.08.16 18:42:34     Test_001 (GBPUSD,M15)   Конец_Vhod=30.00
2012.08.16 18:42:34     Test_001 (GBPUSD,M15)   a+b=30.00
2012.08.16 18:42:34     Test_001 (GBPUSD,M15)   а=15.00, b=15.00, a/b=1.00
2012.08.16 18:42:34     Test_001 (GBPUSD,M15)   а=14.00, b=15.00, a/b=0.93
2012.08.16 18:42:34     Test_001 (GBPUSD,M15)   а=13.00, b=15.00, a/b=0.87
2012.08.16 18:42:34     Test_001 (GBPUSD,M15)   а=12.00, b=15.00, a/b=0.80
2012.08.16 18:42:34     Test_001 (GBPUSD,M15)   а=11.00, b=15.00, a/b=0.73
2012.08.16 18:42:34     Test_001 (GBPUSD,M15)   а=10.00, b=15.00, a/b=0.67
2012.08.16 18:42:34     Test_001 (GBPUSD,M15)   а=9.00, b=15.00, a/b=0.60
2012.08.16 18:42:34     Test_001 (GBPUSD,M15)   а=8.00, b=15.00, a/b=0.53
2012.08.16 18:42:34     Test_001 (GBPUSD,M15)   а=7.00, b=15.00, a/b=0.47
2012.08.16 18:42:34     Test_001 (GBPUSD,M15)   а=6.00, b=15.00, a/b=0.40
2012.08.16 18:42:34     Test_001 (GBPUSD,M15)   а=5.00, b=15.00, a/b=0.33
2012.08.16 18:42:34     Test_001 (GBPUSD,M15)   а=4.00, b=15.00, a/b=0.27
2012.08.16 18:42:34     Test_001 (GBPUSD,M15)   а=3.00, b=15.00, a/b=0.20
2012.08.16 18:42:34     Test_001 (GBPUSD,M15)   а=2.00, b=15.00, a/b=0.13
2012.08.16 18:42:34     Test_001 (GBPUSD,M15)   а=1.00, b=15.00, a/b=0.07
2012.08.16 18:42:34     Test_001 (GBPUSD,M15)   Начало_Vhod=0.00

Win7 x64

MT5 x64 build 687

 
alexvd:

If you run the debug EX5 not from the editor, but directly in the terminal - the same result?

Can you attach debug EX5?

It's interesting, if I run it from tester, it gives 30, if I run it as EA, it also gives 30 on print.

If I go back to debug, it returns 0.


MetaDriver

On what build and on what kind (excuse the expression) did it work.

I must still lay out the video will be, if no one else can not reproduce this miracle.

Files:
1.ex5  5 kb
 
alexvd:

Right there

clearly lacking in checks:

  1. BarsCalculated >= 20
  2. CopyBuffer==20

Thank you, I will try to add it.

 

Here is a video (but choose a resolution higher than 720, otherwise everything will be in soap)

https://www.youtube.com/watch?v=Prpw6DUYvjY&feature=youtu.be

Win7 64bit MT5 687 build

As I found out the effect when return gives 0 seems to happen only in debugger.

At the same time, if I use only the "step while" button, it seems to work.

If I enter while loop to exit with "step in" button, it doesn't work, the output is stably 0.

In general, the video shows everything, but how to be and what to do until I do not understand (and why is it so only me?)

 
Fia:
Win7 64bit MT5 687 build
What is the bit rate of the terminal?
 

During optimisation incomprehensible symbols popped up

In the vertical optimisation graph tab, all values are -1

 
alexvd:

Right there

clearly lacking in checks:

  1. BarsCalculated >= 20
  2. CopyBuffer==20

However, I still have problems with buffers. Everything is clear when I read them, but I do not understand how they should be implemented in code. If it's not too much trouble, can you insert it into the code?