Condition temporelle : délai entre deux positions

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #42121 quote
    Faabiien
    Participant
    Junior

    Bonjour à tous,

    Je suis bloqué sur une “condition temporelle”.

    Mon code est simple:

    Je prends position dès que le cours croise à la hausse les 1500.

    Avant de prendre une nouvelle position, je souhaiterais vérifier que le dernier croisement à la hausse des 1500 a eu lieu il y a au moins 1h.

    Sauriez-vous comment faire?

    // Définition des paramètres du code
    DEFPARAM CumulateOrders = False // Cumul des positions désactivé
    
    // Conditions pour ouvrir une position acheteuse
    c1 = (close CROSSES OVER 1500)
    
    IF c1 AND Heure - HeureCroisement > 1h THEN
    HeureCroisement = TIME
    BUY 1 CONTRACT AT MARKET
    ENDIF
    #42730 quote
    Faabiien
    Participant
    Junior

    Bonjour à tous,

    Pour info, après recherche, il n’existe pas de fonction clef en main.

    Mais il est tout à fait possible de s’en sortir avec MINUTE et HOUR.

    J’ai réfléchi à 2 moyens d’y arriver:

    1 – Soustraction d’heures

    ONCE HeureDernierePosition = 010000
     
    // Conditions pour ouvrir une position acheteuse
    c1 = (close CROSSES OVER 1500)
     
    IF c1 AND HeureDernierePosition - TIME[1] > 1 THEN
    BUY 1 CONTRACT AT MARKET
    HeureDernierePosition = TIME[1]
    ENDIF

    2 – Décomposition Heure/Minute

    ONCE HeureDernierePosition = 0
    ONCE MinuteDernierePosition = 0
     
    // Conditions pour ouvrir une position acheteuse
    c1 = (close CROSSES OVER 1500)
     
    IF c1 AND HEURE[1] - HeureDernierePosition > 1 THEN
    BUY 1 CONTRACT AT MARKET
    ELSIF c1 AND HeureDernierePosition = HOUR AND MinuteDernierePosition - MINUTE > 30 THEN
    BUY 1 CONTRACT AT MARKET
    ELSIF HEURE[1] = HeureDernierePosition +1 AND 60 - MinuteDernierePosition + MINUTE > 60 THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    IF c1 AND HeureDernierePosition - TIME[1] > 1 THEN
    BUY 1 CONTRACT AT MARKET
    HeureDernierePosition = TIME[1]
    ENDIF
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Condition temporelle : délai entre deux positions


ProOrder : Trading Automatique & Backtests

New Reply
Author
author-avatar
Faabiien @faabiien Participant
Summary

This topic contains 1 reply,
has 1 voice, and was last updated by Faabiien
8 years, 7 months ago.

Topic Details
Forum: ProOrder : Trading Automatique & Backtests
Language: French
Started: 07/31/2017
Status: Active
Attachments: No files
Logo Logo
Loading...