Heikin Ashi et Volume

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #244512 quote
    charleddy
    Participant
    New

    Bonjour à tous,

    Je souhaite intégrer dans mon programme 2 éléments supplémentaires :

    J’utilise Heikin Ashi et je voudrais que l’entrée en position se fasse lorsque la bougie clôture au dessus d’une SMA.

    Et que les volumes soient supérieur à la SMA 7 mais qu’ils différencient les volumes haussiers ou baissiers. L’entrée en position acheteuse doit se faire uniquement si le volume est haussier et inversement.

    Est ce que vous pourriez m’aider ?

    Merci pour votre retour.

    Bon week-end.

    #244588 quote
    robertogozzi
    Moderator
    Master
    Le voilà :
    defparam preloadbars = 0
    ONCE N   = 7              //Periods
    // Bougies Heikin Ashi
    xOpen    = open
    xClose   = (open + close + high + low) / 4
    IF BarIndex > 0 THEN
    xOpen = (xOpen[1] + xClose[1]) / 2
    ENDIF
    // Calculer la SMA
    Sma      = average[N,0](xClose)
    // Calculer la SMA des volumes
    ONCE SmaVolL  = 0
    ONCE SmaVolS  = 0
    ONCE maVolL   = 0
    ONCE maVolS   = 0
    Bullish       = xClose > xOpen
    Bearish       = xClose < xOpen
    IF BarIndex > (N * 2) THEN
       IF Bullish THEN
          maVolL     = volume
          SmaVolL    = SmaVolL - maVolL[N] + maVolL
       ELSIF Bearish THEN
          maVolS     = volume
          SmaVolS    = SmaVolS - maVolS[N] + maVolS
       ENDIF
    ENDIF
    VolSmaL    = SmaVolL / N
    VolSmaS    = SmaVolS / N
    // Conditions d'entrée
    L1    = xClose > Sma
    S1    = xClose > Sma
    L2    = volume > VolSmaL
    S2    = volume > VolSmaS
    L3    = Not OnMarket
    S3    = Not OnMarket
    CondL = L1 AND L2 AND L3
    CondS = S1 AND S2 AND S3
    // Entrées sur le marché
    IF CondL THEN
       BUY 1 CONTRACT AT MARKET
    ELSIF CondS THEN
       SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    SET STOP   %LOSS   0.5
    SET TARGET %PROFIT 1
    //
    //graph SmaVolL AS "SmaVolL"  coloured("Blue")
    //graph maVolL  AS "maVolL"   coloured("Black")
    //graph VolSmaL AS "VolSmaL"  coloured("Cyan"
    //
    //graph SmaVolS AS "SmaVolS"  coloured("Red")
    //graph maVolS  AS "maVolS"   coloured("Black")
    //graph VolSmaS AS "VolSmaS"  coloured("Fuchsia")
    Iván González thanked this post
    #244597 quote
    charleddy
    Participant
    New
    Merci beaucoup…J’essaye ça et je vous redis…bonne journée
    #244754 quote
    charleddy
    Participant
    New
    Bonjour, J’ai essayé votre code mais cela ne fonctionne pas du tout…j’en suis désolé… Je reviens donc vers vous pour essayer de corriger mon code. Ce qui ne fonctionne pas : Il ne prend pas en compte les bougies Heikin Ashi mais les chandeliers Japonais, Et il ne différencie pas les volumes haussiers ou baissiers. Pourriez vous faire les modifications dans le programme ci-dessous. J’espère que vous pourrez m’aider. Merci.
    // Définition des paramètres du code
    DEFPARAM CumulateOrders = False // Cumul des positions désactivé
    // Annule tous les ordres en attente et ferme toutes les positions à 0:00, puis empêche toute création d'ordre avant l'heure "FLATBEFORE".
    DEFPARAM FLATBEFORE = 153000
    // Annule tous les ordres en attente et ferme toutes les positions à l'heure "FLATAFTER"
    DEFPARAM FLATAFTER = 220000
    
    // Empêche le système de placer de nouveaux ordres sur les jours de la semaine spécifiés
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
    
    // Conditions pour ouvrir une position acheteuse
    indicator1 = Average[5](high)
    c1 = (close >= indicator1)
    indicator2 = Volume
    indicator3 = Average[20](indicator2)
    c2 = (indicator2 >= indicator3)
    indicator4, ignored, ignored, indicator5, ignored, ignored, ignored = CALL "TDI 2"(close)
    c3 = (indicator4 >= indicator5)
    indicator6, ignored, ignored, ignored, ignored, ignored, ignored = CALL "TDI 2"(close)
    c4 = (indicator6 >= 50)
    
    IF (c1 AND c2 AND c3 AND c4) AND not daysForbiddenEntry THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions pour fermer une position acheteuse
    indicator7 = Average[5](low)
    c5 = (close <= indicator7)
    
    IF c5 THEN
    SELL AT MARKET
    ENDIF
    
    // Conditions pour ouvrir une position en vente à découvert
    indicator8 = Average[5](low)
    c6 = (close < indicator8)
    indicator9, ignored, ignored, indicator10, ignored, ignored, ignored = CALL "TDI 2"(close)
    c7 = (indicator9 <= indicator10)
    indicator11, ignored, ignored, ignored, ignored, ignored, ignored = CALL "TDI 2"(close)
    c8 = (indicator11 <= 50)
    indicator12 = Volume
    indicator13 = Average[20](indicator12)
    c9 = (indicator12 >= indicator13)
    
    IF (c6 AND c7 AND c8 AND c9) AND not daysForbiddenEntry THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions pour fermer une position en vente à découvert
    indicator14 = Average[5](high)
    c10 = (close >= indicator14)
    
    IF c10 THEN
    EXITSHORT AT MARKET
    ENDIF
    
    #244761 quote
    robertogozzi
    Moderator
    Master
    Désolé, mais ce que vous avez écrit n’est pas mon code. Si vous souhaitez utiliser ce que vous avez écrit, vous devez mettre, à la ligne 7, les instructions suivantes pour définir les bougies Heikin Ashi :
    once xOpen = open
    xClose     = (open + close + high + low) / 4
    if barindex > 0 then
        xOpen  = (xOpen[1] + xClose[1]) / 2
    endif
    xLow       = min(low,min(xClose,xOpen))
    xHigh      = max(high,max(xClose,xOpen))
    Après il faut remplacer :
    • Close avec xClose
    • Open avec xOpen
    • High avec xHigh
    • Low avec xLow
    #244776 quote
    charleddy
    Participant
    New
    Bonjour, Merci, j’ai essayé et cela fonctionne maintenant avec les bougies Heikin Ashi. Par contre, j’ai toujours le problème avec les volumes. Je vous joints une photo pour que vous compreniez ce qui ne fonctionne pas. Je souhaite que pour un achat, les volumes soit haussier et vis versa pour une vente. D’autre part, pensez vous qu’il serait possible d’ajouter deux fonctions :
    • Une pour fixer un BE à un nombre de points X
    • Et une pour couper une partie X des positions lorsqu’on a atteint un nombre de points X
    Je vous remercie vraiment pour votre aide. Bon week-end
    Capture-decran-2025-03-08-a-10.45.23.png Capture-decran-2025-03-08-a-10.45.23.png
    #244907 quote
    charleddy
    Participant
    New
    Bonjour, Je reviens vers vous car je ne sais pas si vous avez vu mon message. Je suis désolé de vous relancer mais j’aimerais avoir votre aide pour essayer de finaliser mon code. Merci d’avance pour votre retour. Bonne journée
    #244988 quote
    robertogozzi
    Moderator
    Master
    Essayez ceci :
    defparam preloadbars = 0
    ONCE N   = 7              //Periods
    // Bougies Heikin Ashi
    xOpen    = open
    xClose   = (open + close + high + low) / 4
    IF BarIndex > 0 THEN
    xOpen = (xOpen[1] + xClose[1]) / 2
    ENDIF
    // Calculer la SMA
    Sma      = average[N,0](xClose)
    // Calculer la SMA des volumes
    ONCE SmaVolL  = 0
    ONCE SmaVolS  = 0
    ONCE maVolL   = 0
    ONCE maVolS   = 0
    Bullish       = xClose > xOpen
    Bearish       = xClose < xOpen
    IF BarIndex > (N * 2) THEN
    IF Bullish THEN
    maVolL     = volume
    SmaVolL    = SmaVolL - maVolL[N] + maVolL
    ELSIF Bearish THEN
    maVolS     = volume
    SmaVolS    = SmaVolS - maVolS[N] + maVolS
    ENDIF
    ENDIF
    VolSmaL    = SmaVolL / N
    VolSmaS    = SmaVolS / N
    // Conditions d'entrée
    L1    = xClose > Sma
    S1    = xClose > Sma
    L2    = volume > VolSmaL
    S2    = volume > VolSmaS
    L3    = Not OnMarket
    S3    = Not OnMarket
    L4    = Bullish
    S4    = Bearish
    CondL = L1 AND L2 AND L3 AND L4
    CondS = S1 AND S2 AND S3 AND S4
    // Entrées sur le marché
    IF CondL THEN
    BUY 1 CONTRACT AT MARKET
    ELSIF CondS THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    SET STOP   %LOSS   0.5
    SET TARGET %PROFIT 1
    //
    //graph SmaVolL AS "SmaVolL"  coloured("Blue")
    //graph maVolL  AS "maVolL"   coloured("Black")
    //graph VolSmaL AS "VolSmaL"  coloured("Cyan"
    //
    //graph SmaVolS AS "SmaVolS"  coloured("Red")
    //graph maVolS  AS "maVolS"   coloured("Black")
    //graph VolSmaS AS "VolSmaS"  coloured("Fuchsia")
    //graph Bullish
    //graph Bearish coloured("Red")
    L’indicateur VOLUME de la plateforme colore l’histogramme en fonction des bougies japonais réguliers. Si vous souhaitez avoir le volume basé sur les bougies HA, vous devez utiliser cet indicateur :
    // Bougies Heikin Ashi
    xOpen    = open
    xClose   = (open + close + high + low) / 4
    IF BarIndex > 0 THEN
    xOpen = (xOpen[1] + xClose[1]) / 2
    ENDIF
    //,volume HA candles
    Bullish = xClose > xOpen
    Bearish = xClose < xOpen
    r       = 0
    g       = 205
    b       = 0
    IF Bearish THEN
    r = 205
    g = 92
    b = 92
    ENDIF
    RETURN Volume style(histogram) coloured(r,g,b,255) AS "Volume"
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.

Heikin Ashi et Volume


ProOrder : Trading Automatique & Backtests

New Reply
Author
author-avatar
charleddy @charleddy Participant
Summary

This topic contains 7 replies,
has 2 voices, and was last updated by robertogozzi
11 months, 3 weeks ago.

Topic Details
Forum: ProOrder : Trading Automatique & Backtests
Language: French
Started: 03/01/2025
Status: Active
Attachments: 1 files
Logo Logo
Loading...