Utilisation simultanée de conditions de trading

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

    Bonjour à tous

    J’ essaie une stratégie basée sur 5 conditions variables avec un compteur.

    1 Une moyenne mobile MM , si elle est croissante on augmente le compteur de +1 si décroissante : -1

    2 Si le close est > à MM on augmente le compteur : +1 s’ il est < à MM on diminue le compteur : -1

    3 Si Histogramme du MACD > 0 on augmente le compteur de 1 si il est < 0 on diminue le compteur : -1

    4 Si MACD[1] < MACD on augmente le compteur de +1 et si MACD[1] > MACD on diminue le compteur: -1

    5 Si MACDline > 0 on augmente le compteur de +1 et si MACDline < 0 on diminue le compteur: -1

    La variable “compteur” varie donc entre -5 et +5.

    Si le compteur est > = 3 alors trade long Si le compteur est < = -3 alors trade short.

    Si LONGONMARKET clôture de la position si le compteur est < 2

    Si SHORTONMARKET clôture de la position si le compteur est > -2

    Merci beaucoup à tous car je suis en échec pour coder cette stratégie.

    #265871 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Je l’ai créée avec l’IA (https://ai.prorealcode.com/it/), puis je l’ai légèrement modifiée et traduite :

    DEFPARAM CumulateOrders = false
    ONCE fastPeriod   = 12
    ONCE slowPeriod   = 26
    ONCE signalPeriod = 9
    ONCE maPeriod     = 20
    
    
    Sma20      = Average[maPeriod,0](close)
    macdHist   = MACD[fastPeriod, slowPeriod, signalPeriod](close)
    myMacdLine = MACDLine[fastPeriod, slowPeriod, signalPeriod](close)
    
    
    compteur = 0
    
    
    // Condition 1
    IF Sma20 > Sma20[1] THEN
    compteur = compteur + 1
    ELSIF Sma20 < Sma20[1] THEN
    compteur = compteur - 1
    ENDIF
    
    
    // Condition 2
    IF close > Sma20 THEN
    compteur = compteur + 1
    ELSIF close < Sma20 THEN
    compteur = compteur - 1
    ENDIF
    
    
    // Condition 3
    IF macdHist > 0 THEN
    compteur = compteur + 1
    ELSIF macdHist < 0 THEN
    compteur = compteur - 1
    ENDIF
    
    
    // Condition 4
    IF macdHist > macdHist[1] THEN
    compteur = compteur + 1
    ELSIF macdHist < macdHist[1] THEN
    compteur = compteur - 1
    ENDIF
    
    
    // Condition 5
    IF myMacdLine > 0 THEN
    compteur = compteur + 1
    ELSIF myMacdLine < 0 THEN
    compteur = compteur - 1
    ENDIF
    
    
    IF Not OnMarket THEN
    IF compteur >= 3 THEN
    BUY 1 CONTRACT AT MARKET
    ELSIF compteur <= -3 THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    ENDIF
    
    
    // ===== SEGNALI DI USCITA =====
    IF LONGONMARKET AND compteur < 2 THEN
    SELL AT MARKET
    ENDIF
    
    
    IF SHORTONMARKET AND compteur > -2 THEN
    EXITSHORT AT MARKET
    ENDIF
    
    
    SET STOP   %LOSS   1
    SET TARGET %PROFIT 2
    




    GraHal and Iván González thanked this post
Viewing 2 posts - 1 through 2 (of 2 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

Utilisation simultanée de conditions de trading


ProOrder : Trading Automatique & Backtests

New Reply
Author
author-avatar
4801 @4801 Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzirobertogozzi
15 hours, 11 minutes ago.

Topic Details
Forum: ProOrder : Trading Automatique & Backtests
Language: French
Started: 10/27/2026
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...