MQL5:
Ik probeer een functie te schrijven om de reeks te sluiten.
Er is geen fout na het compileren, maar deze wordt niet uitgevoerd.
Ik kon niet achterhalen waarom. Kunt u helpen?
Dank je!
Afsluiten op volgorde volgorde.
d.w.z.
Deal 1 Deal 2 heeft geprofiteerd - close
Deal 3 Deal 4 heeft geprofiteerd - close
5 6
7 8
9 10
enzovoorts ...
Deal 1 heeft het kleinste ordernummer en wordt zo vroeg mogelijk geopend.
Deal 10 heeft het grootste ordernummer en wordt op het laatst geopend.
Ingevoegd Code void CloseBySequence () {datetime from = 0; datetime to = TimeCurrent (); HistorySelect (van tot); dubbele Minimum_Profit = 5,00; ulong-ticket; uint x; dubbele transacties # 91; # 93; # 91; 2 # 93 ;; uint total = HistoryDealsTotal (); if (totalgt; 1) {ArrayResize (transacties, totaal); for (x = total-1; xgt; = 0; x--) {if (ticket = HistoryDealGetTicket (x)) gt; 0) {trades # 91; x # 93; # 91; 0 # 93; = HistoryDealGetInteger (ticket, DEAL_ORDER); trades # 91; x # 93; # 91; 1 # 93; = HistoryDealGetDouble (ticket, DEAL_PROFIT) HistoryDealGetDouble (ticket, DEAL_COMMISSION) HistoryDealGetDouble (ticket, DEAL_SWAP); }} ArraySort (transacties); x = 0; terwijl (xlt; totaal-1) {dubbele winst = transacties # 91; x # 93; # 91; 1 # 93; transacties # 91; x 1 # 93; # 91; 1 # 93 ;; if (profitgt; = Minimum_Profit) {if (HistoryDealSelect ((int) transacties # 91; x # 93; # 91; 0 # 93;)) if (! trade.PositionClose (PositionGetSymbol (x))) Afdrukken (Foutafsluiting ( Deal 1/2) #, IntegerToString (OrderGetTicket (x)), Foutcode, GetLastError ()); if (HistoryDealSelect ((int) handelt # 91; x 1 # 93; # 91; 0 # 93;)) if (! trade.PositionClose (PositionGetSymbol (x))) Afdrukken (Fout sluiten (Deal 2/2) # , IntegerToString (OrderGetTicket (x)), Foutcode, GetLastError ()); } x = 2; }}}