Errors, bugs, questions - page 1611

 
Slawa:
The quad tester only has OnInit, OnTick, OnDeinit. No timer, no chart events, no ticks from alien characters and even tester Sleep doesn't work

Thank you for your reply. As far as I understand, you're not going to finalize the timer handler?

 

Bug in new compiler version, build 1354:

2016.07.08 14:10:04.626 MetaCOT2 COT Absolute Changes (EURUSD,H1) math overflow or undefined calculation detected. Check source code, please

The message occurs before OnInit is even called. No complex objects are used. No calculations are performed either. Everything was working fine in previous versions.

Appears when loading any custom indicator.

 
coderex:
do you want std::cout and std::cin?

No, it's long since passed.

it was inconvenient that printf() in MQL, unlike C++, moves to a new line when it is not asked to do so

 

There are several mistakes here at once

class B;
class A { public:
        virtual B *f() { Print( __FUNCSIG__ ); return &this; }
};
class B : public A { public:
        virtual B *f() { Print( __FUNCSIG__ ); return &this; }
};
void OnStart() 
{
        A a;
        a.f().f();
}

1. Implicit transformation from base class to derived class. It must be explicit, otherwise you will get an error message

        virtual B *f() { Print( __FUNCSIG__ ); return (B *)&this; } //(*)
2. execution error: result (bottom-up)

B* B::f()
B* A::f()

But if you rewrite it in C++, the result will be

B* A::f()
B* A::f()

 
If anything, there's also a cast error here. Casting &this to B* should throw an error. On the plus side, it's supposed to do the same thing.
 
Комбинатор:
If anything, there's also a cast error here. Casting &this to B* should throw an error. In the pluses, too, by the way.
Explicit conversion is allowed (check with C++)
 
A100:
Explicit conversion is acceptable (check in C++)
Need dynamic_cast here, does it work?
 
Комбинатор:
Here we need dynamic_cast, does it work?
if
        virtual B *f() { Print( __FUNCSIG__ ); return dynamic_cast<B *>( &this ); }

then the execution result is correct (from bottom to top):

invalid pointer access
B* A::f()

 
A100:

The other cast in your example does not work correctly.

So there's a mistake in mql type conversion which should unfold into dynamic cast, which in fact doesn't happen or doesn't happen correctly.

 

Dear Sirs!

MT4 has a very handy way of setting stop orders by dragging: when I drag the cursor away from the trade line, I can immediately see the profit that will be made if the trade closes at the price at which the cursor is positioned.

In my trading, I use a strategy where I often need a similar tool, but not for a single trade, but for ALL trades opened on a given chart.

That is. I would like. that when I set the cursor on any price, I would like to see the size of the TOTAL PROFIT, which will be if ALL trades are closed at the price at which the cursor is set.

And it would be quite luxurious if, when I release the mouse button, all open trades were automatically set to the correct TP and SL for that profit, as is currently the case for a single trade.

Maybe I want too much, but I have described an ideal situation. At a minimum I want a calculator that inputs levels and volumes of open trades (all trades are unidirectional, either all sell or all buy) and closing price, and outputs the total profit to be made after closing all trades when a given price is reached. Or, for example, it could be an indicator in the form of ahorizontal line which shows the price at which the group profit will be zero at closing. I am currently calculating it by hand with a calculator but it is very long and may cause errors.

I would look on the Market myself, but I don't know what to look for. Should it be an Expert Advisor, an indicator, a robot or something else? If there is nothing ready-made, I am ready to discuss the terms of an order for writing such a tool.