Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1402
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
Hi there,
I am trying to make a very simple EA that compares two closing prices and based on that it either opens a buy or a sell order.
All goes well on the first order, but as soon as the condition switches from sell to buy, it places multiple orders at once.
m_trade is a Ctrade object.
Hi there,
I am trying to make a very simple EA that compares two closing prices and based on that it either opens a buy or a sell order.
All goes well on the first order, but as soon as the condition switches from sell to buy, it places multiple orders at once.
m_trade is a Ctrade object .
You forgot that the 'startTime' time needs to be reset.
You forgot that the 'startTime' time needs to be reset.
Thank you Vladimir, I will try to fix it based on your hint.
Yet, I am still suprised. Because in the if statement for entering a trade, we check for an existing order placement of the same type. If this is true, then the order should not be placed. So I thought with this statement only 1 type of order can be entered at the same time.
Is this thought incorrect?
Thank you Vladimir, I will try to fix it based on your hint.
Yet, I am still suprised. Because in the if statement for entering a trade, we check for an existing order placement of the same type. If this is true, then the order should not be placed. So I thought with this statement only 1 type of order can be entered at the same time.
Is this thought incorrect?
You do not control the ORDERS in any way, you check the number and type of the POSITION in the code. Besides - you incorrectly work with POSITIONS (error to use 'PositionSelect(_Symbol)' if your account type is hedging). Your algorithm has serious design errors.
What You Should Do:
1. Work EXCLUSIVELY at the time of the birth of a new bar. If there is no new bar - do nothing, do not make unnecessary movements.
2. This item will be disclosed after item 1 is completed.
Yes, in MT5 it slows down the operation considerably.
In OnInit it only works once during initialisation and no more.
Are you talking about the Comment() function?
If yes, then that is obvious. In the OnInit(), the comment will only update once, while on OnTick() the comment might end up being updated on every tick.
The solution is to only update the comment when needed. If it is static, then updated in only on OnInit() and clear it it in OnDeinit(), but if it is dynamic, then in OnTick() only update the comment when it needs to be changed.
EDIT: This post was originally done on the English forum.
Good day to all.
I have a question
how to make a query to sqlite to select a row from a ticket.
The structure of the database is as follows:
symbol-text
ticket - text
pirce- real
s_l - real
t_p - real
need to get the whole ticket string into the structure