Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1428
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
You are not describing the task correctly! It is not "once every 20 seconds", but every second to check the values that have passed some time ago. As for "why" - this is not a question for this discussion. (And 20 seconds is just as an example).
It's like a moving average, where the first candle is compared to the second candle. Only I have to calculate everything inside the current (zero) minute candle. (Or even better - on a line chart. After all, 20 seconds can flow to the first candle).
You have described your algorithm incorrectly, i.e. inaccurately, and it follows from the fact that it was not understood unambiguously by everyone. One understood it this way, it turned out to be wrong, another understood it differently, it turned out to be right according to you. This is a consequence of an inaccurate and unambiguous description of the algorithm. By the way, such a code with copying ticks will not work in 4k. 4ka does not memorise ticks, you need to memorise them yourself.)))))
I am so sick of reading all this nonsense... After all, the code is only FOUR lines, and the discussions are 3 pages long.
20,000 milliseconds is 20 seconds.
Next, put a condition on the size of the delta variable more/smaller, left/right or north/yuh....
Brutal code) On every tick, copy it))))))
...
this code will not work in 4k with copying ticks.
...
Read the title of the topic.
Read the title of the thread.
))))) you can't argue)
Hi all, I am writing a code for checking open positions in the Expert Advisor.
#include <Trade\PositionInfo.mqh>
#include <Trade\Trade.mqh>
#include <Trade\SymbolInfo.mqh>
#include <Trade\AccountInfo.mqh>
#include <Trade\DealInfo.mqh>
#include <Trade\OrderInfo.mqh>
CPositionInfo m_position; // trade position object
CTrade m_trade; // trading object
CSymbolInfo m_symbol; // symbol info object
CAccountInfo m_account; // account info wrapper
CDealInfo m_deal; // deals object
COrderInfo m_order; // pending orders object
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
bool ExistBuy(long magic_number)
{
for (int i = PositionsTotal() - 1; i >= 0; i--)
{
if (m_position.SelectByIndex(i))
{
if (m_position.PositionType() == POSITION_TYPE_BUY && m_position.Magic() == magic_number && m_position.Symbol() == Symbol())
{
return (true);
}
}
}
return (false);
}
The same code is available for sell positions. Everything works. But there is one broker (maybe there is a little more) he can open duplicate positions on a real account despite the check. And he does it not always. I.e. the error (opening a duplicate position) is not caught in the tester - everything is ok there, on the real account it is caught, but not always.
What is going on? Why is it so?
The same code is available for sell positions. Everything works. But there is one broker (maybe there is a little more) he can open duplicate positions on a real account despite the check. And he does it not always. I.e. the error (opening a duplicate position) is not caught in the tester - everything is ok there, it is caught on the real account, but not always.
What is going on? Why is it so?
Hello! And what are your conditions for opening a long and/or short position? Do you check that there is already one open BUY and/or SELL position?
Regards, Vladimir.
Hello! And what are your conditions for opening a long and/or short position? Do you check there that there is already one open BUY and/or SELL position?
Regards, Vladimir.
This is a demonstrative code, "How not to write" ...
Guys, give me a hint, please.
I was not a very good programmer in MT4 ) Now I'm switching to MT5.
I have encountered such a nuance:
I want open orders to be not more than one at a time, on mt4 it was easy enough to solve this ... In MT5 in the manual it is written "DO NOT confuse orders and deals" and it is written that it is necessary through the function
HistoryDealGetIntegerHistoryDealGetInteger function to request something there..... I don't understand anything, honestly. Please, kind people, explain it humanely.