I have built my first Expert Advisor from the kindly provided codes (special thanks toMakarFX_ for motivation and code)
Everything works as it should, but with one problem. I don't know where to look for it.
The algorithm is as follows:
there is a signal - order opens
close it using stop or take order in points, or after the profit and loss limits have been reached in depo currency CountLoss and CountProfit. (whichever comes first)
if a stop - the next order with a margin, if a take, CountProfit, CountLoss - the lot is reset to the initial one
if the Stop Loss is set to CountLoss , the next order is opened with the minimum lot, for example, instead of the starting lot:
in external variables the starting lot 0.02 is set, the next order at CountLoss will be the lot 0.01.
I have built my first Expert Advisor from the kindly provided codes (special thanks toMakarFX_ for motivation and code)
Everything works as it should, but with one problem. I don't know where to look for it.
The algorithm is as follows:
there is a signal - order opens
close it using stop or take order in points, or after the profit and loss limits achievement in depo currency CountLoss and CountProfit. (whichever comes first)
if a stop - the next order with a margin, if a take, CountProfit, CountLoss - the lot is reset to the initial one
if the Stop Loss is set to CountLoss , the next order is opened with the minimum lot, for example, instead of the starting lot:
in external variables the starting lot 0.02 is set, the next order at CountLoss will be the lot 0.01.
Can someone tell me where the error is ?
Look what I have changed in the function double Lots()
Thanks for the thought. I compared the closing time of the current order with the closing time of the previous order and everything went as it should. I also made the function to open an order in the opposite direction with a stop loss, although it didn't help much.
Petronet: Thank you, I got the idea. I compared the closing time of the current order to the closing time of the previous order and everything went as it should. I have also made the function of opening an order in the opposite direction with a stop loss, although it did not help much.
Good afternoon, all. Trying to implement profit and stop calculation using atr indicator. The stop works fine. But the profit is always set to the same value. Here is the code for profit calculation
if(Tip_tp == en_TP_po_atr)// ЕСЛИ ПРОФИТ ПО АТР//-------------------------------------------------------------------------------------------------+
{
tp =NormalizeDouble(iATR(NULL,PeriodForWork_sl,atr_sl_period,1),Digits);// ПРИСВАЕВАЕМ ЗНАЧЕНИЙ АТР ДЛЯ ВЫСТАВЛЕНИЯ СТОПЛОССАif(tp<stoplevel) // ЕСЛИ ПРОФИТ МЕНЬШЕ ЧЕМ МИНИМАЛЬНО ДОПУСТИМЫЙ УРОВЕНЬ ЕГО УСТАНОВКИ ТО
{
tp=NormalizeDouble(tp*1.5,Digits); // ПРОФИТУ ПРИСВАЕВАЕМ МИНИМАЛЬНО ДОПУСТИМУЮ ВЕЛИЧИНУ ЕГО УСТАНОВКИ
}
}
tp= NormalizeDouble(tp*Point, Digits());// НОРМАЛИЗУЕМ ПРОФИТ, ЧТОБЫ РАБОТАЛО НА ЛЮБЫХ КАТИРОВКАХ//+--КОНЕЦ РАСЧЁТА ПРОФИТА---------------------------------------------------------------------- Разделитель ---+
What is the error that profit always has the same value? Huh?
Good afternoon, all. Trying to implement profit and stop calculation using atr indicator. The stop works fine. But the profit is always set to the same value. Here is the code for profit calculation
What is the error that profit always has the same value? Huh?
// ЕСЛИ ПРОФИТ ПО АТР//-------------------------------------------------------------------------------------------------+if(Tip_tp == en_TP_po_atr)
{
tp =NormalizeDouble(iATR(NULL,PeriodForWork_sl,atr_sl_period,1),Digits);// ПРИСВАЕВАЕМ ЗНАЧЕНИЙ АТР ДЛЯ ВЫСТАВЛЕНИЯ СТОПЛОССАif(tp<stoplevel) // ЕСЛИ ПРОФИТ МЕНЬШЕ ЧЕМ МИНИМАЛЬНО ДОПУСТИМЫЙ УРОВЕНЬ ЕГО УСТАНОВКИ ТО
{
tp=NormalizeDouble(tp*1.5,Digits); // ПРОФИТУ ПРИСВАЕВАЕМ МИНИМАЛЬНО ДОПУСТИМУЮ ВЕЛИЧИНУ ЕГО УСТАНОВКИ
}
}
//+--КОНЕЦ РАСЧЁТА ПРОФИТА---------------------------------------------------------------------- Разделитель ---+
Thank you for your help - I changed a piece of code and it all worked. But can you describe in words what the error was as I can't get ahead of it by eye?
DanilaMactep: Thank you for your help - I changed a piece of code - everything worked. But can you describe in words what was the error, as I can't get ahead of it by eye?
your code has been split
В этой части кода ты задаешь tp значение АТРif(Tip_tp == en_TP_po_atr)// ЕСЛИ ПРОФИТ ПО АТР//-------------------------------------------------------------------------------------------------+
{
tp =NormalizeDouble(iATR(NULL,PeriodForWork_sl,atr_sl_period,1),Digits);// ПРИСВАЕВАЕМ ЗНАЧЕНИЙ АТР ДЛЯ ВЫСТАВЛЕНИЯ СТОПЛОССАif(tp<stoplevel) // ЕСЛИ ПРОФИТ МЕНЬШЕ ЧЕМ МИНИМАЛЬНО ДОПУСТИМЫЙ УРОВЕНЬ ЕГО УСТАНОВКИ ТО
{
tp=NormalizeDouble(tp*1.5,Digits); // ПРОФИТУ ПРИСВАЕВАЕМ МИНИМАЛЬНО ДОПУСТИМУЮ ВЕЛИЧИНУ ЕГО УСТАНОВКИ
}
}
А в этой части ты обнуляешь предыдущее действие и задаешь непонятно что...
tp= NormalizeDouble(tp*Point, Digits());// НОРМАЛИЗУЕМ ПРОФИТ, ЧТОБЫ РАБОТАЛО НА ЛЮБЫХ КАТИРОВКАХ
Good afternoon! Please help me get my terminal up and running - the market is not working. I want to download a free indicator from the market and I can't.
I changed the password, rebooted, but nothing works.
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.
I have built my first Expert Advisor from the kindly provided codes (special thanks toMakarFX_ for motivation and code)
Everything works as it should, but with one problem. I don't know where to look for it.
The algorithm is as follows:
there is a signal - order opens
close it using stop or take order in points, or after the profit and loss limits have been reached in depo currency CountLoss and CountProfit. (whichever comes first)
if a stop - the next order with a margin, if a take, CountProfit, CountLoss - the lot is reset to the initial one
if the Stop Loss is set to CountLoss , the next order is opened with the minimum lot, for example, instead of the starting lot:
in external variables the starting lot 0.02 is set, the next order at CountLoss will be the lot 0.01.
Can someone tell me where the error is ?
I have built my first Expert Advisor from the kindly provided codes (special thanks toMakarFX_ for motivation and code)
Everything works as it should, but with one problem. I don't know where to look for it.
The algorithm is as follows:
there is a signal - order opens
close it using stop or take order in points, or after the profit and loss limits achievement in depo currency CountLoss and CountProfit. (whichever comes first)
if a stop - the next order with a margin, if a take, CountProfit, CountLoss - the lot is reset to the initial one
if the Stop Loss is set to CountLoss , the next order is opened with the minimum lot, for example, instead of the starting lot:
in external variables the starting lot 0.02 is set, the next order at CountLoss will be the lot 0.01.
Can someone tell me where the error is ?
Look what I have changed in the function double Lots()
Will print once when there is a loss trade
Thank you, I got the idea. I compared the closing time of the current order to the closing time of the previous order and everything went as it should. I have also made the function of opening an order in the opposite direction with a stop loss, although it did not help much.
More specifically...
Good afternoon, all. Trying to implement profit and stop calculation using atr indicator. The stop works fine. But the profit is always set to the same value. Here is the code for profit calculation
What is the error that profit always has the same value? Huh?
Good afternoon, all. Trying to implement profit and stop calculation using atr indicator. The stop works fine. But the profit is always set to the same value. Here is the code for profit calculation
What is the error that profit always has the same value? Huh?
See what I changed in the double Lots() function
super! thanks a lot!
Thank you for your help - I changed a piece of code - everything worked. But can you describe in words what was the error, as I can't get ahead of it by eye?
your code has been split
I changed the password, rebooted, but nothing works.
The program logs the following
2021.08.23 11:54:18.236 MQL5 Market failed downloading product 'MACD Intraday Trend'(www.mql5.com:443 send failed [426: ])
Regards, Olga