Questions from Beginners MQL4 MT4 MetaTrader 4 - page 175

 

Can I have some of the code, I'm interested in how to loop through the dates?

//=================================================История на дату - Баланс ====================================================================================================

double Ballanc()

{

double date=0, history=0;

for ( int trade = OrdersTotal() - 1; trade >= 0; trade-- )

{

if ( OrderSelect(trade, SELECT_BY_POS, MODE_TRADES) && OrderMagicNumber() == MagicLock && OrderSymbol() == Symbol())

{

date=Day();

}

}

for ( trade = date - 1; trade >= 0; trade--)

{

for ( int trade = OrdersHistoryTotal() - 1; trade >= 0; trade-- )

{

if ( OrderSelect(trade,SELECT_BY_POS,MODE_HISTORY))

{

=OrderProfit(;)

}

}

}


return(profithistory);


 
or time to use, what's the best way?
 
I have an idea: take a day, a month, a year separately and do three cycles. Am I moving in the right direction?
 

This is the function! The condition was to know the account balance as of the opening date of the locking order.

//=================================================История на дату - Баланс ====================================================================================================

double Ballanc()

{

int date=31,month=12,year=0;

double history=0,swaphistory=0;

for ( int trade = OrdersTotal() - 1; trade >= 0; trade-- )

{

if ( OrderSelect(trade, SELECT_BY_POS, MODE_TRADES) && OrderMagicNumber() == MagicLock && OrderSymbol() == Symbol())

{

year=Year();

}

}

for (int trade=year;trade>=2018;trade--)

{

for ( trade=month;trade>=1;trade--)

{

for ( trade = date; trade >= 1; trade--)


{

for ( trade = OrdersHistoryTotal() - 1; trade >= 0; trade-- )

{

if ( OrderSelect(trade,SELECT_BY_POS,MODE_HISTORY) && date==Day() && month==Month() && year==Year())

{

swaphistory+=OrderProfit();

swaphistory+=OrderSwap();

}

}

}

}

}

return(profithistory+swaphistory)

}

 
The account balance link at the top appeared by itself...
 

In the Metacvot library, which is used to make panels, the ON_DRAG_PROCESS event is implemented.

There is a need to handle the ON_DRAG_PROCESS event for a separate trend line rather than for the panel elements within the code of such a panel. Is it possible and how to implement it? I have tried it and failed.

 

Good afternoon!

Can you please tell me in which situations after EA deinitialization a memory leak like "1 leaked strings left" may occur?

No more objects remain, all dynamic ones are deleted, this is the only memory leak message

 
Hello, could you tell me how to modify the take profit and stop loss calculation with every new bar?
 
mikesteb_87:
Hi, can you tell me how to modify the calculation of take profit and stop loss with every new bar?

You have a link to do it in your post: https://www.mql5.com/ru/articles/159.

Roughly, in OnTick to check if the bar has changed, and if it has changed - to call the necessary procedures to change the stop loss and take profit.

Обработчик события "новый бар"
Обработчик события "новый бар"
  • www.mql5.com
Для создателей индикаторов и экспертов всегда был актуален вопрос написания экономичного кода с точки зрения времени выполнения. Можно подойти к решению этой задачи с разных сторон. Из этой обширной темы в данной статье будет затронут, казалось бы уже решенный вопрос: проверка появления нового бара. Это достаточно популярный способ ограничения...
 
Zelimhannahal00:
Guys, help me fix EA code, on the first signal it buys for all funds in lots of 0.1. The error is most likely in checking orders, it turns out not to check but to buy. I can not figure out how to fix
Reason: