Code de clôture des ordres contre FIFO
Résultats de 1 é 10 sur 10

Sujet : Code de clôture des ordres contre FIFO

  1. #1
    D'accord, voici l'affaire. J'ai un bloc de commandes que j'aimerais clôturer en une seule fois en utilisant une clôture générale afin de respecter le FIFO.

    Vous trouverez ci-dessous deux scénarios qui, je le sais, fermeront un bloc de commandes une fois, mais est-ce que quelqu'un sait si l'un ou l'autre les fermera selon FIFO ou non ?

    PHP Code: <code><span style=”color: #000000”> <span style=”color: #0000BB”></span><span style=”color: #007700”>for(</span><span style=”color: #0000BB”>inti</span><span style=”color: #007700”>=</span><span style=”color: #0000BB”>OrdersTotal</span><span style=”color: #007700”>()-</span><span style=”color: #0000BB”>1</span><span style=”color: #007700”>;</span><span style=”color: #0000BB”>i</span><span style=”color: #007700”>gt;=</span><span style=”color: #0000BB”>0</span><span style=”color: #007700”>;</span><span style=”color: #0000BB”>i</span><span style=”color: #007700”>--)
    {
    </span><span style=”color: #0000BB”>OrderSelect</span><span style=”color: #007700”>(</span><span style=”color: #0000BB”>i</span><span style=”color: #007700”>,</span><span style=”color: #0000BB”>SELECT_BY_POS</span><span style=”color: #007700”>,</span><span style=”color: #0000BB”>MODE_TRADES</span><span style=”color: #007700”>);
    if(</span><span style=”color: #0000BB”>OrderSymbol</span><span style=”color: #007700”>()!=</span><span style=”color: #0000BB”>Symbol</span><span style=”color: #007700”>()||</span><span style=”color: #0000BB”>OrderMagicNumber</span><span style=”color: #007700”>()!=</span><span style=”color: #0000BB”>magic</span><span style=”color: #007700”>||</span><span style=”color: #0000BB”>cmd</span><span style=”color: #007700”>()gt;</span><span style=”color: #0000BB”>1</span><span style=”color: #007700”>)continue;
    </span><span style=”color: #0000BB”>OrderClose</span><span style=”color: #007700”>(</span><span style=”color: #0000BB”>OrderTicket</span><span style=”color: #007700”>(),</span><span style=”color: #0000BB”>OrderLots</span><span style=”color: #007700”>(),</span><span style=”color: #0000BB”>OrderClosePrice</span><span style=”color: #007700”>(),</span><span style=”color: #0000BB”>3</span><span style=”color: #007700”>,</span><span style=”color: #0000BB”>CLR_NONE</span><span style=”color: #007700”>);
    }
    </span><span style=”color: #0000BB”></span> </span> </code> PHP Code: <code><span style=”color: #000000”> <span style=”color: #0000BB”></span><span style=”color: #007700”>for(</span><span style=”color: #0000BB”>inti</span><span style=”color: #007700”>=</span><span style=”color: #0000BB”>0</span><span style=”color: #007700”>;</span><span style=”color: #0000BB”>i</span><span style=”color: #007700”>lt;=</span><span style=”color: #0000BB”>OrdersTotal</span><span style=”color: #007700”>();</span><span style=”color: #0000BB”>i</span><span style=”color: #007700”> )
    {
    </span><span style=”color: #0000BB”>OrderSelect</span><span style=”color: #007700”>(</span><span style=”color: #0000BB”>i</span><span style=”color: #007700”>,</span><span style=”color: #0000BB”>SELECT_BY_POS</span><span style=”color: #007700”>,</span><span style=”color: #0000BB”>MODE_TRADES</span><span style=”color: #007700”>);
    if(</span><span style=”color: #0000BB”>OrderSymbol</span><span style=”color: #007700”>()!=</span><span style=”color: #0000BB”>Symbol</span><span style=”color: #007700”>()||</span><span style=”color: #0000BB”>OrderMagicNumber</span><span style=”color: #007700”>()!=</span><span style=”color: #0000BB”>magic</span><span style=”color: #007700”>||</span><span style=”color: #0000BB”>cmd</span><span style=”color: #007700”>()gt;</span><span style=”color: #0000BB”>1</span><span style=”color: #007700”>)continue;
    </span><span style=”color: #0000BB”>OrderClose</span><span style=”color: #007700”>(</span><span style=”color: #0000BB”>OrderTicket</span><span style=”color: #007700”>(),</span><span style=”color: #0000BB”>OrderLots</span><span style=”color: #007700”>(),</span><span style=”color: #0000BB”>OrderClosePrice</span><span style=”color: #007700”>(),</span><span style=”color: #0000BB”>3</span><span style=”color: #007700”>,</span><span style=”color: #0000BB”>CLR_NONE</span><span style=”color: #007700”>);
    }
    </span><span style=”color: #0000BB”></span> </span> </code> Currently I'm using the first scenario for closing out the orders, however, when I check the results tab while backtesting, it shows the last orders are being closing first so, I guess this won't work the way it is. I haven't checked the second scenario yet, so I don't know? Nor do I normally use it this way (mostly for sorting and tagging).

    Quoi qu'il en soit, j'ai besoin de savoir quelle est la meilleure solution (ou réalisable) pour faire cela?

    Des idées?


    Merci!

  2. #2
    With respect to the code above, this is where I opted to put it (in a similar configuration). Thus far I haven't encountered any problems, so I assume it is correct. PHP Code: <code><span style=”color: #000000”> <span style=”color: #0000BB”></span><span style=”color: #007700”>if(</span><span style=”color: #0000BB”>close_2</span><span style=”color: #007700”>)
    {
    for(</span><span style=”color: #0000BB”>i</span><span style=”color: #007700”>=</span><span style=”color: #0000BB”>OrdersTotal</span><span style=”color: #007700”>()-</span><span style=”color: #0000BB”>1</span><span style=”color: #007700”>;</span><span style=”color: #0000BB”>i</span><span style=”color: #007700”>gt;=</span><span style=”color: #0000BB”>0</span><span style=”color: #007700”>;</span><span style=”color: #0000BB”>i</span><span style=”color: #007700”>--)
    {
    </span><span style=”color: #0000BB”>OrderSelect</span><span style=”color: #007700”>(</span><span style=”color: #0000BB”>i</span><span style=”color: #007700”>,</span><span style=”color: #0000BB”>SELECT_BY_POS</span><span style=”color: #007700”>,</span><span style=”color: #0000BB”>MODE_TRADES</span><span style=”color: #007700”>);
    if(</span><span style=”color: #0000BB”>OrderSymbol</span><span style=”color: #007700”>()!=</span><span style=”color: #0000BB”>Symbol</span><span style=”color: #007700”>()||</span><span style=”color: #0000BB”>OrderMagicNumber</span><span style=”color: #007700”>()!=</span><span style=”color: #0000BB”>magic</span><span style=”color: #007700”>||</span><span style=”color: #0000BB”>cmd</span><span style=”color: #007700”>()gt;</span><span style=”color: #0000BB”>1</span><span style=”color: #007700”>)continue;
    while(</span><span style=”color: #0000BB”>IsTradeContextBusy</span><span style=”color: #007700”>()){</span><span style=”color: #0000BB”>Sleep</span><span style=”color: #007700”>(</span><span style=”color: #0000BB”>100</span><span style=”color: #007700”>);}</span><span style=”color: #0000BB”>RefreshRates</span><span style=”color: #007700”>();
    if(</span><span style=”color: #0000BB”>OOT</span><span style=”color: #007700”>()==</span><span style=”color: #0000BB”>FOOT</span><span style=”color: #007700”>){</span><span style=”color: #0000BB”>OrderClose</span><span style=”color: #007700”>(</span><span style=”color: #0000BB”>OrderTicket</span><span style=”color: #007700”>(),</span><span style=”color: #0000BB”>OrderLots</span><span style=”color: #007700”>(),</span><span style=”color: #0000BB”>OrderClosePrice</span><span style=”color: #007700”>(),</span><span style=”color: #0000BB”>3</span><span style=”color: #007700”>,</span><span style=”color: #0000BB”>CLR_NONE</span><span style=”color: #007700”>);
    </span><span style=”color: #0000BB”>closeall</span><span style=”color: #007700”>=</span><span style=”color: #0000BB”>true</span><span style=”color: #007700”>;break;}
    }
    }
    </span><span style=”color: #0000BB”></span> </span> </code>

  3. #3

    Citation Envoy? par ;
    ne pas oublier de traiter les sujets chargés du contexte commercial...
    Hé, si je place le code suivant juste avant OrderSend() ou, dans le cas ci-dessus, OrderClose(), c'est là qu'il doit être placé, n'est-ce pas ? Code PHP : <code><span style=”color : #000000”> <span style=”color : #0000BB”></span><span style=”color : #007700”>tandis que(</span>< span style=”color: #0000BB”>IsTradeContextBusy</span><span style=”color: #007700”>())</span><span style=”color: #0000BB”>Sommeil</span>< span style=”color: #007700”>(</span><span style=”color: #0000BB”>100</span><span style=”color: #007700”>);
    </span><span style=”color: #0000BB”>Taux de rafraîchissement</span><span style=”color: #007700”>();
    </span><span style=”color: #0000BB”></span> </span> </code> Je fais déjà cela avec OrderSend() depuis un certain temps maintenant, et jusqu'à présent il n'a pas interféré avec mon commerce. J'ai donc supposé que c'était le bon endroit pour le mettre. Cependant, je ne l'ai pas fait avec la fonction OrderClose(), qui est encore plus susceptible d'être encombrée en cas de problème, surtout si j'utilise plusieurs graphiques. Alors oui, ce serait bien de savoir si je le faisais correctement. Merci!

  4. #4
    Oui, je suis d'accord, une coche suffit. De plus, chaque fois que je dois trier pour la première commande, j'utilise toujours OrderOpenTime(), ce que j'ai fait avec le code ci-dessus. Je pensais juste qu'il y avait peut-être un moyen simple de le spécifier sans créer de boucle supplémentaire ... et, bien sûr, d'essayer de le comprendre. Si je n'avais pas utilisé l'instruction while, que j'utilise rarement, je n'aurais probablement pas pensé à ce que je devais faire. J'ai aussi un compte IBFX, donc cela m'a rarement concerné aussi. C'est juste que je suis en train de créer une EA pour quelqu'un d'autre et qu'il envisage de faire appel à un autre courtier.

  5. #5

    Citation Envoy? par ;
    Oui, je peux le faire, mais combien de cycles (ou ticks) faudra-t-il pour que cela se produise ?.
    hey ec ...... une coche devrait suffire si elle est correctement codée ... et n'oubliez pas que le numéro de ticket le plus bas ne garantit pas qu'il s'agit de la commande la plus ancienne ..... vous devez sélectionner par orderopentime () seulement ....../---/--- j'utilise ibfx donc fifo ne me concerne pas du tout ..... mes commandes vont et viennent sans respect de l'heure à laquelle elles ont été passées ... ... c'est un avantage énorme même si peu le voient.....h

  6. #6
    n'oubliez pas de traiter les problèmes liés au contexte commercial, mais pourquoi ne pas simplement faire quelque chose comme ça... Code inséré function FIFOCloseAll(int magicnum, int slippagepoints) { int i, lowerticket; double pc ; booléen répéter ; répéter = vrai ; tandis que (répéter) { répéter = faux ; billet le plus bas = -1 ; i = TotalCommandes()-1 ; while(i gt;= 0) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if ((OrderSymbol() == Symbol()) (OrderMagicNumber() == magicnum) ((OrderType() == OP_BUY) || (OrderType() == OP_SELL))) { répéter = vrai ;/force une réitération pour vérifier à nouveau un autre nombre le plus bas au prochain cycle si (lowestticket lt; 0) lowerticket = OrderTicket(); if (OrderTicket() lt; ticket le plus bas) ticket le plus bas = OrderTicket(); } je--; } if (ticket le plus bas gt; -1) { OrderSelect(ticket le plus bas, SELECT_BY_TICKET, MODE_TRADES); cp = offre ; if (OrderType() == OP_SELL) cp = Ask ; OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(cp, Digits), NormalizeDouble(Point * slippagepoints, Digits), Orange); } } }

  7. #7
    Existe-t-il un moyen de dire à la boucle de se répéter jusqu'à ce que toutes les commandes soient fermées, en fonction de OrderOpenTime() ? Ça, je pense. serait idéal. Code PHP : <code><span style=”color : #000000”> <span style=”color : #0000BB”></span><span style=”color : #007700”>for(</span>< span style=”color: #0000BB”>inti</span><span style=”color: #007700”>=</span><span style=”color: #0000BB”>Total des commandes</span><span style =”color: #007700”>()-</span><span style=”color: #0000BB”>1</span><span style=”color: #007700”>;</span><span style =”color: #0000BB”>i</span><span style=”color: #007700”>gt;=</span><span style=”color: #0000BB”>0</span><span style =”color: #007700”>;</span><span style=”color: #0000BB”>i</span><span style=”color: #007700”>--;</span><span style =”color: #0000BB”>T</span><span style=”color: #007700”>gt;</span><span style=”color: #0000BB”>0</span><span style= ”color : #007700”>)
    {
    </span><span style=”color: #0000BB”>OrderSelect</span><span style=”color: #007700”>(<span><span style=”color: #0000BB”>i</span><span style=”color: #007700”>,</span><span style=”color: #0000BB”>SELECT_BY_POS</span ><span style=”color: #007700”>,</span><span style=”color: #0000BB”>MODE_TRADES</span><span style=”color: #007700”>);
    if(</span><span style=”color: #0000BB”>OrderSymbol</span><span style=”color: #007700”>()!=</span><span style=”color: #0000BB ”>Symbole</span><span style=”color: #007700”>()||</span><span style=”color: #0000BB”>NuméroMagiqueCommande</span><span style=”color: # 007700”>()!=</span><span style=”color: #0000BB”>magique</span><span style=”color: #007700”>||</span><span style=”color : #0000BB”>cmd</span><span style=”color: #007700”>()gt;</span><span style=”color: #0000BB”>1</span><span style=” color : #007700 »>)continuer ;
    </span><span style=”color: #0000BB»>CommanderFermer</span><span style=”color: #007700»>(</span>< span style=”color: #0000BB”>Billet de commande</span><span style=”color: #007700”>(),</span><span style=”color: #0000BB”>Lots de commande</span>< span style=”color : #007700”>(),</span><span style=”color: #0000BB”>Prix de clôture de la commande</span><span style=”color: #007700”>(),</span ><span style=”color: #0000BB”>3</span><span style=”color: #007700”>,</span><span style=”color: #0000BB”>CLR_NONE</span>< span style=”color : #007700”>);
    }
    </span><span style=”color : #0000BB”></span> </span> </code> Ou, peut-être que je pourrais faire quelque chose comme ça : où T est égal au nombre de commandes ouvertes ? et éventuellement créer une deuxième boucle dans la première boucle afin de déterminer quelle est la commande la plus ancienne, et la trouver et la supprimer une fois qu'elle est taguée ou identifiée. Hé, cela semble presque plausible ... ou, du moins, ça vaut le coup.

  8. #8
    hey ec ..... si pour une raison quelconque vous souhaitez fermer les commandes en ce qui concerne fifo, sélectionnez par orderopentime () ...... h

  9. #9
    Oui, je peux le faire, mais combien de cycles (ou ticks) faudra-t-il pour que cela se produise ? D'après ce que j'ai compris, il ne trie les commandes qu'une seule fois, donc, si ce n'est pas dans l'ordre chronologique la première fois, il doit attendre le prochain cycle (ou tick) pour passer la commande suivante. Ou, je suppose que vous pourriez créer toute une série de boucles comme celle-ci, l'une après l'autre, mais cela semble terriblement redondant, surtout si vous avez beaucoup de commandes.

  10. #10
    Si j'ai besoin de supprimer LIFO, le i=OrdersTotal()-1; igt;=0; i-- fonctionne, et si vous voulez l'autre, juste tandis que OrdersTotal() gt; 0 supprimer à la position 0

Régles des messages

  • Vous ne pouvez pas cr?er de sujets
  • Vous ne pouvez pas r?pondre aux sujets
  • Vous ne pouvez pas importer de fichiers joints
  • Vous ne pouvez pas ?diter vos messages
  •  
  • Les BB codes sont Activés
  • Les Smileys sont Activés
  • Le BB code [IMG] est Activé
  • Le code [VIDEO] est Désactivé
  • Le code HTML est Désactivé
Le site d'sundytrading utilise des cookies
Le site d'sundytrading utilise des cookies pour vous assurer la meilleure expérience sur notre site ; certains sont déjà effectifs. Vous pouvez consulter plus de détails sur leurs usages ici. Veuillez cliquer sur le bouton à droite pour accepter nos cookies. Si vous continuez à utiliser le site internet d???sundytrading, nous considérerons que vous acceptez nos cookies.