Erreurs, bugs, questions - page 2020

 
fxsaber:

Un bug, bien sûr. Écrire dans le SD.

Cette ligne fonctionne comme elle le devrait, mais j'ai dû vérifier car je dois deviner l'ordre d'exécution. Discussion de ce point ici.

L'ordre des expressions de calcul dans Print() est de droite à gauche. En quelque sorte... Jusqu'à présent... Je l'ai également vérifié à l'avance :)


Il est difficile d'être sûr quand il y a unecontradiction directe dans la référence MQL4/5 :

Référence MQL5Fondamentaux du langageFonctionsPassage de paramètres

Note

N'oubliez pas que les paramètres sont transmis à la fonction à l'envers, c'est-à-dire que le dernier paramètre est calculé et transmis en premier, puis l'avant-dernier, et ainsi de suite. Le paramètre qui est le premier après la parenthèse ouvrante est calculé et passé en dernier.


Référence MQL5Fondamentaux du langageOpérations et expressionsAutres opérations

Appel de fonction avec les arguments x1, x2,..., xn

Chaque argument peut être une constante, une variable ou une expression d'un type correspondant. Les arguments passés sont séparés par des virgules et doivent être mis entre parenthèses, la parenthèse ouvrante doit suivre le nom de la fonction.

La valeur de l'expression est la valeur renvoyée par la fonction. Si le type de valeur de retour d'une fonction est void, l'appel de fonction ne peut pas être placé à droite de l'opération d'affectation. Notez que l'ordre des expressions x1,..., xn est garanti.


Pour l'instant, je me concentre sur le passage des paramètres dans l'ordre inverse.

 
Kirill Belousov:

Une question sur OrderCalcMargin a été soulevée dans un fil de discussion voisinhttps://www.mql5.com/ru/forum/216697/page3.


Test : vérifions 2 façons différentes de calculer le dépôt en substituant différents prix d'ouverture.

Voici le LOG

La fonction OrderCalcMargin ne prend pas en compte le prix d'ouverture lors du calcul de la marge.

Cela semble être lié au taux de change de la devise cotée, qui doit être recalculé pour l'heure et le prix d'ouverture.

Si la devise cotée est l'USD (et que la devise du compte est également l'USD), la marge calculée changera en fonction du prix d'ouverture.

Journal pour GBPUSD

Est-ce un bug ou devrait-il l'être ?

Il est probable qu'elle devrait l'être, car l'AUDUSD et l'USDJPY en particulier sont impliqués dans le calcul, et leurs cotations sont constantes au moment du calcul.

Maintenant, cette pensée me donne envie de vérifier... Dans le compte MetaQuotes-Demo, dans l'aperçu du marché, le GBPUSD est présent, mais pas dans le compte robo...

 
Alexey Viktorov:

Cela doit être le cas parce que AUDUSD et USDJPY en particulier sont impliqués dans le calcul et leurs cotations sont inchangées au moment du calcul.

Maintenant, cette pensée me donne envie de vérifier... GBPUSD est présent dans le compte MetaQuotes-Demo, mais pas dans le compte Robo-...

Je voulais juste vous dire - qu'il y a un bug.

J'ai déjà reproduit votre situation avec Margin=0 dans le calcul de OrderCalcMargin.

Je ne l'ai juste pas encore posté.

 
Alexey Viktorov:

Dans le compte MetaQuotes-Demo, le GBPUSD est présent dans Market Watch, mais pas dans le compte Robo...

Très probablement présent dans Market Watch (à ne pas confondre avec la liste générale des symboles), mais non affiché.

 
Alexey Viktorov:

Cela doit être le cas parce que AUDUSD et USDJPY en particulier sont impliqués dans le calcul et leurs cotations sont inchangées au moment du calcul.

Maintenant, cette pensée me donne envie de vérifier... Dans le compte MetaQuotes-Demo, dans l'aperçu du marché, le GBPUSD est présent mais pas dans le compte robo...

Voici le test :

#define  TOSTRING(A) #A+" = "+(string)(A)
void OnStart()
  {
   double margin_1=999,price_1;

   Print(TOSTRING(price_1=SymbolInfoDouble(Symbol(),SYMBOL_ASK)));
   Print("price_1= ",price_1," margin_1= ",NormalizeDouble(margin_1,8)," ",TOSTRING(OrderCalcMargin(ORDER_TYPE_BUY,_Symbol,0.1,price_1,margin_1)));
   Print("price_1= ",price_1," margin_1= ",NormalizeDouble(margin_1,8)," ",TOSTRING(MyOrderCalcMargin(ORDER_TYPE_BUY,_Symbol,0.1,price_1,margin_1)));
   Print(TOSTRING(price_1=SymbolInfoDouble(Symbol(),SYMBOL_BID)));
   Print("price_1= ",price_1," margin_1= ",NormalizeDouble(margin_1,8)," ",TOSTRING(OrderCalcMargin(ORDER_TYPE_BUY,_Symbol,0.1,price_1,margin_1)));
   Print("price_1= ",price_1," margin_1= ",NormalizeDouble(margin_1,8)," ",TOSTRING(MyOrderCalcMargin(ORDER_TYPE_BUY,_Symbol,0.1,price_1,margin_1)));
   Print(TOSTRING(price_1=10.0));
   Print("price_1= ",price_1," margin_1= ",NormalizeDouble(margin_1,8)," ",TOSTRING(OrderCalcMargin(ORDER_TYPE_BUY,_Symbol,0.1,price_1,margin_1)));
   Print("price_1= ",price_1," margin_1= ",NormalizeDouble(margin_1,8)," ",TOSTRING(MyOrderCalcMargin(ORDER_TYPE_BUY,_Symbol,0.1,price_1,margin_1)));
   Print(TOSTRING(price_1=1.0));
   Print("price_1= ",price_1," margin_1= ",NormalizeDouble(margin_1,8)," ",TOSTRING(OrderCalcMargin(ORDER_TYPE_BUY,_Symbol,0.1,price_1,margin_1)));
   Print("price_1= ",price_1," margin_1= ",NormalizeDouble(margin_1,8)," ",TOSTRING(MyOrderCalcMargin(ORDER_TYPE_BUY,_Symbol,0.1,price_1,margin_1)));
//выведем признак выбранности мажоров
   Print(TOSTRING(SymbolInfoInteger("GBPUSD",SYMBOL_SELECT)));
   Print(TOSTRING(SymbolInfoInteger("USDJPY",SYMBOL_SELECT)));
   Print(TOSTRING(SymbolInfoInteger("USDCAD",SYMBOL_SELECT)));
   Print(TOSTRING(SymbolInfoInteger("AUDUSD",SYMBOL_SELECT)));
   Print(TOSTRING(SymbolInfoInteger("NZDUSD",SYMBOL_SELECT)));
   Print(TOSTRING(SymbolInfoInteger("USDCHF",SYMBOL_SELECT)));
   Print(TOSTRING(SymbolInfoInteger("EURUSD",SYMBOL_SELECT)));
   for(int i=SymbolsTotal(false)-1;i>=0;i--)
     {
       //проверим для каждого символа брокера ситуацию, когда OrderCalcMargin()==true, а маржа=0
       if(OrderCalcMargin(ORDER_TYPE_BUY,SymbolName(i,false),0.1,SymbolInfoDouble(SymbolName(i,false),SYMBOL_ASK),margin_1)==true && margin_1==0)
        {
         Print(TOSTRING(SymbolName(i,false))," ",TOSTRING(margin_1)," ");
        }
     }
  }

// Альтернатива OrderCalcMargin
bool MyOrderCalcMargin(const ENUM_ORDER_TYPE action,const string symbol,const double volume,const double price,double &margin)
  {
   double MarginInit,MarginMain;

   const bool Res=SymbolInfoMarginRate(symbol,action,MarginInit,MarginMain);

   margin=Res ? MarginInit*price*volume*SymbolInfoDouble(symbol,SYMBOL_TRADE_TICK_VALUE)/
          (SymbolInfoDouble(symbol,SYMBOL_TRADE_TICK_SIZE)*AccountInfoInteger(ACCOUNT_LEVERAGE)) : 0;

   return(Res);
  }

1. Sélectionner les croisements dans MarketWatch, cacher tout ce qui est en USD

2. ajouter le symbole DSHBTC et ouvrir son graphique.

3. Fermer le terminal

4) Ouvrir le terminal

5. Commençons le test pour DSHBTC

Voici le LOG :

