Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1830
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
No script?
No script?
We take a zig-zag and in OnCalculace check its buffer for values usually greater than 0 (it means that the buffer stores the value of the extremum, low or high). We loop through the buffer using the
the loop above (from right to left) is intended for MQL5
for MQL4 the loop will be from left to right
The above examples give new time values first. To get the values senior in time first, use ArraySetAsSeries or reverse the direction of the loop.
Data can be retrieved from the script using iCustom, CopyTime or iTime as well as iBars (instead of rates_total).
I must be misunderstanding something.
if i switch the function in
then stop and takeaway are instantly shifted an infinite number of times
Ifyou don't use TrailingOrders(); then nothing shifts.
My task was not to create a trailing move, but to move stop and takeout one/two times.
I've been "inventing" things all day today, so far nothing works.
I must be misunderstanding something.
if i switch the function in
then stop and takeaway are instantly shifted an infinite number of times
Ifyou don't use TrailingOrders(); then nothing shifts.
My task was not to create a trailing move, but to move stop and takeout one/two times.
I've been "inventing" things all day long, so far nothing works.
Trailing stop should work if the price moved in the direction of TP, and it should not do anything if the price rolls back. The SL level should go only in the direction of the TP and not roll back.
A trailing stop should be triggered if the price moves in the direction of the TP and do nothing if the price pulls back. The SL level should only go in the direction of the TP and not roll back.
I know
I wrote.
there is an infinite number of stop and take positions instantly
2021.12.23 21:07:51.634 2021.12.21 21 21:12:20 111 AUDUSD,M15: Buy order modification successful!
2021.12.23 21:07:51.634 2021.12.21 21 21:12:20 111 AUDUSD,M15: modify #2 buy 0.02 AUDUSD at 0.71028 sl: 0.71288 tp: 0.72038 ok
2021.12.23 21:07:51.634 2021.12.21 21 12:12:18 111 AUDUSD,M15: Buy Order Modification successful!
2021.12.23 21:07:51.634 2021.12.21 21 21:12:18 111 AUDUSD,M15: modify #2 buy 0.02 AUDUSD at 0.71028 sl: 0.71268 tp: 0.72018 ok
2021.12.23 21:07:51.634 2021.12.21 21 12:12:16 111 AUDUSD,M15: Buy Order Modification successful!
2021.12.23 21:07:51.634 2021.12.21 21 21:12:16 111 AUDUSD,M15: modify #2 buy 0.02 AUDUSD at 0.71028 sl: 0.71248 tp: 0.71998 ok
2021.12.23 21:07:51.634 2021.12.21 21 12:12:15 111 AUDUSD,M15: Buy Order Modification successful!
2021.12.23 21:07:51.634 2021.12.21 21 21:12:15 111 AUDUSD,M15: modify #2 buy 0.02 AUDUSD at 0.71028 sl: 0.71228 tp: 0.71978 ok
2021.12.23 21:07:51.634 2021.12.21 21 12:12:13 111 AUDUSD,M15: Buy Order Modification successful!
2021.12.23 21:07:51.634 2021.12.21 21 21:12:13 111 AUDUSD,M15: modify #2 buy 0.02 AUDUSD at 0.71028 sl: 0.71208 tp: 0.71958 ok
2021.12.23 21:07:51.634 2021.12.21 21 12:12:11 111 AUDUSD,M15: Buy Order Modification successful!
2021.12.23 21:07:51.634 2021.12.21 21 21:12:11 111 AUDUSD,M15: modify #2 buy 0.02 AUDUSD at 0.71028 sl: 0.71188 tp: 0.71938 ok
2021.12.23 21:07:51.634 2021.12.21 12:12:10 111 AUDUSD,M15: Buy Order Modification successful!
2021.12.23 21:07:51.634 2021.12.21 21 21:12:10 111 AUDUSD,M15: modify #2 buy 0.02 AUDUSD at 0.71028 sl: 0.71168 tp: 0.71918 ok
2021.12.23 21:07:51.634 2021.12.21 21 12:12:08 111 AUDUSD,M15: Buy Order Modification successful!
2021.12.23 21:07:51.634 2021.12.21 21 21:12:08 111 AUDUSD,M15: modify #2 buy 0.02 AUDUSD at 0.71028 sl: 0.71148 tp: 0.71898 ok
2021.12.23 21:07:51.634 2021.12.21 21 12:12:06 111 AUDUSD,M15: Buy Order Modification successful!
2021.12.23 21:07:51.634 2021.12.21 21 21:12:06 111 AUDUSD,M15: modify #2 buy 0.02 AUDUSD at 0.71028 sl: 0.71128 tp: 0.71878 ok
2021.12.23 21:07:51.634 2021.12.21 21 12:12:05 111 AUDUSD,M15: Buy Order Modification successful!
2021.12.23 21:07:51.634 2021.12.21 21 21:12:05 111 AUDUSD,M15: modify #2 buy 0.02 AUDUSD at 0.71028 sl: 0.71108 tp: 0.71858 ok
2021.12.23 21:07:51.634 2021.12.21 21 12:12:00 111 AUDUSD,M15: Modify Buy Order Successful!
2021.12.23 21:07:51.634 2021.12.21 21 21:12:00 111 AUDUSD,M15: modify #2 buy 0.02 AUDUSD at 0.71028 sl: 0.71088 tp: 0.71838 ok
2021.12.23 21:07:51.634 2021.12.21 12:11:53 111 AUDUSD,M15: Buy Order Modification successful!
2021.12.23 21:07:51.634 2021.12.21 12:11:53 111 AUDUSD,M15: modify #2 buy 0.02 AUDUSD at 0.71028 sl: 0.71068 tp: 0.71818
2021.12.23 21:07:51.634 2021.12.21 12:11:52 111 AUDUSD,M15: Modify Buy Order Successful!
I know.
I wrote.
the stop and take are moved instantly an infinite number of times
You should get the SL of the order being modified and compare it with the calculated SL. If they are equal, the robot should do nothing until the calculated SL exceeds the SL of the order being processed. How to compare two double values: either compare NodmalizeDouble(value, Digits) (of each value) or EqualDoubleshttps://www.mql5.com/ru/docs/basis/types/double
I know.
You set it correctly. Did you change anything inside the TrailingOrders() function?
You should get the SL of the order being modified and compare it with the calculated SL. ...
In general, the rules are as follows.