Forums › ProRealTime forum Français › Support ProOrder › Remplacement de la fonction zigzag dans mon système de trading › Reply To: Remplacement de la fonction zigzag dans mon système de trading
01/13/2025 at 7:49 PM
#242514
Adaptative ZigZag
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
DEFPARAM DRAWONLASTBARONLY=TRUE MaxSegments2show=max(0,Segments2show-2) //points top/low back to store // initialisation once LastZigZag = 1 once ZigZagIndex = 0 once $ZigZagX[ZigZagIndex]=barindex once $ZigZagY[ZigZagIndex]=High // Variation de prix en fonction de l'ATD et de la déviation standart DeltaY=max(7,(AverageTrueRange[period](close)+STD[period](close))*facteur) // Vague haussière en cours if LastZigZag=1 then if High>$ZigZagY[ZigZagIndex] then $ZigZagY[ZigZagIndex]=High $ZigZagX[ZigZagIndex]=barindex elsif Low<=($ZigZagY[ZigZagIndex]-DeltaY) then // New ZigZag, changement de vague ZigZagIndex=ZigZagIndex+1 $ZigZagY[ZigZagIndex]=Low $ZigZagX[ZigZagIndex]=barindex LastZigZag=-1 endif endif // Vague baissière en cours if LastZigZag=-1 then //lastpoint was a low if Low<$ZigZagY[ZigZagIndex] then $ZigZagY[ZigZagIndex]=low $ZigZagX[ZigZagIndex]=barindex elsif High>=($ZigZagY[ZigZagIndex]+DeltaY) then // New ZigZag, changement de vague ZigZagIndex=ZigZagIndex+1 $ZigZagY[ZigZagIndex]=High $ZigZagX[ZigZagIndex]=barindex LastZigZag=1 endif endif FirstSegment=max(1,ZigZagIndex-MaxSegments2show) // Zigzag Drawing If LastZigZag=1 then drawsegment (barindex,Low,$ZigZagX[ZigZagIndex],$ZigZagY[ZigZagIndex]) style(dottedline,2) COLOURED ("tomato",200) //segment in progress If ZigZagIndex>1 then For i= ZigZagIndex downto FirstSegment do If $ZigZagY[i]>$ZigZagY[i-1] then drawsegment($ZigZagX[i],$ZigZagY[i],$ZigZagX[i-1],$ZigZagY[i-1]) style(line,2) COLOURED("dodgerblue",200) Else drawsegment($ZigZagX[i],$ZigZagY[i],$ZigZagX[i-1],$ZigZagY[i-1]) style(line,2) COLOURED("tomato",200) Endif Next Endif Endif If LastZigZag=-1 then drawsegment (barindex,High,$ZigZagX[ZigZagIndex],$ZigZagY[ZigZagIndex]) style (dottedline,2) COLOURED ("dodgerblue",200) //segment in progress If ZigZagIndex>1 then For i= ZigZagIndex downto FirstSegment do If $ZigZagY[i]>$ZigZagY[i-1] then drawsegment($ZigZagX[i],$ZigZagY[i],$ZigZagX[i-1],$ZigZagY[i-1]) style(line,2) COLOURED("dodgerblue",200) Else drawsegment($ZigZagX[i],$ZigZagY[i],$ZigZagX[i-1],$ZigZagY[i-1]) style(line,2) COLOURED("tomato",200) Endif Next Endif Endif return |