Questions from Beginners MQL5 MT5 MetaTrader 5 - page 223
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Afternoon. Please help a beginner trader to find a suitable advisor for automated trading, which is able to open locked orders in currency pairs with the possibility of arbitrary take profit setting. Thank you.
Alternatively: declare Type method in all of them, in which return type identifier.
Heh, if you could edit the source code... You don't have to simplify things so much. And still - is there a class name in mql5?
Heh, if you could edit the source code... You don't have to simplify things so much. Still - is there any way to find out the class name on mql5???
Look in the direction of templates. This code will return the name of the class or a primitive type.
#include<Trade\Trade.mqh>
//+------------------------------------------------------------------+
//||
//+------------------------------------------------------------------+
voidOnStart()
{
//---
CTrade trade;
double d_value=M_PI;
int i_value=INT_MAX;
Print("d_value: type=",GetTypeName(d_value),", value=", d_value);
Print("i_value: type=",GetTypeName(i_value),", value=", i_value);
Print("trade: type=",GetTypeName(trade);
//---
}
//+------------------------------------------------------------------+
//| Returns type in string form|
//+------------------------------------------------------------------+
template<typename T>
string GetTypeName(const T&t)
{
//---return type as string
return(typename(T))
//---
}
Look towards patterns. This code will return the name of a class or primitive type.
#include<Trade\Trade.mqh>
//+------------------------------------------------------------------+
//||
//+------------------------------------------------------------------+
voidOnStart()
{
//---
CTrade trade;
double d_value=M_PI;
int i_value=INT_MAX;
Print("d_value: type=",GetTypeName(d_value),", value=", d_value);
Print("i_value: type=",GetTypeName(i_value),", value=", i_value);
Print("trade: type=",GetTypeName(trade);
//---
}
//+------------------------------------------------------------------+
//| Returns type in string form|
//+------------------------------------------------------------------+
template<typename T>
string GetTypeName(const T&t)
{
//---return type as string
return(typename(T))
//---
}
I've got something! But it doesn't work with new - in the code there is an example of what I need - may be someone can suggest how?
I've got something! But it doesn't work with new - there's an example in the code of what I need - can anyone suggest any ways?
Can someone explain me why this code does not work in the tester, while in real-time it works!!!? Specifically interested in why in the tester, after HistorySelect(0, TimeCurrent()) the HistoryOrderGetInteger...
Screenshot in the strategy tester:
Real-time screenshot in the demo:
p.s. What is interesting, the first order in the tester is handled correctly but the others are not. Also, if we comment HistroryOrderSelect(ticketOrder), we get a message in the Strategy Tester that the order has not been selected and in the Strategy Tester, everything starts working, except for the first order.
And I have some problem with HistorySelect(). I open a position with the script by sending a market order, and if a deal has opened, I immediately look at the number of deals in the history since the script was launched, and I check it 10 times at an interval of a second. Obviously, there should be one trade. Here is the script:
And here is the result in Alfa-Forex:
A trade is actually made, but it's not in the history even after 10 seconds. What is it? A MT bug? Alpha glitch? Some kind of chip that I don't know? Alpari's script works normally, only occasionally zero is detected at the first (zero) step (well, it is understandable - the history has not yet had time to update), all other steps are one. But after ten seconds, why is there no deal in the history?
And I have some problem with HistorySelect(). I open a position with the script by sending a market order, and if a deal has opened, I immediately look at the number of deals in the history since the script was launched, and I check it 10 times at an interval of a second. Obviously, there should be one trade. Here is the script:
And here is the result from the Alpha broker:
A trade is actually made, but it's not in the history even after 10 seconds. What is this? A MT bug? Alpha glitch? Some kind of chip that I don't know? Alpari's script works normally, only occasionally zero is detected at the first (zero) step (well, it is understandable - the history has not yet had time to update), all other steps are one. But why is there no deal in the history in ten seconds?
What bothers me is the following line
datetime dtStartTime = TimeCurrent();
Are you sure that dtStartTime and TimeCurrent() are not the same number by the moment for? Maybe the rounding to one second puts the completed transaction outside of dtStartTime.
The line
datetime dtStartTime = TimeCurrent();
Are you sure that dtStartTime and TimeCurrent() are not the same number by the time for? Perhaps the rounding to one second puts the completed transaction outside of dtStartTime.
And even if it's one, shouldn't MT output the history for that second? I.e. doesn't it output the history within the specified limits, INCLUDING the limits themselves?
But anyway, I tried writing both dtStartTime = TimeCurrent() - 1, and dtStartTime = TimeCurrent() - 10. Doesn't work.