JM      0       09:26:05.485    test (DSHBTC,H1)        price_1=SymbolInfoDouble(Symbol(),SYMBOL_ASK) = 0.07183
QK      0       09:26:05.487    test (DSHBTC,H1)        price_1= 0.07183 margin_1= 0.0 OrderCalcMargin(ORDER_TYPE_BUY,_Symbol,0.1,price_1,margin_1) = true
KO      0       09:26:05.487    test (DSHBTC,H1)        price_1= 0.07183 margin_1= 0.0 MyOrderCalcMargin(ORDER_TYPE_BUY,_Symbol,0.1,price_1,margin_1) = true
QN      0       09:26:05.487    test (DSHBTC,H1)        price_1=SymbolInfoDouble(Symbol(),SYMBOL_BID) = 0.07079000000000001
NJ      0       09:26:05.487    test (DSHBTC,H1)        price_1= 0.07079000000000001 margin_1= 0.0 OrderCalcMargin(ORDER_TYPE_BUY,_Symbol,0.1,price_1,margin_1) = true
HO      0       09:26:05.487    test (DSHBTC,H1)        price_1= 0.07079000000000001 margin_1= 0.0 MyOrderCalcMargin(ORDER_TYPE_BUY,_Symbol,0.1,price_1,margin_1) = true
LL      0       09:26:05.487    test (DSHBTC,H1)        price_1=10.0 = 10.0
EE      0       09:26:05.487    test (DSHBTC,H1)        price_1= 10.0 margin_1= 0.0 OrderCalcMargin(ORDER_TYPE_BUY,_Symbol,0.1,price_1,margin_1) = true
QF      0       09:26:05.487    test (DSHBTC,H1)        price_1= 10.0 margin_1= 0.0 MyOrderCalcMargin(ORDER_TYPE_BUY,_Symbol,0.1,price_1,margin_1) = true
HD      0       09:26:05.487    test (DSHBTC,H1)        price_1=1.0 = 1.0
EN      0       09:26:05.487    test (DSHBTC,H1)        price_1= 1.0 margin_1= 0.0 OrderCalcMargin(ORDER_TYPE_BUY,_Symbol,0.1,price_1,margin_1) = true
OM      0       09:26:05.487    test (DSHBTC,H1)        price_1= 1.0 margin_1= 0.0 MyOrderCalcMargin(ORDER_TYPE_BUY,_Symbol,0.1,price_1,margin_1) = true
EN      0       09:26:05.487    test (DSHBTC,H1)        SymbolInfoInteger(GBPUSD,SYMBOL_SELECT) = 0
GI      0       09:26:05.487    test (DSHBTC,H1)        SymbolInfoInteger(USDJPY,SYMBOL_SELECT) = 0
DS      0       09:26:05.487    test (DSHBTC,H1)        SymbolInfoInteger(USDCAD,SYMBOL_SELECT) = 0
JL      0       09:26:05.487    test (DSHBTC,H1)        SymbolInfoInteger(AUDUSD,SYMBOL_SELECT) = 0
JF      0       09:26:05.487    test (DSHBTC,H1)        SymbolInfoInteger(NZDUSD,SYMBOL_SELECT) = 0
MQ      0       09:26:05.487    test (DSHBTC,H1)        SymbolInfoInteger(USDCHF,SYMBOL_SELECT) = 0
HK      0       09:26:05.487    test (DSHBTC,H1)        SymbolInfoInteger(EURUSD,SYMBOL_SELECT) = 0
LH      0       09:26:05.488    test (DSHBTC,H1)        SymbolName(i,false) = DSHBTC margin_1 = 0.0 
RS      0       09:26:05.489    test (DSHBTC,H1)        SymbolName(i,false) = NZDJPY margin_1 = 0.0 
FE      0       09:26:05.489    test (DSHBTC,H1)        SymbolName(i,false) = NZDCHF margin_1 = 0.0 
QO      0       09:26:05.489    test (DSHBTC,H1)        SymbolName(i,false) = NZDCAD margin_1 = 0.0 
RP      0       09:26:05.489    test (DSHBTC,H1)        SymbolName(i,false) = GBPNZD margin_1 = 0.0 
JD      0       09:26:05.489    test (DSHBTC,H1)        SymbolName(i,false) = GBPCAD margin_1 = 0.0 
CN      0       09:26:05.489    test (DSHBTC,H1)        SymbolName(i,false) = GBPJPY margin_1 = 0.0 
KP      0       09:26:05.489    test (DSHBTC,H1)        SymbolName(i,false) = GBPCHF margin_1 = 0.0 
JK      0       09:26:05.489    test (DSHBTC,H1)        SymbolName(i,false) = GBPAUD margin_1 = 0.0 
QL      0       09:26:05.489    test (DSHBTC,H1)        SymbolName(i,false) = EURNZD margin_1 = 0.0 
RG      0       09:26:05.489    test (DSHBTC,H1)        SymbolName(i,false) = EURJPY margin_1 = 0.0 
RH      0       09:26:05.489    test (DSHBTC,H1)        SymbolName(i,false) = EURGBP margin_1 = 0.0 
HS      0       09:26:05.489    test (DSHBTC,H1)        SymbolName(i,false) = EURCHF margin_1 = 0.0 
CD      0       09:26:05.489    test (DSHBTC,H1)        SymbolName(i,false) = EURCAD margin_1 = 0.0 
GO      0       09:26:05.489    test (DSHBTC,H1)        SymbolName(i,false) = EURAUD margin_1 = 0.0 
QP      0       09:26:05.489    test (DSHBTC,H1)        SymbolName(i,false) = CHFJPY margin_1 = 0.0 
JJ      0       09:26:05.489    test (DSHBTC,H1)        SymbolName(i,false) = CADJPY margin_1 = 0.0 
JL      0       09:26:05.489    test (DSHBTC,H1)        SymbolName(i,false) = CADCHF margin_1 = 0.0 
QF      0       09:26:05.489    test (DSHBTC,H1)        SymbolName(i,false) = AUDNZD margin_1 = 0.0 
NI      0       09:26:05.489    test (DSHBTC,H1)        SymbolName(i,false) = AUDJPY margin_1 = 0.0 
JS      0       09:26:05.489    test (DSHBTC,H1)        SymbolName(i,false) = AUDCHF margin_1 = 0.0 
EF      0       09:26:05.489    test (DSHBTC,H1)        SymbolName(i,false) = AUDCAD margin_1 = 0.0 

