Errors, bugs, questions - page 1661

 

Is it a bug or a question, but something incomprehensible ...is happening in the tester and in the debugger... Everything's fine on EURUSD, but there's a problem with USDJPY...

Part of the code

void funArrPositionTicket(ulong & arrBuy[], int & buySize, ulong & arrSell[], int & sellSize)
{
 double bp, sp;
  buyProfit = 0; sellProfit = 0; buyVolume = 0; sellVolume = 0;
   int i, total = PositionsTotal();
    for(i = 0; i < total; i++)
     {
      if(PositionGetTicket(i) > 0 && PositionGetString(POSITION_SYMBOL) == _Symbol)
       {
        if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY)
         {
          buySize = ArraySize(arrBuy);
           ArrayResize(arrBuy, buySize+1);
            arrBuy[buySize] = (int)PositionGetInteger(POSITION_TICKET);
           buyProfit += PositionGetDouble(POSITION_PROFIT);
          buyVolume += PositionGetDouble(POSITION_VOLUME);
         }
        if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL)
         {
          sellSize = ArraySize(arrSell);
           ArrayResize(arrSell, sellSize+1);
            arrSell[sellSize] = (int)PositionGetInteger(POSITION_TICKET);
           sp = PositionGetDouble(POSITION_PROFIT);
           sellProfit += sp;
          sellVolume += PositionGetDouble(POSITION_VOLUME);
         }
       }
     }
}/*******************************************************************/

What I'm interested in in the code is clear from screenshots... It is marked in the code.

There is ONE Sell order with a loss of 7.39, but the code shows a loss of only 0.93


The green arrow in the following screenshot shows that the debug is stopped at this line...



That is, the sl variable has already been set to PositionGetDouble(POSITION_PROFIT)


QUESTION: Why is this happening? Is it a bug or a pattern, a special feature of the mql5 tester/debugger???

The variable sp was introduced a bit later, initially the variable sellProfit was checked, which was set to zero when the function was entered.

 
Alexey Viktorov:

Whether it's a bug or a question, but there's something unclear... happens in the tester and in the debug... Everything's fine on EURUSD, but there's a problem on USDJPY...

There was a problem in the build a dozen or so years earlier when the visualizer was showing the future by one tick, while MQL was working normally - the future was not seen.

Try to compare PositionGetDouble(POSITION_PROFIT) on the next tick. If it coincides with what the visualizer has shown before - the problem is there. Slawa gave an explanation and promised to correct it.

If not - another bug in this case.

 
fxsaber:

On a build a dozen or two earlier than the current one, there was a problem when the visualizer was showing the future on one tick, while MQL was working fine - the future was not seen.

Try to compare PositionGetDouble(POSITION_PROFIT) on the next tick. If it coincides with what the visualizer has shown before - the problem is there. Slawa gave an explanation and promised to correct it.

If not - another bug in this case.

Maybe so, but the code does not provide a check on the next tick. Only once at the moment of opening of a new bar. And what guarantee is there that these values are from the next tick? None... I tried it again; the loss is 2.55, but the debugger still shows 0.93.

But, fingers crossed... tester 5 is way better than tester 4... Only glitches and inadequate operation... How can you debug an Expert Advisor with such glitches? How else do people do optimization??? In fact, optimization is self-deception, and with such fiddles, it is self-deception to the degree of lying 8.

I'll have to test it on a demo... for weeks...

 

Just because the visualiser shows nonsense does not mean that the tester itself is wrong. The tester does not care about visualization problems, not at all.

Use TickValue to calculate the profit size and compare it with POSITION_PROFIT. You will see that everything is the same. The visualization seems to be a bug.

 
fxsaber:

Just because the visualiser shows nonsense does not mean that the tester itself is wrong. The tester does not care about visualization problems, not at all.

Use TickValue to calculate the profit size and compare it with POSITION_PROFIT. You will see that everything is the same. The visualization seems to be a bug.

Yes, I re-calculated it before posting the question. Seems to be true, you can recalculate from screenshots. I didn't start checking for a reason. The loss is calculated based on the lot size that will lead to the expected profit at closing the take profit. Everything was calculated correctly on EURUSD, but suddenly losses are not covered on USDJPY... I started to check the formula... and reached this bug. It turns out that the visualizer has nothing to do with it.

 
Alexey Viktorov:

Yes counted it before posting the question. Seems to be true, you can recalculate from the screenshots. I did not start checking for a reason. The loss is calculated based on the size of the lot at which the expected profit will be closed at take. Everything was calculated correctly on EURUSD, but suddenly losses are not covered on USDJPY... I started to check the formula... and reached this bug. It turns out that the visualizer has nothing to do with it.

Sorry, but I don't follow your point. Who do you think is the bug - the tester or the visualizer?
 

Error compiling Script1.mq5

//Script.mqh
typedef void (*fn)();
#import "Script1.ex5"
        void g();
#import "Script2.ex5"
        void h();
        void h( fn );
#import
class A {
public:
        void f1() { h( g ); } //Error: #1 - no one of the overloads can be applied to the function call
                              //Error: #2 - cannot resolve function address
        void f2() {    g(); } //нормально (*)
        void f3() { Print( __FUNCTION__ ); }
};
//Script1.mq5
#property library
#include "Script.mqh"
void g() export
{
        A a;
        a.f3();
}

Error #1. The h call is unambiguous by signature here.

Error #2. In A::f1() calling of h( g ) in sense of g - can seem ambiguous, but on the other hand in A::f2() compiler on the other hand does not ask unnecessary questions concerning g() (and correctly does - at least at first existing problems of including header file with function declaration in module with its implementation and further use in this module were solved long ago). And besides, it is difficult to rewrite otherwise, because Script.mqh is a common header file

 
fxsaber:
I'm sorry, but I don't understand your point. Who do you think is wrong - the tester or the visualizer?

If it shows values similar to the truth, but calculates them using the wrong data, then the problem is in mql5 and not in the tester or visualizer.

All in all, thanks for your input, I'll be beating the problem in the long run. And will check on another, similar piece of currency today. Maybe it's the ticks problem at that location, hhz?

 

Why is the warning on a level playing field?

void OnStart()
{
  uchar Data[];  
  ArrayInitialize(Data, UCHAR_MAX); // Warning: truncation of constant value
}
 
Dear Professionals, please help me to understand the problem. The Expert Advisor works by the signal of the indicator the period of which can be changed within a wide range from 3 bars up to 10000 and more. The indicator itself works fine on its own and reacts adequately to changes in the period within these limits. However, the Expert Advisor in the Strategy Tester does not accept settings higher than 1002 bars and reports "Zero Divide". What may be the problem? I have not found any limitations in the Expert Advisor's code.