Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1565

 

colleagues, how in netting positions and orders - to close part of a market position in the MT 5 terminal, here I understand - at hedging:

https://www.mql5.com/ru/docs/standardlibrary/tradeclasses/ctrade/ctradepositionclosepartial

Документация по MQL5: Стандартная библиотека / Торговые классы / CTrade / PositionClosePartial
Документация по MQL5: Стандартная библиотека / Торговые классы / CTrade / PositionClosePartial
  • www.mql5.com
PositionClosePartial(const string,const double,ulong) - CTrade - Торговые классы - Стандартная библиотека - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Roman Shiredchenko:

colleagues, how in netting positions and orders - to close part of a market position in the MT 5 terminal, here I understand - at hedging:

https://www.mql5.com/ru/docs/standardlibrary/tradeclasses/ctrade/ctradepositionclosepartial

with a counter-order
 
MakarFX:
with a counter order

Ah, I see, with a smaller counter position, without

https://www.mql5.com/ru/docs/standardlibrary/tradeclasses/ctrade/ctradepositioncloseby

spc.
Документация по MQL5: Стандартная библиотека / Торговые классы / CTrade / PositionCloseBy
Документация по MQL5: Стандартная библиотека / Торговые классы / CTrade / PositionCloseBy
  • www.mql5.com
PositionCloseBy(const ulong,const ulong) - CTrade - Торговые классы - Стандартная библиотека - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
MakarFX:

Basically, it doesn't matter how the swap or commission is calculated, as long as the amount

has always been more than "0".

How can it not matter, if high swap and commission reduce winnings and increase deposit losses? All right, if the strategy is stable... But this is the world of fantasy, as practice shows. And then there are the commissions...

 
the commission counts as a fix spread.
 
Mihail Matkovskij:

So how can it be purple if high swaps and commissions reduce winnings and increase deposit drains? OK, if the strategy is dragging steadily... But this is from the world of fiction, as practice shows. And the commissions...

I meant the main thing that the total profit of the account should be positive

either

p= OrderProfit()+OrderCommission()+OrderSwap()

or

p+= OrderProfit()+OrderCommission()+OrderSwap()
 

MakarFX:
Я могу ошибаться, но думаю надо объявлять глобально только

int или double   NB_M1;

Only int or double?
What if the variable is an object of a class?
And if number of such objects is unknown beforehand [before execution of OnInit()]?
And if the parameters of constructors in advance [before execution of OnInit()] are unknown?

 
Maxim Kuznetsov:

so for signals :-)

In those places, the more (by any means) closed on the plus side, the more risk-free money arrived.

ah, there you go...

 

Functional programming will save the "father of Russian democracy" ))))

>>>>>>> Far from professional opinion, but "classes" and OOP in general, in this context ... do not need it! All the more so, all this "stuff" (excuse me) - it's "whatever I want and whatever I turn...". !

 
Сергей Таболин:

Functional programming will save the "father of Russian democracy" ))))

>>>>>>> Far from professional opinion, but "classes" and OOP in general, in this context ... do not need it! All the more so, all this "stuff" (excuse me) - it's "whatever I want and whatever I turn...". !

If you have an Expert Advisor of three lines, then you don't need OOP of course)