Code pinescript vers ProBuilder

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #234701 quote
    Emanuel_
    Participant
    New

    Bonjour à tous,

    j’ai codé un indicateur dans trading_view avec pinescript et j’aimerais l’adapté pour pouvoir l’utilisé dans ProRealTime mais je ne trouve pas de documentation complète et donc je suis un peux perdu avec le langage.

    Voici mon code :

    //@version=5
    
    indicator("Parabolic SAR with High and Low Lines", overlay=true)
    
    // Calculate Parabolic SAR
    
    sar = ta.sar(0.02, 0.02, 0.2)
    
    // Signals
    
    signal_up = ta.crossover(close, sar)
    
    signal_down = ta.crossover(sar, close)
    
    // Variables to store the high and the low prices, and the start time of the lines
    
    var float highPrice = na
    
    var float lowPrice = na
    
    var int highBar = na
    
    var int lowBar = na
    
    var line highLine = na
    
    var line lowLine = na
    
    // Check for signal_up and signal_down
    
    if (signal_up)
    
        highPrice := high
    
        highBar := bar_index
    
        // Remove the previous lines if they exist
    
        if (na(highLine) == false)
    
            line.delete(highLine)
    
        highLine := na  // Reset the high line variable
    
    if (signal_down)
    
        lowPrice := low
    
        lowBar := bar_index
    
        if (na(lowLine) == false)
    
            line.delete(lowLine)
    
        lowLine := na   // Reset the low line variable
    
    // Update the highest high and the lowest low between signal_up and signal_down
    
    if not na(highPrice)
    
        highPrice := math.max(highPrice, high)
    
    if not na(lowPrice)
    
        lowPrice := math.min(lowPrice, low)
    
    // Plot the horizontal lines from signal_up to signal_down
    
    if not na(highPrice) and not signal_down
    
        // Remove the previous high line if it exists
    
        if (na(highLine) == false)
    
            line.delete(highLine)
    
        highLine := line.new(highBar, highPrice, bar_index, highPrice, color=color.red, width=2)
    
    if not na(lowPrice) and not signal_up
    
        // Remove the previous low line if it exists
    
        if (na(lowLine) == false)
    
            line.delete(lowLine)
    
        lowLine := line.new(lowBar, lowPrice, bar_index, lowPrice, color=color.green, width=2)
    
    if signal_down
    
        highPrice := na
    
        highLine := na  // Reset the high line variable
    
    if signal_up
    
        lowPrice := na
    
        lowLine := na
    
    plot(sar, style = plot.style_circles, linewidth = 1, color = sar < close ? color.green : color.red)

    Si quelqu’un saurait comment je peux faire des arrays et ensuite tracer mes lignes je suis preneurs, merci d’avance.

    #234705 quote
    Iván González
    Moderator
    Master

    Holà. Vraiment pas de tableaux de fautes. De toutes les formes, il est programmé avec des tableaux pour que vous puissiez fonctionner.

    //------------------------------------------------------------//
    Psar=SAR[0.02,0.02,0.2]
    
    //----Signals
    signalUP=close crosses over psar
    signalDN=close crosses under psar
    //----Store prices
    if signalUP then
    $price[t+1]=high
    $bar[t+1]=barindex
    $crossidx[t+1]=barindex
    $type[t+1]=1
    t=t+1
    elsif signalDN then
    $price[t+1]=low
    $bar[t+1]=barindex
    $crossidx[t+1]=barindex
    $type[t+1]=-1
    t=t+1
    endif
    //----Update prices between signals
    if not signalUP and $type[t]=1 and high>$price[t] then
    $price[t]=high
    $bar[t]=barindex
    endif
    
    if not signalDN and $type[t]=-1 and low<$price[t] then
    $price[t]=low
    $bar[t]=barindex
    endif
    //----Parabolic  Sar colors
    if close < psar then
    r=255
    g=0
    else
    r=0
    g=255
    endif
    //----Draw Parabolic Sar points
    drawpoint(barindex,psar,2)coloured(r,g,0)
    //----Draw Horizontal lines
    if islastbarupdate then
    for i=t downto 1 do
    if $type[i]=1 then
    drawsegment($crossidx[i],$price[i],$crossidx[i+1],$price[i])coloured("red")style(line,2)
    elsif $type[i]=-1 then
    drawsegment($crossidx[i],$price[i],$crossidx[i+1],$price[i])coloured("green")style(line,2)
    endif
    next
    endif
    return //psar as "P.Sar" coloured(r,g,0)style(dottedline,2)
    
    #234707 quote
    Emanuel_
    Participant
    New

    Merci beaucoup ça marche, mais ou avez vous appris a faire ça, car j’ai lu la documentation proposé par ProRealCode et elle me semble plutôt limité.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Code pinescript vers ProBuilder


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
author-avatar
Emanuel_ @emanuel_ Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by Emanuel_
1 year, 7 months ago.

Topic Details
Forum: ProBuilder : Indicateurs & Outils Personnalisés
Language: French
Started: 07/02/2024
Status: Active
Attachments: 1 files
Logo Logo
Loading...