Toutes les croix montrent une marge=0 et AUCUNE CROIX MAJEURE n'a été sélectionnée.

Une fois encore, exécutez le script sur DSHBTC

LOG

HF      0       09:29:07.268    test (DSHBTC,H1)        price_1=SymbolInfoDouble(Symbol(),SYMBOL_ASK) = 0.07185999999999999
IQ      0       09:29:07.268    test (DSHBTC,H1)        price_1= 0.07185999999999999 margin_1= 0.0 OrderCalcMargin(ORDER_TYPE_BUY,_Symbol,0.1,price_1,margin_1) = true
KP      0       09:29:07.268    test (DSHBTC,H1)        price_1= 0.07185999999999999 margin_1= 0.0 MyOrderCalcMargin(ORDER_TYPE_BUY,_Symbol,0.1,price_1,margin_1) = true
DE      0       09:29:07.269    test (DSHBTC,H1)        price_1=SymbolInfoDouble(Symbol(),SYMBOL_BID) = 0.07087
OQ      0       09:29:07.269    test (DSHBTC,H1)        price_1= 0.07087 margin_1= 0.0 OrderCalcMargin(ORDER_TYPE_BUY,_Symbol,0.1,price_1,margin_1) = true
MQ      0       09:29:07.269    test (DSHBTC,H1)        price_1= 0.07087 margin_1= 0.0 MyOrderCalcMargin(ORDER_TYPE_BUY,_Symbol,0.1,price_1,margin_1) = true
QP      0       09:29:07.269    test (DSHBTC,H1)        price_1=10.0 = 10.0
HI      0       09:29:07.269    test (DSHBTC,H1)        price_1= 10.0 margin_1= 0.0 OrderCalcMargin(ORDER_TYPE_BUY,_Symbol,0.1,price_1,margin_1) = true
LK      0       09:29:07.269    test (DSHBTC,H1)        price_1= 10.0 margin_1= 0.0 MyOrderCalcMargin(ORDER_TYPE_BUY,_Symbol,0.1,price_1,margin_1) = true
MH      0       09:29:07.269    test (DSHBTC,H1)        price_1=1.0 = 1.0
HR      0       09:29:07.269    test (DSHBTC,H1)        price_1= 1.0 margin_1= 0.0 OrderCalcMargin(ORDER_TYPE_BUY,_Symbol,0.1,price_1,margin_1) = true
NP      0       09:29:07.269    test (DSHBTC,H1)        price_1= 1.0 margin_1= 0.0 MyOrderCalcMargin(ORDER_TYPE_BUY,_Symbol,0.1,price_1,margin_1) = true
GR      0       09:29:07.269    test (DSHBTC,H1)        SymbolInfoInteger(GBPUSD,SYMBOL_SELECT) = 1
FM      0       09:29:07.269    test (DSHBTC,H1)        SymbolInfoInteger(USDJPY,SYMBOL_SELECT) = 0
JG      0       09:29:07.269    test (DSHBTC,H1)        SymbolInfoInteger(USDCAD,SYMBOL_SELECT) = 1
DP      0       09:29:07.269    test (DSHBTC,H1)        SymbolInfoInteger(AUDUSD,SYMBOL_SELECT) = 1
DJ      0       09:29:07.269    test (DSHBTC,H1)        SymbolInfoInteger(NZDUSD,SYMBOL_SELECT) = 1
OE      0       09:29:07.269    test (DSHBTC,H1)        SymbolInfoInteger(USDCHF,SYMBOL_SELECT) = 1
FO      0       09:29:07.269    test (DSHBTC,H1)        SymbolInfoInteger(EURUSD,SYMBOL_SELECT) = 1
DD      0       09:29:07.269    test (DSHBTC,H1)        SymbolName(i,false) = DSHBTC margin_1 = 0.0 

