Avoir plusieurs conditions pour le rachat de ma position

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #179512 quote
    adrienv
    Participant
    New

    Bonjour,

    Je suis nouveau dans le forum et je débute en trading algo.

    j’ai un problème au niveau de la partie “//STOP ET RACHAT DE POSITION”, je n’arrive pas à faire en sorte que le programme respect les 3 conditions en même temps.

    C’est toujours l’une des trois qui fonctionne mais pas les autres ! Pouvez-vous m’aider ?

    Defparam cumulateorders = false
    
    // horaire de trading
    CtimeAchat = time >= 080000 and time <= 190000
    CtimeVente = time >= 080000 and time <= 190000
    
    
    // pivot journalier
    //cloture=DClose(1)
    //pivotJ=(DHigh(1) + DLow(1) + DClose(1))/3
    //if OpenDayOfWeek=1 then
    //pivotJ=(DHigh(2) + DLow(2) + DClose(2))/3
    //cloture=DClose(2)
    //endif
    
    // pivot 4H
    Int = (OpenTime[1] < 010000 AND OpenTime > 010000) OR (OpenTime[1] < 050000 AND OpenTime > 050000) OR (OpenTime[1] < 090000 AND OpenTime > 090000) OR (OpenTime[1] < 130000 AND OpenTime > 130000) OR (OpenTime[1] < 170000 AND OpenTime > 170000) OR (OpenTime[1] < 210000 AND OpenTime > 210000) OR (Openday <> Openday[1] AND DayOfWeek < DayOfWeek[1])
    IF (OpenTime Mod 40000 = 10000) OR Int THEN
    myLastHigh = myHigh
    myLastLow = myLow
    myLastClose = Close[1]
    myHigh = High
    myLow = Low
    ELSE
    myHigh = Max(myHigh, High)
    myLow = Min(myLow, Low)
    ENDIF
    
    // Calcul Points Pivots 4h
    PP = (myLastHigh + myLastLow + myLastClose) / 3
    
    
    // moyennes mobiles
    
    MM100 = ExponentialAverage[100](close)
    MM300 = ExponentialAverage[300](close)
    
    // vente
    
    Timeframe(1 minutes)
    StochK1mn=Stochastic[11,5](close)
    StochD1mn=Stochasticd[11,5,3](close)
    
    c1 = StochK1mn > 75 and StochK1mn crosses under StochD1mn
    c2 = MM100 < MM300
    c3 = (close < MM100 )
    
    IF c1 and c2 and c3 and CtimeVente and not onmarket THEN
    SELLSHORT 1 shares AT MARKET
    endif
    
    // STOP ET RACHAT DE LA POSITION 
    //condition 1 si le cours remonte de 12 c'est le stop loss
    set stop ploss 12
    
    //condition 2 deuxiémement, si le cours coupe la MM100 c'est le rachat
    if (close > MM100) then
    exitshort at market 
    endif
    
    // condition 3 pour finir, si la ligne K touche la borne 20 du stochastique alors c'est le rachat
    if StochK1mn = 20 then
    exitshort at market
    endif
    #179517 quote
    GraHal
    Participant
    Master

    Essayez ci-dessous à la place de votre ligne 44 ci-dessus.

    c1 = StochK1mn > 75 et StochK1mn < StochD1mn
    #179538 quote
    Nicolas
    Keymaster
    Legend

    La sortie de ta position SELLSHORT doit déjà opérer correctement avec les lignes 54 et 58, le stoploss est correctement placé et la condition vis à vis de la MM100 est correcte selon moi (sauf si tu as vendu déjà en dessous à vérifier).

    Par contre la valeur de la stochastique strictement égale à 20 a une chance infime de fonctionner, obtenir pile poile une valeur égale à 20 est une condition beaucoup trop stricte, à revoir avec un >= par exemple ?

    #179629 quote
    adrienv
    Participant
    New

    Merci beaucoup pour votre aide, c’est très gentil à vous !

    Je vais voir ce que j’arrive à faire de mon coté pour améliorer le programme.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Avoir plusieurs conditions pour le rachat de ma position


ProOrder : Trading Automatique & Backtests

New Reply
Author
author-avatar
adrienv @adrienv Participant
Summary

This topic contains 3 replies,
has 3 voices, and was last updated by adrienv
4 years, 11 months ago.

Topic Details
Forum: ProOrder : Trading Automatique & Backtests
Language: French
Started: 10/12/2021
Status: Active
Attachments: No files
Logo Logo
Loading...