[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 207
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
Gentlemen, please tell me how to code (probably in a conditional statement) a simple idea
-if a trade was closed at a stop loss
-open another trade at the stop loss price
Thank you
1. You cannot open orders in the init() function. (In the Strategy Tester, this will still work, but it will not work on the demo).
2. When you close orders, you should count from the end to the beginning, and not vice versa, like in your case.
Thank you for your reply.
In this case the loop operator was investigated in the tester, that is why orders are opened in init() for simplification, this does not happen in real EAs.
A change in the order of order selection does indeed lead to the closure of orders within one tick (I give the code of the program and report from the tester log below).
It seems strange that MQL4 does not allow me to change the order of working with orders. If you know why, please advise, since according to the work logic of an EA I am going to close orders exactly in the order they are opened.
Sincerely. Shurkin.
You can't open exactly at the stop loss price, but you can condition to open in the same or opposite direction!
Here is a function call from Kim's "Useful Functions", which you can put in a condition:
isCloseLastPosByStop - Returns flag to close last position by stop
if(isCloseLastPosByStop() == 0) or ... == 1) and whatever you want ......
You can find the function here: https://www.mql5.com/ru/forum/131859
And put it outside the start!
And I beg you! You may do all this by yourself, with diligence, accuracy and patience, otherwise you will not learn anything from hints!
Knowledge is gained only with adequate effort on your part! Get into daily inquisitive work! Good luck!
Good day.
Please tell me if there are situations where TCs can change or delete comments to an order?
Thank you very much.
Please tell me if there are situations where TCs can change or delete comments to an order...?
Native comment
e121220_3in1 01
With added DC after rollover
e121220_3in1 01[swap]
That is, if we search for an order with a comment, we should preliminarily determine the length of the native comment line and during the search we only check the first part of the changed comment in the corresponding length. Or check if the native string is in the comment being checked.
Shurkin:
Thanks for the reply.
In this case the work of loop operator was investigated exactly in the tester, that is why orders are opened in init() for simplification, it does not happen in real EAs.
Changing the order of order selection does lead to closure of orders within one tick (I give the code of the program and report from the tester log below).
It seems strange that MQL4 does not allow me to select an order. If you know why, please advise, as the work logic of the Expert Advisor suggests that orders should be closed exactly in the order they are opened.
Sincerely. Shurkin.
The logic is correct - the order numbers of the orders should be the same as the order numbers. Once one order is closed, all of the others will be recalculated. Try this construction
Good day.
Please tell me if there are situations where TCs can change or delete comments to an order?
Thank you very much.
We have experienced a complete change of comment on an order. Also, magic is sometimes zeroed out during partial closures (partial closures are initiated by the server). Now, there is a separate, looped advisor to control the latter, which monitors "alien" orders and other inconsistencies, notifying by Push messages in a timely manner.
Please advise how to write the condition correctly:
1.if order symbol = symbol and order magik = 135
2.if there are no pending BAYSTOP orders
3.if there are no open orders BAY OR (if there are) stoploss>open price
4.if price is between MA and fractal up
PLACE PENDING BUYSTOP ORDER
WRITTEN LIKE THIS:
DOES NOT WORK! TELL ME WHAT THE MISTAKE IS!
Please advise what could be causing the following problem.
There is an indicator which uses external functions. The compiled library code is located in the libraries folder, descriptors - in include.
Connection #include <lib_Zemckikh.mqh>. During the first run of the indicator, all library functions work normally, the indicator is displayed on the chart. After a change of parameters (after a new calculation of the indicator) the library functions are not called, the indicator is not displayed, there are no entries in the "Experts" tab after the change of parameters.
If you exclude the connection of the library and place the required functions in the indicator file (compiled directly with the functions), everything works fine.
I can't understand what's wrong. I don't want to pollute the forum, I'm not attaching the codes. If you need it, I'll send it to you in person.