Il n'y a pas de composantes majeures, mais l 'USDJPY est la seule.

Tous les tests ont été effectués sur MetaQuotes.


 
fxsaber:

Très probablement présent dans le Market Watch (à ne pas confondre avec la liste générale des symboles), mais non affiché.

Nous parlons en quelque sorte de la même chose mais de manière différente.


 
Alexey Viktorov:

Nous parlons en quelque sorte de la même chose de manière différente.

Exactement. Le Market Watch ne le montre pas, mais il est là.

 
Kirill Belousov:
for(int i=SymbolsTotal(false)-1;i>=0;i--)
Ajustez-le.
 
fxsaber:
Répare-le.

C'est fait !

P.S. J'ai oublié d'enlever la réserve :)

 

Jouer le bug

  1. Allez sur Metaquotes-Demo.
  2. Seul AUDJPY est dans l'aperçu du marché et ouvre son graphique.
  3. Rechargez le terminal et attendez une connexion complète - les devis arrivent.
  4. Exécuter le script sur le graphique

void OnStart()
{  
  for (int i = 0; i < 5; i++)
    Print(SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_VALUE));
}


Le résultat est le suivant

2017.10.05 09:02:27.460 Test6 (AUDJPY,M1)       0.0
2017.10.05 09:02:27.460 Test6 (AUDJPY,M1)       0.0
2017.10.05 09:02:27.460 Test6 (AUDJPY,M1)       0.0
2017.10.05 09:02:27.460 Test6 (AUDJPY,M1)       0.0
2017.10.05 09:02:27.460 Test6 (AUDJPY,M1)       0.0


Redémarrage.

2017.10.05 09:02:32.028 Test6 (AUDJPY,M1)       0.8868393047179851
2017.10.05 09:02:32.028 Test6 (AUDJPY,M1)       0.8868393047179851
2017.10.05 09:02:32.028 Test6 (AUDJPY,M1)       0.8868393047179851
2017.10.05 09:02:32.028 Test6 (AUDJPY,M1)       0.8868393047179851
2017.10.05 09:02:32.028 Test6 (AUDJPY,M1)       0.8868393047179851


C'est-à-dire queSYMBOL_TRADE_TICK_VALUE renvoie des zéros à la première exécution si Sleep() n'est pas utilisé ;


HI Au sujet du symbole invisible dans Market Watch. Si vous essayez d'ouvrir le graphique USDJPY (appuyez sur Entrée et entrez "USDJPY") avant le début du script, cela ne fonctionnera pas. Si après avoir exécuté le script, cela fonctionne. Bien que le Market Watch n'ait pas changé.

Raison: