Questions from Beginners MQL5 MT5 MetaTrader 5 - page 302
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
Cheers! Today I launched my first EA in MT5!
The right situation on the market came and the Expert Advisor started buying and buying!!! At least I managed to react in time. Can you tell me what is wrong in the code? I thought it should buy only one lot and immediately set a Stop Loss and Take Profit. As soon as he bought something, the variable Bye_opened should become true and it should not allow a subsequent trade until the stops are triggered. Also, how do I know the price of the last trade to put stops on it?
But it looks like I did something wrong. Please point out my mistake.
Ticks may come faster than the position is in the list of open positions. So, your check
won't work for a while, and during that time several entries will pass. It is assumed that the above piece of code is located in the tick handler.
put this script in the scripts folder, open this script in a unitor, compile it
When the exchange opens, drag this script onto the chart
Good evening everyone, please share the code for the trawl. Thanks.
Please use the site search - it's not hard:https://www.mql5.com/ru/search#!keyword=%D1%82%D1%80%D0%B0%D0%BB
Please use the site search - it is not difficult:https://www.mql5.com/ru/search#!keyword=%D1%82%D1%80%D0%B0%D0%BB
Ticks may come faster than the position is in the list of open. So, your check
will not work for some time, and during this time there will be multiple entries. It is assumed that the above piece of code is located in the tick handler.
Dima, the code is in the tick processing block. What's the right way to solve this problem? I had the same problem in QuickBooks, the robot often buys more than it should. I put it down to its second delay and simply added separate variable that changes when conditions are fulfilled, but it had some problems there too. Sometimes the order was rejected by the exchange and the variable already had the value "deal" and the robot didn't trade.
How to correctly solve the problem in MQL5, so the robot will buy a specified number of lots at a given condition and will not buy more than the specified number of lots until it has sold all the lots it has bought?
Should we pause after buying to wait for a response from the exchange for sure?
Sleep(1000); //Have you paused?
Stop loss does not move
writes:
--Modify order -> price open:1.3111 BID :1.3121 sl 1.3109
failed modify order #3 buy limit 1.00 at 1.31110 sl: 1.31080 tp: 0.00000 -> 1.31110, sl: 1.31090 tp: 0.00000 [Invalid stops]
--Modify order <- result:10016
Why?
Stop loss does not move
writes:
--Modify order -> price open:1.3111 BID :1.3121 sl 1.3109
failed modify order #3 buy limit 1.00 at 1.31110 sl: 1.31080 tp: 0.00000 -> 1.31110, sl: 1.31090 tp: 0.00000 [Invalid stops]
--Modify order <- result:10016
Why?
Normalize does not help. The same thing, sop-loss is not pulled up
--Create order -> ASK:1.3121 price:1.3111 sl 1.3106
buy limit 1.00 EURUSD at 1.3111 (1.3121) sl: 1.3106 (1.3118 / 1.3121 / 1.3118)
--Modify order -> price open:1.3111 BID :1.3119 sl 1.3107--Create order <- result:10009
order modified [#3 buy limit 1.00 EURUSD at 1.3111]
--Modify order <- result:10009
--Modify order -> price open:1.3111 BID :1.312 sl 1.3108order modified [#3 buy limit 1.00 EURUSD at 1.3111]
--Modify order <- result:10009
--Modify order -> price open:1.3111 BID :1.3121 sl 1.3109failed modify order #3 buy limit 1.00 at 1.31110 sl: 1.31080 tp: 0.00000 -> 1.31110, sl: 1.31090 tp: 0.00000 [Invalid stops]
--Modify order <- result:10016