Hello all. Can someone help to edit the EA. I need to remove the order opening function, so the EA will not open orders by itself, but only work with manually opened orders. Many thanks in advance.
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
intOnCalculate( constint rates_total, // размер входных таймсерий constint prev_calculated, // обработано баров на предыдущем вызове constdatetime& time[], // Time constdouble& open[], // Open constdouble& high[], // High constdouble& low[], // Low constdouble& close[], // Close constlong& tick_volume[], // Tick Volume constlong& volume[], // Real Volume constint& spread[] // Spread
) {
// код зиг-зага
...
if (prev_calculated > 0) // дальнейший код сработает только один разreturn (rates_total);
// обработка значений зиг-загаfor (int i = rates_total - 1; i >= 0; i--) {
if (zigZag[i] > 0) { // найден экстремум// сохраняем time[i] в любую удобную форму для дальнейшей работы
}
}
return (rates_total);
}
the loop above (from right to left) is intended for MQL5
for MQL4 the loop will be from left to right
for (int i = 0; i < rates_total; i++)
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).
voidOnTick()
{
// Получим значение индикатора
dMA = iMA(Symbol(), 0,PeriodMA, MovingShift, MODE_SMA, PRICE_CLOSE, 0); // MODE_SMA - простое усреднение , значение 0. PRICE_CLOSE- цена закрытия, значение 0.// Если нет открытых ордеров, то входим в условиеif(CountOrders()==0)
{
// Если появился сигнал на покупку, то откроем ордер на покупкуif(bSignalBuy() == true)
vOrderOpenBuy();
// Если появился сигнал на продажу, то откроем ордер на продажуif(bSignalSell() == true)
vOrderOpenSell();
}
DrawLABEL("nextlot",1,5,0,Color1(),StringConcatenate("CURRENT LOT: ",DoubleToStr(LOT(),2)));
DrawLABEL("currentlot",1,5,0,Color2(),StringConcatenate("NEXT LOT: ",DoubleToStr(LOT(),2)));
TrailingOrders();
}
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.
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
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
Вещественные типы (double, float) - Типы данных - Основы языка - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
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.