pine script to probuilder

Viewing 15 posts - 1 through 15 (of 21 total)
  • Author
    Posts
  • #225075 quote
    VINNYVINCE
    Participant
    New

    hello all I have a question I’m hoping some one can help? I like an indicator on trading view platform called sessions (luxalgo) which is coded in pine script I’m wondering if its possible to convert to probuilder to use in prorealtime platform? I am pretty clueless when it comes to things like this I am also  new to this forum.

    #225078 quote
    JS
    Participant
    Senior

    Hi @VINNYVINCE

    If you want a code conversion, the “official” way to do it is via menu:

    Help => Ask for a free code conversion (and provide all the data that is requested)

    #225136 quote
    LucasBest
    Participant
    Average
    https://www.tradingview.com/script/bkb6vZDz-Sessions-LuxAlgo/ Sessions (by Luxalgo) is more than 600 lines of pinescript codes, it would take a lot of time to convert. But at the end, it is no more than a session overlay! Maybe it would take less time and effort and would be more simple to just make all together a prorealcode that do the same kind of session overlay… ?
    VINNYVINCE thanked this post
    #225162 quote
    LucasBest
    Participant
    Average
    Here’s the prorealcode for Europe session…
    DefParam DrawOnLastBarOnly = true
    
    Once EUIndex = 0
    
    ////////////////////
    // EUROPE Session //
    ////////////////////
    
    If OpenTime >= 090000 AND OpenTime < 173000 THEN
    IF OpenTime = 090000 THEN
    EUBegin = Barindex
    EUHigh = high
    EULow = low
    EUActive = 1
    ENDIF
    EUEnd = Barindex
    EUHigh = max(EUHigh,high)
    EULow = min(EULow,low)
    Offset = Average[1+EUEnd-EUBegin](TR(close))
    
    If ShowMedianPrice then
    EUMedian = (EUHigh+EULow)/2
    Drawsegment(EUBegin,EUMedian,EUEnd,EUMedian) style(line,3) coloured("tomato",200)
    Endif
    
    If ShowMeanPrice then
    EUAverage = Average[EUEnd-EUBegin+1](Close)
    Drawsegment(EUBegin,EUAverage,EUEnd,EUAverage) style(line,3) coloured("tomato",200)
    Endif
    
    If ShowVWAP then
    If barindex = EUBegin then
    PreviousEUVWAP = typicalprice
    Endif
    If barindex >= EUBegin+1 then
    For k = EUBegin+1 to barindex do
    If volume>0 then
    EUVWAP = SUMMATION[k-EUBegin](volume[Barindex-k]*typicalprice[Barindex-k])/SUMMATION[k-EUBegin](volume[Barindex-k])
    Drawsegment(k-1,PreviousEUVWAP,k,EUVWAP) style(line,3) coloured("tomato",200)
    PreviousEUVWAP = EUVWAP
    Endif
    Next
    Endif
    Endif
    
    If ShowTrendLine then
    If Barindex > EUBegin then
    b=linearregression[EUEnd-EUBegin](close)
    a=linearregressionslope[EUEnd-EUBegin](close)
    y=b-a*(EUEnd-EUBegin-1)
    Drawsegment(EUBegin,y,EUEnd,b)Style(dottedline2,4) style(line,3) coloured("tomato",200)
    Endif
    Endif
    
    Drawrectangle(EUBegin,EUHigh,EUEnd,EULow) coloured("tomato",10) bordercolor("tomato",200) style(dottedline,2)
    Drawtext("Euronext",(EUBegin+EUEnd)/2,EUHigh+Offset/2) coloured("tomato",200)
    ENDIF
    
    If Opentime = 173000 then
    $EUBegin[EUIndex] = EUBegin
    $EUEnd[EUIndex] = EUEnd
    $EUHigh[EUIndex] = EUHigh
    $EULow[EUIndex] = EULow
    $Offset[EUIndex] = Offset
    EUActive = 0
    EUIndex = EUIndex + 1
    Endif
    
    
    If Sessions2Show > 0 then
    
    If EUIndex > 0 then
    
    EUSessions2Draw = Max(0,Sessions2Show-EUActive)
    EUFirstSession = Max(0,EUIndex-Min(EUSessions2Draw,EUIndex))
    
    For i = EUIndex-1 downto EUFirstSession do
    
    If ShowMedianPrice then
    EUMedian = ($EUHigh[i]+$EULow[i])/2
    Drawsegment($EUBegin[i],EUMedian,$EUEnd[i],EUMedian) style(line,3) coloured("tomato",200)
    Endif
    
    If ShowMeanPrice then
    delay = Barindex-$EUEnd[i]
    EUAverage = Average[$EUEnd[i]-$EUBegin[i]+1](Close[delay])
    Drawsegment($EUBegin[i],EUAverage,$EUEnd[i],EUAverage) style(line,3) coloured("tomato",200)
    Endif
    
    If ShowVWAP then
    delay = Barindex-$EUBegin[i]
    PreviousEUVWAP = typicalprice[delay]
    For k = $EUBegin[i]+1 to $EUEnd[i] do
    delay = barindex-k
    length = k-$EUBegin[i]
    If volume[delay]>0 then
    EUVWAP = SUMMATION[length](volume[delay]*typicalprice[delay])/SUMMATION[length](volume[delay])
    Drawsegment(k-1,PreviousEUVWAP,k,EUVWAP) style(line,3) coloured("tomato",200)
    PreviousEUVWAP = EUVWAP
    Endif
    Next
    Endif
    
    If ShowTrendLine then
    delay = Barindex-$EUEnd[i]
    b=linearregression[$EUEnd[i]-$EUBegin[i]+1](close[delay])
    a=linearregressionslope[$EUEnd[i]-$EUBegin[i]+1](close[delay])
    y=b-a*($EUEnd[i]-$EUBegin[i])
    Drawsegment($EUBegin[i],y,$EUEnd[i],b) Style(dottedline2,4) style(line,3) coloured("tomato",200)
    Endif
    
    Drawrectangle($EUBegin[i],$EUHigh[i],$EUEnd[i],$EULow[i]) coloured("tomato",10) bordercolor("tomato",200) style(line,2)
    Drawtext("Euronext",($EUBegin[i]+$EUEnd[i])/2,$EUHigh[i]+$Offset[i]/2) coloured("tomato",200)
    
    Next
    
    Endif
    Endif
    
    Return
    JS and VINNYVINCE thanked this post
    #225170 quote
    LucasBest
    Participant
    Average
    I added New York session.
    DefParam DrawOnLastBarOnly = true
    
    Once EUIndex = 0
    Once NYIndex = 0
    
    ////////////////////
    // EUROPE Session //
    ////////////////////
    
    If ShowEuropeSession then
    
    If OpenTime >= 090000 AND OpenTime < 173000 THEN
    IF OpenTime = 090000 THEN
    EUBegin = Barindex
    EUHigh = high
    EULow = low
    EUActive = 1
    ENDIF
    EUEnd = Barindex
    EUHigh = max(EUHigh,high)
    EULow = min(EULow,low)
    Offset = Average[1+EUEnd-EUBegin](TR(close))
    
    If ShowMedianPrice then
    EUMedian = (EUHigh+EULow)/2
    Drawsegment(EUBegin,EUMedian,EUEnd,EUMedian) style(line,3) coloured("royalblue",200)
    Endif
    
    If ShowMeanPrice then
    EUAverage = Average[EUEnd-EUBegin+1](Close)
    Drawsegment(EUBegin,EUAverage,EUEnd,EUAverage) style(line,3) coloured("royalblue",200)
    Endif
    
    If ShowVWAP then
    If barindex = EUBegin then
    PreviousEUVWAP = typicalprice
    Endif
    If barindex >= EUBegin+1 then
    For k = EUBegin+1 to barindex do
    If volume>0 then
    EUVWAP = SUMMATION[k-EUBegin](volume[Barindex-k]*typicalprice[Barindex-k])/SUMMATION[k-EUBegin](volume[Barindex-k])
    Drawsegment(k-1,PreviousEUVWAP,k,EUVWAP) style(line,3) coloured("royalblue",200)
    PreviousEUVWAP = EUVWAP
    Endif
    Next
    Endif
    Endif
    
    If ShowTrendLine then
    If Barindex > EUBegin then
    b=linearregression[EUEnd-EUBegin](close)
    a=linearregressionslope[EUEnd-EUBegin](close)
    y=b-a*(EUEnd-EUBegin-1)
    Drawsegment(EUBegin,y,EUEnd,b)Style(dottedline2,4) style(line,3) coloured("royalblue",200)
    Endif
    Endif
    
    Drawrectangle(EUBegin,EUHigh,EUEnd,EULow) coloured("royalblue",10) bordercolor("royalblue",200) style(dottedline,2)
    Drawtext("Euronext",(EUBegin+EUEnd)/2,EUHigh+Offset/2) coloured("royalblue",200)
    ENDIF
    
    If Opentime = 173000 then
    $EUBegin[EUIndex] = EUBegin
    $EUEnd[EUIndex] = EUEnd
    $EUHigh[EUIndex] = EUHigh
    $EULow[EUIndex] = EULow
    $Offset[EUIndex] = Offset
    EUActive = 0
    EUIndex = EUIndex + 1
    Endif
    
    Endif
    
    //////////////////////
    // New York Session //
    //////////////////////
    
    If ShowNewYorkSession then
    
    If OpenTime >= 153000 AND OpenTime < 220000 THEN
    IF OpenTime = 153000 THEN
    NYBegin = Barindex
    NYHigh = high
    NYLow = low
    NYActive = 1
    ENDIF
    NYEnd = Barindex
    NYHigh = max(NYHigh,high)
    NYLow = min(NYLow,low)
    Offset = Average[1+NYEnd-NYBegin](TR(close))
    
    If ShowMedianPrice then
    NYMedian = (NYHigh+NYLow)/2
    Drawsegment(NYBegin,NYMedian,NYEnd,NYMedian) style(line,3) coloured("tomato",200)
    Endif
    
    If ShowMeanPrice then
    NYAverage = Average[NYEnd-NYBegin+1](Close)
    Drawsegment(NYBegin,NYAverage,NYEnd,NYAverage) style(line,3) coloured("tomato",200)
    Endif
    
    If ShowVWAP then
    If barindex = NYBegin then
    PreviousNYVWAP = typicalprice
    Endif
    If barindex >= NYBegin+1 then
    For k = NYBegin+1 to barindex do
    If volume>0 then
    NYVWAP = SUMMATION[k-NYBegin](volume[Barindex-k]*typicalprice[Barindex-k])/SUMMATION[k-NYBegin](volume[Barindex-k])
    Drawsegment(k-1,PreviousNYVWAP,k,NYVWAP) style(line,3) coloured("tomato",200)
    PreviousNYVWAP = NYVWAP
    Endif
    Next
    Endif
    Endif
    
    If ShowTrendLine then
    If Barindex > NYBegin then
    b=linearregression[NYEnd-NYBegin](close)
    a=linearregressionslope[NYEnd-NYBegin](close)
    y=b-a*(NYEnd-NYBegin-1)
    Drawsegment(NYBegin,y,NYEnd,b)Style(dottedline2,4) style(line,3) coloured("tomato",200)
    Endif
    Endif
    
    Drawrectangle(NYBegin,NYHigh,NYEnd,NYLow) coloured("tomato",10) bordercolor("tomato",200) style(dottedline,2)
    Drawtext("New York",(NYBegin+NYEnd)/2,NYHigh+Offset/2.5) coloured("tomato",200)
    ENDIF
    
    If Opentime = 220000 then
    $NYBegin[NYIndex] = NYBegin
    $NYEnd[NYIndex] = NYEnd
    $NYHigh[NYIndex] = NYHigh
    $NYLow[NYIndex] = NYLow
    $Offset[NYIndex] = Offset
    NYActive = 0
    NYIndex = NYIndex + 1
    Endif
    
    Endif
    
    
    ///////////////////////////////
    // Previous Sessions drawing //
    ///////////////////////////////
    
    If Sessions2Show > 0 then
    
    // EUROPE Session //
    
    If ShowEuropeSession and EUIndex > 0 then
    
    EUSessions2Draw = Max(0,Sessions2Show-EUActive)
    EUFirstSession = Max(0,EUIndex-Min(EUSessions2Draw,EUIndex))
    
    For i = EUIndex-1 downto EUFirstSession do
    
    If ShowMedianPrice then
    EUMedian = ($EUHigh[i]+$EULow[i])/2
    Drawsegment($EUBegin[i],EUMedian,$EUEnd[i],EUMedian) style(line,3) coloured("royalblue",200)
    Endif
    
    If ShowMeanPrice then
    delay = Barindex-$EUEnd[i]
    EUAverage = Average[$EUEnd[i]-$EUBegin[i]+1](Close[delay])
    Drawsegment($EUBegin[i],EUAverage,$EUEnd[i],EUAverage) style(line,3) coloured("royalblue",200)
    Endif
    
    If ShowVWAP then
    delay = Barindex-$EUBegin[i]
    PreviousEUVWAP = typicalprice[delay]
    For k = $EUBegin[i]+1 to $EUEnd[i] do
    delay = barindex-k
    length = k-$EUBegin[i]
    If volume[delay]>0 then
    EUVWAP = SUMMATION[length](volume[delay]*typicalprice[delay])/SUMMATION[length](volume[delay])
    Drawsegment(k-1,PreviousEUVWAP,k,EUVWAP) style(line,3) coloured("royalblue",200)
    PreviousEUVWAP = EUVWAP
    Endif
    Next
    Endif
    
    If ShowTrendLine then
    delay = Barindex-$EUEnd[i]
    b=linearregression[$EUEnd[i]-$EUBegin[i]+1](close[delay])
    a=linearregressionslope[$EUEnd[i]-$EUBegin[i]+1](close[delay])
    y=b-a*($EUEnd[i]-$EUBegin[i])
    Drawsegment($EUBegin[i],y,$EUEnd[i],b) Style(dottedline2,4) style(line,3) coloured("royalblue",200)
    Endif
    
    Drawrectangle($EUBegin[i],$EUHigh[i],$EUEnd[i],$EULow[i]) coloured("royalblue",10) bordercolor("royalblue",200) style(line,2)
    Drawtext("Euronext",($EUBegin[i]+$EUEnd[i])/2,$EUHigh[i]+$Offset[i]/2) coloured("royalblue",200)
    Next
    Endif
    
    // New York Session //
    
    If ShowNewYorkSession and NYIndex > 0 then
    
    NYSessions2Draw = Max(0,Sessions2Show-NYActive)
    NYFirstSession = Max(0,NYIndex-Min(NYSessions2Draw,NYIndex))
    
    For i = NYIndex-1 downto NYFirstSession do
    
    If ShowMedianPrice then
    NYMedian = ($NYHigh[i]+$NYLow[i])/2
    Drawsegment($NYBegin[i],NYMedian,$NYEnd[i],NYMedian) style(line,3) coloured("tomato",200)
    Endif
    
    If ShowMeanPrice then
    delay = Barindex-$NYEnd[i]
    NYAverage = Average[$NYEnd[i]-$NYBegin[i]+1](Close[delay])
    Drawsegment($NYBegin[i],NYAverage,$NYEnd[i],NYAverage) style(line,3) coloured("tomato",200)
    Endif
    
    If ShowVWAP then
    delay = Barindex-$NYBegin[i]
    PreviousNYVWAP = typicalprice[delay]
    For k = $NYBegin[i]+1 to $NYEnd[i] do
    delay = barindex-k
    length = k-$NYBegin[i]
    If volume[delay]>0 then
    NYVWAP = SUMMATION[length](volume[delay]*typicalprice[delay])/SUMMATION[length](volume[delay])
    Drawsegment(k-1,PreviousNYVWAP,k,NYVWAP) style(line,3) coloured("tomato",200)
    PreviousNYVWAP = NYVWAP
    Endif
    Next
    Endif
    
    If ShowTrendLine then
    delay = Barindex-$NYEnd[i]
    b=linearregression[$NYEnd[i]-$NYBegin[i]+1](close[delay])
    a=linearregressionslope[$NYEnd[i]-$NYBegin[i]+1](close[delay])
    y=b-a*($NYEnd[i]-$NYBegin[i])
    Drawsegment($NYBegin[i],y,$NYEnd[i],b) Style(dottedline2,4) style(line,3) coloured("tomato",200)
    Endif
    
    Drawrectangle($NYBegin[i],$NYHigh[i],$NYEnd[i],$NYLow[i]) coloured("tomato",10) bordercolor("tomato",200) style(line,2)
    Drawtext("New York",($NYBegin[i]+$NYEnd[i])/2,$NYHigh[i]+$Offset[i]/2) coloured("tomato",200)
    Next
    Endif
    
    Endif
    
    Return
    
    VINNYVINCE thanked this post
    #225173 quote
    LucasBest
    Participant
    Average
    With Tokyo session added…
    DefParam DrawOnLastBarOnly = true
    
    Once EUIndex = 0
    Once NYIndex = 0
    Once JPIndex = 0
    
    ////////////////////
    // EUROPE Session //
    ////////////////////
    
    If ShowEuropeSession then
    
    If OpenTime >= 090000 AND OpenTime < 173000 THEN
    IF OpenTime = 090000 THEN
    EUBegin = Barindex
    EUHigh = high
    EULow = low
    EUActive = 1
    ENDIF
    EUEnd = Barindex
    EUHigh = max(EUHigh,high)
    EULow = min(EULow,low)
    Offset = Average[1+EUEnd-EUBegin](TR(close))
    
    If ShowMedianPrice then
    EUMedian = (EUHigh+EULow)/2
    Drawsegment(EUBegin,EUMedian,EUEnd,EUMedian) style(line,3) coloured("royalblue",200)
    Endif
    
    If ShowMeanPrice then
    EUAverage = Average[EUEnd-EUBegin+1](Close)
    Drawsegment(EUBegin,EUAverage,EUEnd,EUAverage) style(line,3) coloured("royalblue",200)
    Endif
    
    If ShowVWAP then
    If barindex = EUBegin then
    PreviousEUVWAP = typicalprice
    Endif
    If barindex >= EUBegin+1 then
    For k = EUBegin+1 to barindex do
    If volume>0 then
    EUVWAP = SUMMATION[k-EUBegin](volume[Barindex-k]*typicalprice[Barindex-k])/SUMMATION[k-EUBegin](volume[Barindex-k])
    Drawsegment(k-1,PreviousEUVWAP,k,EUVWAP) style(line,3) coloured("royalblue",200)
    PreviousEUVWAP = EUVWAP
    Endif
    Next
    Endif
    Endif
    
    If ShowTrendLine then
    If Barindex > EUBegin then
    b=linearregression[EUEnd-EUBegin](close)
    a=linearregressionslope[EUEnd-EUBegin](close)
    y=b-a*(EUEnd-EUBegin-1)
    Drawsegment(EUBegin,y,EUEnd,b)Style(dottedline2,4) style(line,3) coloured("royalblue",200)
    Endif
    Endif
    
    Drawrectangle(EUBegin,EUHigh,EUEnd,EULow) coloured("royalblue",10) bordercolor("royalblue",200) style(dottedline,2)
    Drawtext("Euronext",(EUBegin+EUEnd)/2,EUHigh+Offset/2) coloured("royalblue",200)
    ENDIF
    
    If Opentime = 173000 then
    $EUBegin[EUIndex] = EUBegin
    $EUEnd[EUIndex] = EUEnd
    $EUHigh[EUIndex] = EUHigh
    $EULow[EUIndex] = EULow
    $Offset[EUIndex] = Offset
    EUActive = 0
    EUIndex = EUIndex + 1
    Endif
    
    Endif
    
    //////////////////////
    // New York Session //
    //////////////////////
    
    If ShowNewYorkSession then
    
    If OpenTime >= 153000 AND OpenTime < 220000 THEN
    IF OpenTime = 153000 THEN
    NYBegin = Barindex
    NYHigh = high
    NYLow = low
    NYActive = 1
    ENDIF
    NYEnd = Barindex
    NYHigh = max(NYHigh,high)
    NYLow = min(NYLow,low)
    Offset = Average[1+NYEnd-NYBegin](TR(close))
    
    If ShowMedianPrice then
    NYMedian = (NYHigh+NYLow)/2
    Drawsegment(NYBegin,NYMedian,NYEnd,NYMedian) style(line,3) coloured("tomato",200)
    Endif
    
    If ShowMeanPrice then
    NYAverage = Average[NYEnd-NYBegin+1](Close)
    Drawsegment(NYBegin,NYAverage,NYEnd,NYAverage) style(line,3) coloured("tomato",200)
    Endif
    
    If ShowVWAP then
    If barindex = NYBegin then
    PreviousNYVWAP = typicalprice
    Endif
    If barindex >= NYBegin+1 then
    For k = NYBegin+1 to barindex do
    If volume>0 then
    NYVWAP = SUMMATION[k-NYBegin](volume[Barindex-k]*typicalprice[Barindex-k])/SUMMATION[k-NYBegin](volume[Barindex-k])
    Drawsegment(k-1,PreviousNYVWAP,k,NYVWAP) style(line,3) coloured("tomato",200)
    PreviousNYVWAP = NYVWAP
    Endif
    Next
    Endif
    Endif
    
    If ShowTrendLine then
    If Barindex > NYBegin then
    b=linearregression[NYEnd-NYBegin](close)
    a=linearregressionslope[NYEnd-NYBegin](close)
    y=b-a*(NYEnd-NYBegin-1)
    Drawsegment(NYBegin,y,NYEnd,b)Style(dottedline2,4) style(line,3) coloured("tomato",200)
    Endif
    Endif
    
    Drawrectangle(NYBegin,NYHigh,NYEnd,NYLow) coloured("tomato",10) bordercolor("tomato",200) style(dottedline,2)
    Drawtext("New York",(NYBegin+NYEnd)/2,NYHigh+Offset/2.5) coloured("tomato",200)
    ENDIF
    
    If Opentime = 220000 then
    $NYBegin[NYIndex] = NYBegin
    $NYEnd[NYIndex] = NYEnd
    $NYHigh[NYIndex] = NYHigh
    $NYLow[NYIndex] = NYLow
    $Offset[NYIndex] = Offset
    NYActive = 0
    NYIndex = NYIndex + 1
    Endif
    
    Endif
    
    ////////////////////
    // Tokyo Session //
    ////////////////////
    
    If ShowTokyoSession then
    
    If OpenTime >= 010000 AND OpenTime < 070000 THEN
    IF OpenTime = 010000 THEN
    JPBegin = Barindex
    JPHigh = high
    JPLow = low
    JPActive = 1
    ENDIF
    JPEnd = Barindex
    JPHigh = max(JPHigh,high)
    JPLow = min(JPLow,low)
    Offset = Average[1+JPEnd-JPBegin](TR(close))
    
    If ShowMedianPrice then
    JPMedian = (JPHigh+JPLow)/2
    Drawsegment(JPBegin,JPMedian,JPEnd,JPMedian) style(line,3) coloured("mediumvioletred",200)
    Endif
    
    If ShowMeanPrice then
    JPAverage = Average[JPEnd-JPBegin+1](Close)
    Drawsegment(JPBegin,JPAverage,JPEnd,JPAverage) style(line,3) coloured("mediumvioletred",200)
    Endif
    
    If ShowVWAP then
    If barindex = JPBegin then
    PreviousJPVWAP = typicalprice
    Endif
    If barindex >= JPBegin+1 then
    For k = JPBegin+1 to barindex do
    If volume>0 then
    JPVWAP = SUMMATION[k-JPBegin](volume[Barindex-k]*typicalprice[Barindex-k])/SUMMATION[k-JPBegin](volume[Barindex-k])
    Drawsegment(k-1,PreviousJPVWAP,k,JPVWAP) style(line,3) coloured("mediumvioletred",200)
    PreviousJPVWAP = JPVWAP
    Endif
    Next
    Endif
    Endif
    
    If ShowTrendLine then
    If Barindex > JPBegin then
    b=linearregression[JPEnd-JPBegin](close)
    a=linearregressionslope[JPEnd-JPBegin](close)
    y=b-a*(JPEnd-JPBegin-1)
    Drawsegment(JPBegin,y,JPEnd,b)Style(dottedline2,4) style(line,3) coloured("mediumvioletred",200)
    Endif
    Endif
    
    Drawrectangle(JPBegin,JPHigh,JPEnd,JPLow) coloured("mediumvioletred",10) bordercolor("mediumvioletred",200) style(dottedline,2)
    Drawtext("Tokyo",(JPBegin+JPEnd)/2,JPHigh+Offset/2) coloured("mediumvioletred",200)
    ENDIF
    
    If Opentime = 070000 then
    $JPBegin[JPIndex] = JPBegin
    $JPEnd[JPIndex] = JPEnd
    $JPHigh[JPIndex] = JPHigh
    $JPLow[JPIndex] = JPLow
    $Offset[JPIndex] = Offset
    JPActive = 0
    JPIndex = JPIndex + 1
    Endif
    
    Endif
    
    
    ///////////////////////////////
    // Previous Sessions drawing //
    ///////////////////////////////
    
    If Sessions2Show > 0 then
    
    // EUROPE Session //
    
    If ShowEuropeSession and EUIndex > 0 then
    
    EUSessions2Draw = Max(0,Sessions2Show-EUActive)
    EUFirstSession = Max(0,EUIndex-Min(EUSessions2Draw,EUIndex))
    
    For i = EUIndex-1 downto EUFirstSession do
    
    If ShowMedianPrice then
    EUMedian = ($EUHigh[i]+$EULow[i])/2
    Drawsegment($EUBegin[i],EUMedian,$EUEnd[i],EUMedian) style(line,3) coloured("royalblue",200)
    Endif
    
    If ShowMeanPrice then
    delay = Barindex-$EUEnd[i]
    EUAverage = Average[$EUEnd[i]-$EUBegin[i]+1](Close[delay])
    Drawsegment($EUBegin[i],EUAverage,$EUEnd[i],EUAverage) style(line,3) coloured("royalblue",200)
    Endif
    
    If ShowVWAP then
    delay = Barindex-$EUBegin[i]
    PreviousEUVWAP = typicalprice[delay]
    For k = $EUBegin[i]+1 to $EUEnd[i] do
    delay = barindex-k
    length = k-$EUBegin[i]
    If volume[delay]>0 then
    EUVWAP = SUMMATION[length](volume[delay]*typicalprice[delay])/SUMMATION[length](volume[delay])
    Drawsegment(k-1,PreviousEUVWAP,k,EUVWAP) style(line,3) coloured("royalblue",200)
    PreviousEUVWAP = EUVWAP
    Endif
    Next
    Endif
    
    If ShowTrendLine then
    delay = Barindex-$EUEnd[i]
    b=linearregression[$EUEnd[i]-$EUBegin[i]+1](close[delay])
    a=linearregressionslope[$EUEnd[i]-$EUBegin[i]+1](close[delay])
    y=b-a*($EUEnd[i]-$EUBegin[i])
    Drawsegment($EUBegin[i],y,$EUEnd[i],b) Style(dottedline2,4) style(line,3) coloured("royalblue",200)
    Endif
    
    Drawrectangle($EUBegin[i],$EUHigh[i],$EUEnd[i],$EULow[i]) coloured("royalblue",10) bordercolor("royalblue",200) style(line,2)
    Drawtext("Euronext",($EUBegin[i]+$EUEnd[i])/2,$EUHigh[i]+$Offset[i]/2) coloured("royalblue",200)
    Next
    Endif
    
    // New York Session //
    
    If ShowNewYorkSession and NYIndex > 0 then
    
    NYSessions2Draw = Max(0,Sessions2Show-NYActive)
    NYFirstSession = Max(0,NYIndex-Min(NYSessions2Draw,NYIndex))
    
    For i = NYIndex-1 downto NYFirstSession do
    
    If ShowMedianPrice then
    NYMedian = ($NYHigh[i]+$NYLow[i])/2
    Drawsegment($NYBegin[i],NYMedian,$NYEnd[i],NYMedian) style(line,3) coloured("tomato",200)
    Endif
    
    If ShowMeanPrice then
    delay = Barindex-$NYEnd[i]
    NYAverage = Average[$NYEnd[i]-$NYBegin[i]+1](Close[delay])
    Drawsegment($NYBegin[i],NYAverage,$NYEnd[i],NYAverage) style(line,3) coloured("tomato",200)
    Endif
    
    If ShowVWAP then
    delay = Barindex-$NYBegin[i]
    PreviousNYVWAP = typicalprice[delay]
    For k = $NYBegin[i]+1 to $NYEnd[i] do
    delay = barindex-k
    length = k-$NYBegin[i]
    If volume[delay]>0 then
    NYVWAP = SUMMATION[length](volume[delay]*typicalprice[delay])/SUMMATION[length](volume[delay])
    Drawsegment(k-1,PreviousNYVWAP,k,NYVWAP) style(line,3) coloured("tomato",200)
    PreviousNYVWAP = NYVWAP
    Endif
    Next
    Endif
    
    If ShowTrendLine then
    delay = Barindex-$NYEnd[i]
    b=linearregression[$NYEnd[i]-$NYBegin[i]+1](close[delay])
    a=linearregressionslope[$NYEnd[i]-$NYBegin[i]+1](close[delay])
    y=b-a*($NYEnd[i]-$NYBegin[i])
    Drawsegment($NYBegin[i],y,$NYEnd[i],b) Style(dottedline2,4) style(line,3) coloured("tomato",200)
    Endif
    
    Drawrectangle($NYBegin[i],$NYHigh[i],$NYEnd[i],$NYLow[i]) coloured("tomato",10) bordercolor("tomato",200) style(line,2)
    Drawtext("New York",($NYBegin[i]+$NYEnd[i])/2,$NYHigh[i]+$Offset[i]/2) coloured("tomato",200)
    Next
    Endif
    
    // TOKYO Session //
    
    If ShowTokyoSession and JPIndex > 0 then
    
    JPSessions2Draw = Max(0,Sessions2Show-JPActive)
    JPFirstSession = Max(0,JPIndex-Min(JPSessions2Draw,JPIndex))
    
    For i = JPIndex-1 downto JPFirstSession do
    
    If ShowMedianPrice then
    JPMedian = ($JPHigh[i]+$JPLow[i])/2
    Drawsegment($JPBegin[i],JPMedian,$JPEnd[i],JPMedian) style(line,3) coloured("mediumvioletred",200)
    Endif
    
    If ShowMeanPrice then
    delay = Barindex-$JPEnd[i]
    JPAverage = Average[$JPEnd[i]-$JPBegin[i]+1](Close[delay])
    Drawsegment($JPBegin[i],JPAverage,$JPEnd[i],JPAverage) style(line,3) coloured("mediumvioletred",200)
    Endif
    
    If ShowVWAP then
    delay = Barindex-$JPBegin[i]
    PreviousJPVWAP = typicalprice[delay]
    For k = $JPBegin[i]+1 to $JPEnd[i] do
    delay = barindex-k
    length = k-$JPBegin[i]
    If volume[delay]>0 then
    JPVWAP = SUMMATION[length](volume[delay]*typicalprice[delay])/SUMMATION[length](volume[delay])
    Drawsegment(k-1,PreviousJPVWAP,k,JPVWAP) style(line,3) coloured("mediumvioletred",200)
    PreviousJPVWAP = JPVWAP
    Endif
    Next
    Endif
    
    If ShowTrendLine then
    delay = Barindex-$JPEnd[i]
    b=linearregression[$JPEnd[i]-$JPBegin[i]+1](close[delay])
    a=linearregressionslope[$JPEnd[i]-$JPBegin[i]+1](close[delay])
    y=b-a*($JPEnd[i]-$JPBegin[i])
    Drawsegment($JPBegin[i],y,$JPEnd[i],b) Style(dottedline2,4) style(line,3) coloured("mediumvioletred",200)
    Endif
    
    Drawrectangle($JPBegin[i],$JPHigh[i],$JPEnd[i],$JPLow[i]) coloured("mediumvioletred",10) bordercolor("mediumvioletred",200) style(line,2)
    Drawtext("Tokyo",($JPBegin[i]+$JPEnd[i])/2,$JPHigh[i]+$Offset[i]/2) coloured("mediumvioletred",200)
    Next
    Endif
    
    Endif
    
    Return
    JS, PeterSt and VINNYVINCE thanked this post
    #225184 quote
    PeterSt
    Participant
    Master
    Lucas, great stuff. I just wanted to ask whether I should add all of the others, but I see it is a work in progress. 🙂 🙂 What I see as very beneficial is having them all. Thus also India etc., never mind that we can’t trade them via PRT-IB; they vastly influence (at least at openings). And I myself can’t remember them all – them often varying as well. Offtopic I think : That VWAP checkbox is better not checked. V12 never seems to end with the calculations with 5K units and V11 maybe but still undoable (halfway after 20 minutes). Anyway, great thanks !   PS: It is crazy how much slower V12 is.
    VINNYVINCE thanked this post
    #225187 quote
    LucasBest
    Participant
    Average
    Hello Peter, Thanks. I can add the others sessions and maybe also a custom session (on configuration tab) to let the users choose custom hours… The hours of the differents sessions change if those sessions are forex ones or indices (shares) sessions. So maybe it is better to add an option for choosing whever you want forex sessions’ hours or indices sessions hours, or maybe add the hours of the begining and close of the sessions in the configuration tab or maybe at the begining of the code… I agree the VWAP takes too much time to calculate, i will check if it is possible to code the calculation an other way… Maybe i’ll need help for the dashboard part, if you are used to code dashboard ?
    #225188 quote
    LucasBest
    Participant
    Average
    https://www.investopedia.com/terms/t/tradingsession.asp Maybe the best would be to let the user configure the hours of the session on the configuration tab ?
    #225191 quote
    LucasBest
    Participant
    Average
    I don’t know if sessions “vastly influence (at least at openings)”… For me the trend remain in the channel most of the time, and sometimes the channel (the trend) may change during a session…
    #225195 quote
    LucasBest
    Participant
    Average
    DAX daily. Actual rally is impressive… Almost no consolidation!
    #225197 quote
    LucasBest
    Participant
    Average
    Dax 1 hour time frame. Deeper consolidation has begun ?
    #225214 quote
    PeterSt
    Participant
    Master
    I don’t know if sessions “vastly influence (at least at openings)”… For me the trend remain in the channel most of the time, and sometimes the channel (the trend) may change during a session…
    It can be telling for the “western” trading day (or whatever market, but the one(s) I trade. Below the examples of which I try to be right in retrospect. Thus, not completely honest because just looking back for the examples, but in real-life (and live) I work with this. Let’s say that we look at the opening of HK (01:30 Amsterdam). I can’t know or follow ALL what happens around the globe, but I can see by the way a market opens whether something is going on. In the first example HK drops at the opening. This tends to be leading for the remainder of the day everywhere. You can see how it exploits over Europe and later the USA (which latter already happens at 10:00 Amsterdam via ETH and Futures). The 2nd example I see nothing special happening. No choppiness elsewhere during the remainder of the day. Which … also is not a good day (it’s probably the trend of the previous day). The 3rd example is from this week, and all is going well. It goes well right from the start. And HK opening shows that. … I dare to buy on that HK indication. Anyway this is why I think it is a great indicator. Thank you again, and VINNYVINCE of course.
    #225218 quote
    PeterSt
    Participant
    Master
    Dax 1 hour time frame. Deeper consolidation has begun ?
    After just finally breaking the all time high a couple of days ago ? I’d say not. 🙂
    #225220 quote
    PeterSt
    Participant
    Master
    Maybe i’ll need help for the dashboard part, if you are used to code dashboard ?
    Oh, I will help for sure. It is only that I don’t know what you mean with “dashboard” in this realm ? can you elaborate a little ?
Viewing 15 posts - 1 through 15 (of 21 total)
  • You must be logged in to reply to this topic.

pine script to probuilder


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
VINNYVINCE @vinnyvince Participant
Summary

This topic contains 20 replies,
has 4 voices, and was last updated by LucasBest
2 years, 1 month ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 12/08/2023
Status: Active
Attachments: 18 files
Logo Logo
Loading...