detection swing

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #247718 quote
    slimanbslimanb
    Participant
    New

    // — Déclaration des variables d’entrée (Inputs) —
    // Ces variables seront modifiables via l’interface ProRealTime
    input LookbackLeft = 5 // Nombre de bougies à gauche à comparer (X)
    input LookbackRight = 5 // Nombre de bougies à droite à comparer (Y)

    // — Définition des Swing Highs et Swing Lows —

    // Swing High (SH): Le plus haut de la bougie actuelle est le plus haut des ‘LookbackLeft’ bougies précédentes
    // ET le plus haut des ‘LookbackRight’ bougies suivantes.
    // Nous utilisons des bougies décalées pour les bougies “suivantes” pour une logique de backtesting.
    // high[LookbackRight] : plus haut de la bougie LookbackRight périodes DANS LE FUTUR par rapport à la bougie actuelle.
    // high[0] : plus haut de la bougie actuelle.
    // high[1] : plus haut de la bougie précédente.

    // Pour la détection d’un Swing High *passé*, on regarde si la bougie à l’indice ‘i’
    // est la plus haute dans une fenêtre définie.

    SwingHighDetected = 1 // Initialisation à VRAI. Deviendra FAUX si la condition n’est pas remplie.
    FOR i = 1 TO LookbackLeft
    IF high[0] <= high[i] THEN
    SwingHighDetected = 0 // Si une bougie précédente est plus haute ou égale, ce n'est pas un SH
    BREAK
    ENDIF
    NEXT

    IF SwingHighDetected THEN
    FOR i = 1 TO LookbackRight
    IF high[0] = low[i] THEN
    SwingLowDetected = 0 // Si une bougie précédente est plus basse ou égale, ce n’est pas un SL
    BREAK
    ENDIF
    NEXT

    IF SwingLowDetected THEN
    FOR i = 1 TO LookbackRight
    IF low[0] >= low[-i] THEN // -i pour les bougies *futures*
    SwingLowDetected = 0 // Si une bougie future est plus basse ou égale, ce n’est pas un SL
    BREAK
    ENDIF
    NEXT
    ENDIF

    // — Affichage sur le graphique —

    // Dessiner des marqueurs aux points de Swing High et Swing Low
    IF SwingHighDetected THEN
    // Dessine un petit carré rouge au-dessus de la bougie du Swing High
    DRAWSHAPE (high + 0.0005) AS “Square” AT BARINDEX COLOUR (255,0,0) // Rouge
    ENDIF

    IF SwingLowDetected THEN
    // Dessine un petit carré vert en dessous de la bougie du Swing Low
    DRAWSHAPE (low – 0.0005) AS “Square” AT BARINDEX COLOUR (0,255,0) // Vert
    ENDIF

    // Vous pouvez également ajouter des labels pour voir les valeurs
    // DRAWTEXT (“SH”) AT BARINDEX ON SwingHighDetected
    // DRAWTEXT (“SL”) AT BARINDEX ON SwingLowDetected

    #247789 quote
    Iván GonzálezIván González
    Moderator
    Legend
    LookbackLeft = 5 
    LookbackRight = 5
    // pivot low
    pl1=low>low[lookbackright]
    pl2=low[lookbackright]<=lowest[lookbackright](low)
    pl3=low[lookbackright]<lowest[LookbackLeft](low)[LookbackRight+1]
    
    if pl1 and pl2 and pl3 then
    drawpoint(barindex[lookbackright],low[lookbackright],3)coloured("red")
    endif
    
    // pivot high
    ph1=high<high[lookbackright]
    ph2=high[lookbackright]>=highest[lookbackright](high)
    ph3=high[lookbackright]>highest[LookbackLeft](high)[LookbackRight+1]
    
    if ph1 and ph2 and ph3 then
    drawpoint(barindex[lookbackright],high[lookbackright],3)coloured("blue")
    endif
    
    return
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

detection swing


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
author-avatar
slimanb @slimanb Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by Iván GonzálezIván González
1 year, 3 months ago.

Topic Details
Forum: ProBuilder : Indicateurs & Outils Personnalisés
Language: French
Started: 05/29/2025
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...