condition plus haut bas

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #239127 quote
    PRC_2021PRC_2021
    Participant
    Average

    Bonjour,

    Suite au code de Nicolas ci dessous, j’aimerai “isoler” le second point afin d’ajouter une condition de Volume par exemple.

    J’ai bien identifié ce second point ($topx[y],$topy[y]) mais je n’arrive pas a rajouter la condition.

    Merci pour votre aide.

    // https://www.prorealcode.com/topic/array-variables-availability-in-prorealtime/
    // (please do not remove the link above for future reference)
    // Example #6: flat base triangle or double top/bottom
    defparam drawonlastbaronly=true
    
    // --- settings
    fractalP = 10 //fractal period
    percent = 0.05 //maximum percent change between the 2 points
    barlimit = 100 //maximum bars between 2 points
    showTriangle = 1 //show the triangle between the 2 points (1=yes,0=no)
    // --- end of settings
    
    //fractals
    cp=fractalP
    if high[cp] >= highest[(cp)*2+1](high) then //new fractal high found
     $TOPy[lastset($TOPy)+1] = high[cp] //store fractal value
     $TOPx[lastset($TOPx)+1] = barindex[cp] //store fractal barindex
    endif
    
    if low[cp] <= lowest[(cp)*2+1](low)  then //new fractal low found
     $BOTy[lastset($BOTy)+1] = low[cp] //store fractal value
     $BOTx[lastset($BOTx)+1] = barindex[cp] //stire fractal barindex
    endif
    
    if(islastbarupdate and isset($topy[0]) and isset($boty[0])) then
     //check points in a range of X percent
     for i = 0 to lastset($TOPy) do //loop through the tops
      for y = 0 to lastset($TOPy) do //check first top with other tops
       change=abs(($topy[y]-$topy[i])/$topy[i]) //percent range between the 2 tops
       bardiff=abs($TOPx[i]-$TOPx[y]) //how many bars between the 2 points?
       if change<=percent/100 and bardiff<barlimit and bardiff>=fractalP and $topx[i]<>$topx[y] then
        //plot points at each top
        DRAWPOINT($topx[i],$topy[i],5) COLOURED (0,255,0,25) BORDERCOLOR (0,200,0) 
        DRAWPOINT($topx[y],$topy[y],5) COLOURED (0,255,0,25) BORDERCOLOR (0,200,0)
        //plot the flat base
        drawsegment($topx[i],$topy[i],$topx[y],$topy[y]) style(dottedline,2)
        if(showTriangle) then 
         //find the lowest point between the 2 tops 
         ll = lowest[bardiff](low)[barindex-max($topx[i],$topx[y])]
         //plot the triangle 
         drawtriangle($topx[i],$topy[i],$topx[y],$topy[y],max($topx[i],$topx[y])-bardiff/2,ll) COLOURED (0,255,0,20) BORDERCOLOR (0,200,0,0)
        endif
       endif
      next
     next
     for i = 0 to lastset($BOTy) do //loop through the bottoms
      for y = 0 to lastset($BOTy) do //check first bottom with other bottoms
       change=abs(($boty[y]-$boty[i])/$boty[i]) //percent range between the 2 bottoms
       bardiff=abs($botx[i]-$botx[y]) //how many bars between the 2 points?
       if change<=percent/100 and bardiff<barlimit and bardiff>=fractalP and $BOTx[i]<>$BOTx[y] then
        //plot points at each bottom
        DRAWPOINT($botx[i],$boty[i],5) COLOURED (255,0,0,25) BORDERCOLOR (200,0,0)
        DRAWPOINT($botx[y],$boty[y],5) COLOURED (255,0,0,25) BORDERCOLOR (200,0,0)
        //plot the flat base
        drawsegment($botx[i],$boty[i],$botx[y],$boty[y]) style(dottedline,2)
        if(showTriangle) then
         //find the lowest point between the 2 tops
         hh = highest[bardiff](high)[barindex-max($botx[i],$botx[y])]
         //plot the triangle
         drawtriangle($botx[i],$boty[i],$botx[y],$boty[y],max($botx[i],$botx[y])-bardiff/2,hh) COLOURED (255,0,0,20) BORDERCOLOR (200,0,0,0)
        endif
       endif
      next
     next
    endif
    
    return
    #239150 quote
    Iván GonzálezIván González
    Moderator
    Legend

    Bonjour bien. Vous devrez d'abord stocker le volume dans un tableau au moment de la création du point pivot.

    if high[cp] >= highest[(cp)*2+1](high) then //new fractal high found
    $TOPy[lastset($TOPy)+1] = high[cp] //store fractal value
    $TOPx[lastset($TOPx)+1] = barindex[cp] //store fractal barindex
    $TOPvol[lastset($TOPvol)+1] = volume[cp] //store fractal volume
    endif
    
    if low[cp] <= lowest[(cp)*2+1](low)  then //new fractal low found
    $BOTy[lastset($BOTy)+1] = low[cp] //store fractal value
    $BOTx[lastset($BOTx)+1] = barindex[cp] //store fractal barindex
    $BOTvol[lastset($BOTvol)+1] = volume[cp] //store fractal volume
    endif

    Ensuite, vous pouvez l'utiliser dans la boucle.

    PRC_2021 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

condition plus haut bas


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
author-avatar
PRC_2021 @manu35250 Participant
Summary

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

Topic Details
Forum: ProBuilder : Indicateurs & Outils Personnalisés
Language: French
Started: 10/17/2024
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...