pine script to probuilder
Forums › ProRealTime English forum › ProBuilder support › pine script to probuilder
- This topic has 20 replies, 4 voices, and was last updated 10 months ago by LucasBest.
-
-
12/08/2023 at 9:47 PM #225075
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.
12/08/2023 at 10:45 PM #225078Hi @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)
12/12/2023 at 8:34 AM #225136https://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… ?
1 user thanked author for this post.
12/12/2023 at 10:59 PM #225162Here’s the prorealcode for Europe session…
Europe Session123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120DefParam DrawOnLastBarOnly = trueOnce EUIndex = 0////////////////////// EUROPE Session //////////////////////If OpenTime >= 090000 AND OpenTime < 173000 THENIF OpenTime = 090000 THENEUBegin = BarindexEUHigh = highEULow = lowEUActive = 1ENDIFEUEnd = BarindexEUHigh = max(EUHigh,high)EULow = min(EULow,low)Offset = Average[1+EUEnd-EUBegin](TR(close))If ShowMedianPrice thenEUMedian = (EUHigh+EULow)/2Drawsegment(EUBegin,EUMedian,EUEnd,EUMedian) style(line,3) coloured("tomato",200)EndifIf ShowMeanPrice thenEUAverage = Average[EUEnd-EUBegin+1](Close)Drawsegment(EUBegin,EUAverage,EUEnd,EUAverage) style(line,3) coloured("tomato",200)EndifIf ShowVWAP thenIf barindex = EUBegin thenPreviousEUVWAP = typicalpriceEndifIf barindex >= EUBegin+1 thenFor k = EUBegin+1 to barindex doIf volume>0 thenEUVWAP = 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 = EUVWAPEndifNextEndifEndifIf ShowTrendLine thenIf Barindex > EUBegin thenb=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)EndifEndifDrawrectangle(EUBegin,EUHigh,EUEnd,EULow) coloured("tomato",10) bordercolor("tomato",200) style(dottedline,2)Drawtext("Euronext",(EUBegin+EUEnd)/2,EUHigh+Offset/2) coloured("tomato",200)ENDIFIf Opentime = 173000 then$EUBegin[EUIndex] = EUBegin$EUEnd[EUIndex] = EUEnd$EUHigh[EUIndex] = EUHigh$EULow[EUIndex] = EULow$Offset[EUIndex] = OffsetEUActive = 0EUIndex = EUIndex + 1EndifIf Sessions2Show > 0 thenIf EUIndex > 0 thenEUSessions2Draw = Max(0,Sessions2Show-EUActive)EUFirstSession = Max(0,EUIndex-Min(EUSessions2Draw,EUIndex))For i = EUIndex-1 downto EUFirstSession doIf ShowMedianPrice thenEUMedian = ($EUHigh[i]+$EULow[i])/2Drawsegment($EUBegin[i],EUMedian,$EUEnd[i],EUMedian) style(line,3) coloured("tomato",200)EndifIf ShowMeanPrice thendelay = 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)EndifIf ShowVWAP thendelay = Barindex-$EUBegin[i]PreviousEUVWAP = typicalprice[delay]For k = $EUBegin[i]+1 to $EUEnd[i] dodelay = barindex-klength = k-$EUBegin[i]If volume[delay]>0 thenEUVWAP = SUMMATION[length](volume[delay]*typicalprice[delay])/SUMMATION[length](volume[delay])Drawsegment(k-1,PreviousEUVWAP,k,EUVWAP) style(line,3) coloured("tomato",200)PreviousEUVWAP = EUVWAPEndifNextEndifIf ShowTrendLine thendelay = 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)EndifDrawrectangle($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)NextEndifEndifReturn2 users thanked author for this post.
12/13/2023 at 8:58 AM #225170I added New York session.
Europe and New York Session123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245DefParam DrawOnLastBarOnly = trueOnce EUIndex = 0Once NYIndex = 0////////////////////// EUROPE Session //////////////////////If ShowEuropeSession thenIf OpenTime >= 090000 AND OpenTime < 173000 THENIF OpenTime = 090000 THENEUBegin = BarindexEUHigh = highEULow = lowEUActive = 1ENDIFEUEnd = BarindexEUHigh = max(EUHigh,high)EULow = min(EULow,low)Offset = Average[1+EUEnd-EUBegin](TR(close))If ShowMedianPrice thenEUMedian = (EUHigh+EULow)/2Drawsegment(EUBegin,EUMedian,EUEnd,EUMedian) style(line,3) coloured("royalblue",200)EndifIf ShowMeanPrice thenEUAverage = Average[EUEnd-EUBegin+1](Close)Drawsegment(EUBegin,EUAverage,EUEnd,EUAverage) style(line,3) coloured("royalblue",200)EndifIf ShowVWAP thenIf barindex = EUBegin thenPreviousEUVWAP = typicalpriceEndifIf barindex >= EUBegin+1 thenFor k = EUBegin+1 to barindex doIf volume>0 thenEUVWAP = 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 = EUVWAPEndifNextEndifEndifIf ShowTrendLine thenIf Barindex > EUBegin thenb=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)EndifEndifDrawrectangle(EUBegin,EUHigh,EUEnd,EULow) coloured("royalblue",10) bordercolor("royalblue",200) style(dottedline,2)Drawtext("Euronext",(EUBegin+EUEnd)/2,EUHigh+Offset/2) coloured("royalblue",200)ENDIFIf Opentime = 173000 then$EUBegin[EUIndex] = EUBegin$EUEnd[EUIndex] = EUEnd$EUHigh[EUIndex] = EUHigh$EULow[EUIndex] = EULow$Offset[EUIndex] = OffsetEUActive = 0EUIndex = EUIndex + 1EndifEndif//////////////////////// New York Session ////////////////////////If ShowNewYorkSession thenIf OpenTime >= 153000 AND OpenTime < 220000 THENIF OpenTime = 153000 THENNYBegin = BarindexNYHigh = highNYLow = lowNYActive = 1ENDIFNYEnd = BarindexNYHigh = max(NYHigh,high)NYLow = min(NYLow,low)Offset = Average[1+NYEnd-NYBegin](TR(close))If ShowMedianPrice thenNYMedian = (NYHigh+NYLow)/2Drawsegment(NYBegin,NYMedian,NYEnd,NYMedian) style(line,3) coloured("tomato",200)EndifIf ShowMeanPrice thenNYAverage = Average[NYEnd-NYBegin+1](Close)Drawsegment(NYBegin,NYAverage,NYEnd,NYAverage) style(line,3) coloured("tomato",200)EndifIf ShowVWAP thenIf barindex = NYBegin thenPreviousNYVWAP = typicalpriceEndifIf barindex >= NYBegin+1 thenFor k = NYBegin+1 to barindex doIf volume>0 thenNYVWAP = 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 = NYVWAPEndifNextEndifEndifIf ShowTrendLine thenIf Barindex > NYBegin thenb=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)EndifEndifDrawrectangle(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)ENDIFIf Opentime = 220000 then$NYBegin[NYIndex] = NYBegin$NYEnd[NYIndex] = NYEnd$NYHigh[NYIndex] = NYHigh$NYLow[NYIndex] = NYLow$Offset[NYIndex] = OffsetNYActive = 0NYIndex = NYIndex + 1EndifEndif///////////////////////////////// Previous Sessions drawing /////////////////////////////////If Sessions2Show > 0 then// EUROPE Session //If ShowEuropeSession and EUIndex > 0 thenEUSessions2Draw = Max(0,Sessions2Show-EUActive)EUFirstSession = Max(0,EUIndex-Min(EUSessions2Draw,EUIndex))For i = EUIndex-1 downto EUFirstSession doIf ShowMedianPrice thenEUMedian = ($EUHigh[i]+$EULow[i])/2Drawsegment($EUBegin[i],EUMedian,$EUEnd[i],EUMedian) style(line,3) coloured("royalblue",200)EndifIf ShowMeanPrice thendelay = 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)EndifIf ShowVWAP thendelay = Barindex-$EUBegin[i]PreviousEUVWAP = typicalprice[delay]For k = $EUBegin[i]+1 to $EUEnd[i] dodelay = barindex-klength = k-$EUBegin[i]If volume[delay]>0 thenEUVWAP = SUMMATION[length](volume[delay]*typicalprice[delay])/SUMMATION[length](volume[delay])Drawsegment(k-1,PreviousEUVWAP,k,EUVWAP) style(line,3) coloured("royalblue",200)PreviousEUVWAP = EUVWAPEndifNextEndifIf ShowTrendLine thendelay = 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)EndifDrawrectangle($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)NextEndif// New York Session //If ShowNewYorkSession and NYIndex > 0 thenNYSessions2Draw = Max(0,Sessions2Show-NYActive)NYFirstSession = Max(0,NYIndex-Min(NYSessions2Draw,NYIndex))For i = NYIndex-1 downto NYFirstSession doIf ShowMedianPrice thenNYMedian = ($NYHigh[i]+$NYLow[i])/2Drawsegment($NYBegin[i],NYMedian,$NYEnd[i],NYMedian) style(line,3) coloured("tomato",200)EndifIf ShowMeanPrice thendelay = 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)EndifIf ShowVWAP thendelay = Barindex-$NYBegin[i]PreviousNYVWAP = typicalprice[delay]For k = $NYBegin[i]+1 to $NYEnd[i] dodelay = barindex-klength = k-$NYBegin[i]If volume[delay]>0 thenNYVWAP = SUMMATION[length](volume[delay]*typicalprice[delay])/SUMMATION[length](volume[delay])Drawsegment(k-1,PreviousNYVWAP,k,NYVWAP) style(line,3) coloured("tomato",200)PreviousNYVWAP = NYVWAPEndifNextEndifIf ShowTrendLine thendelay = 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)EndifDrawrectangle($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)NextEndifEndifReturn1 user thanked author for this post.
12/13/2023 at 9:35 AM #225173With Tokyo session added…
Europe, New York and Tokyo Sessions123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361DefParam DrawOnLastBarOnly = trueOnce EUIndex = 0Once NYIndex = 0Once JPIndex = 0////////////////////// EUROPE Session //////////////////////If ShowEuropeSession thenIf OpenTime >= 090000 AND OpenTime < 173000 THENIF OpenTime = 090000 THENEUBegin = BarindexEUHigh = highEULow = lowEUActive = 1ENDIFEUEnd = BarindexEUHigh = max(EUHigh,high)EULow = min(EULow,low)Offset = Average[1+EUEnd-EUBegin](TR(close))If ShowMedianPrice thenEUMedian = (EUHigh+EULow)/2Drawsegment(EUBegin,EUMedian,EUEnd,EUMedian) style(line,3) coloured("royalblue",200)EndifIf ShowMeanPrice thenEUAverage = Average[EUEnd-EUBegin+1](Close)Drawsegment(EUBegin,EUAverage,EUEnd,EUAverage) style(line,3) coloured("royalblue",200)EndifIf ShowVWAP thenIf barindex = EUBegin thenPreviousEUVWAP = typicalpriceEndifIf barindex >= EUBegin+1 thenFor k = EUBegin+1 to barindex doIf volume>0 thenEUVWAP = 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 = EUVWAPEndifNextEndifEndifIf ShowTrendLine thenIf Barindex > EUBegin thenb=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)EndifEndifDrawrectangle(EUBegin,EUHigh,EUEnd,EULow) coloured("royalblue",10) bordercolor("royalblue",200) style(dottedline,2)Drawtext("Euronext",(EUBegin+EUEnd)/2,EUHigh+Offset/2) coloured("royalblue",200)ENDIFIf Opentime = 173000 then$EUBegin[EUIndex] = EUBegin$EUEnd[EUIndex] = EUEnd$EUHigh[EUIndex] = EUHigh$EULow[EUIndex] = EULow$Offset[EUIndex] = OffsetEUActive = 0EUIndex = EUIndex + 1EndifEndif//////////////////////// New York Session ////////////////////////If ShowNewYorkSession thenIf OpenTime >= 153000 AND OpenTime < 220000 THENIF OpenTime = 153000 THENNYBegin = BarindexNYHigh = highNYLow = lowNYActive = 1ENDIFNYEnd = BarindexNYHigh = max(NYHigh,high)NYLow = min(NYLow,low)Offset = Average[1+NYEnd-NYBegin](TR(close))If ShowMedianPrice thenNYMedian = (NYHigh+NYLow)/2Drawsegment(NYBegin,NYMedian,NYEnd,NYMedian) style(line,3) coloured("tomato",200)EndifIf ShowMeanPrice thenNYAverage = Average[NYEnd-NYBegin+1](Close)Drawsegment(NYBegin,NYAverage,NYEnd,NYAverage) style(line,3) coloured("tomato",200)EndifIf ShowVWAP thenIf barindex = NYBegin thenPreviousNYVWAP = typicalpriceEndifIf barindex >= NYBegin+1 thenFor k = NYBegin+1 to barindex doIf volume>0 thenNYVWAP = 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 = NYVWAPEndifNextEndifEndifIf ShowTrendLine thenIf Barindex > NYBegin thenb=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)EndifEndifDrawrectangle(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)ENDIFIf Opentime = 220000 then$NYBegin[NYIndex] = NYBegin$NYEnd[NYIndex] = NYEnd$NYHigh[NYIndex] = NYHigh$NYLow[NYIndex] = NYLow$Offset[NYIndex] = OffsetNYActive = 0NYIndex = NYIndex + 1EndifEndif////////////////////// Tokyo Session //////////////////////If ShowTokyoSession thenIf OpenTime >= 010000 AND OpenTime < 070000 THENIF OpenTime = 010000 THENJPBegin = BarindexJPHigh = highJPLow = lowJPActive = 1ENDIFJPEnd = BarindexJPHigh = max(JPHigh,high)JPLow = min(JPLow,low)Offset = Average[1+JPEnd-JPBegin](TR(close))If ShowMedianPrice thenJPMedian = (JPHigh+JPLow)/2Drawsegment(JPBegin,JPMedian,JPEnd,JPMedian) style(line,3) coloured("mediumvioletred",200)EndifIf ShowMeanPrice thenJPAverage = Average[JPEnd-JPBegin+1](Close)Drawsegment(JPBegin,JPAverage,JPEnd,JPAverage) style(line,3) coloured("mediumvioletred",200)EndifIf ShowVWAP thenIf barindex = JPBegin thenPreviousJPVWAP = typicalpriceEndifIf barindex >= JPBegin+1 thenFor k = JPBegin+1 to barindex doIf volume>0 thenJPVWAP = 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 = JPVWAPEndifNextEndifEndifIf ShowTrendLine thenIf Barindex > JPBegin thenb=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)EndifEndifDrawrectangle(JPBegin,JPHigh,JPEnd,JPLow) coloured("mediumvioletred",10) bordercolor("mediumvioletred",200) style(dottedline,2)Drawtext("Tokyo",(JPBegin+JPEnd)/2,JPHigh+Offset/2) coloured("mediumvioletred",200)ENDIFIf Opentime = 070000 then$JPBegin[JPIndex] = JPBegin$JPEnd[JPIndex] = JPEnd$JPHigh[JPIndex] = JPHigh$JPLow[JPIndex] = JPLow$Offset[JPIndex] = OffsetJPActive = 0JPIndex = JPIndex + 1EndifEndif///////////////////////////////// Previous Sessions drawing /////////////////////////////////If Sessions2Show > 0 then// EUROPE Session //If ShowEuropeSession and EUIndex > 0 thenEUSessions2Draw = Max(0,Sessions2Show-EUActive)EUFirstSession = Max(0,EUIndex-Min(EUSessions2Draw,EUIndex))For i = EUIndex-1 downto EUFirstSession doIf ShowMedianPrice thenEUMedian = ($EUHigh[i]+$EULow[i])/2Drawsegment($EUBegin[i],EUMedian,$EUEnd[i],EUMedian) style(line,3) coloured("royalblue",200)EndifIf ShowMeanPrice thendelay = 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)EndifIf ShowVWAP thendelay = Barindex-$EUBegin[i]PreviousEUVWAP = typicalprice[delay]For k = $EUBegin[i]+1 to $EUEnd[i] dodelay = barindex-klength = k-$EUBegin[i]If volume[delay]>0 thenEUVWAP = SUMMATION[length](volume[delay]*typicalprice[delay])/SUMMATION[length](volume[delay])Drawsegment(k-1,PreviousEUVWAP,k,EUVWAP) style(line,3) coloured("royalblue",200)PreviousEUVWAP = EUVWAPEndifNextEndifIf ShowTrendLine thendelay = 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)EndifDrawrectangle($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)NextEndif// New York Session //If ShowNewYorkSession and NYIndex > 0 thenNYSessions2Draw = Max(0,Sessions2Show-NYActive)NYFirstSession = Max(0,NYIndex-Min(NYSessions2Draw,NYIndex))For i = NYIndex-1 downto NYFirstSession doIf ShowMedianPrice thenNYMedian = ($NYHigh[i]+$NYLow[i])/2Drawsegment($NYBegin[i],NYMedian,$NYEnd[i],NYMedian) style(line,3) coloured("tomato",200)EndifIf ShowMeanPrice thendelay = 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)EndifIf ShowVWAP thendelay = Barindex-$NYBegin[i]PreviousNYVWAP = typicalprice[delay]For k = $NYBegin[i]+1 to $NYEnd[i] dodelay = barindex-klength = k-$NYBegin[i]If volume[delay]>0 thenNYVWAP = SUMMATION[length](volume[delay]*typicalprice[delay])/SUMMATION[length](volume[delay])Drawsegment(k-1,PreviousNYVWAP,k,NYVWAP) style(line,3) coloured("tomato",200)PreviousNYVWAP = NYVWAPEndifNextEndifIf ShowTrendLine thendelay = 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)EndifDrawrectangle($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)NextEndif// TOKYO Session //If ShowTokyoSession and JPIndex > 0 thenJPSessions2Draw = Max(0,Sessions2Show-JPActive)JPFirstSession = Max(0,JPIndex-Min(JPSessions2Draw,JPIndex))For i = JPIndex-1 downto JPFirstSession doIf ShowMedianPrice thenJPMedian = ($JPHigh[i]+$JPLow[i])/2Drawsegment($JPBegin[i],JPMedian,$JPEnd[i],JPMedian) style(line,3) coloured("mediumvioletred",200)EndifIf ShowMeanPrice thendelay = 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)EndifIf ShowVWAP thendelay = Barindex-$JPBegin[i]PreviousJPVWAP = typicalprice[delay]For k = $JPBegin[i]+1 to $JPEnd[i] dodelay = barindex-klength = k-$JPBegin[i]If volume[delay]>0 thenJPVWAP = SUMMATION[length](volume[delay]*typicalprice[delay])/SUMMATION[length](volume[delay])Drawsegment(k-1,PreviousJPVWAP,k,JPVWAP) style(line,3) coloured("mediumvioletred",200)PreviousJPVWAP = JPVWAPEndifNextEndifIf ShowTrendLine thendelay = 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)EndifDrawrectangle($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)NextEndifEndifReturn3 users thanked author for this post.
12/13/2023 at 10:13 AM #225184Lucas, 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.
1 user thanked author for this post.
12/13/2023 at 10:29 AM #225187Hello 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 ?
12/13/2023 at 10:36 AM #225188https://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 ?
12/13/2023 at 10:55 AM #22519112/13/2023 at 11:16 AM #22519512/13/2023 at 11:26 AM #22519712/13/2023 at 1:04 PM #225214I 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.12/13/2023 at 1:07 PM #225218Dax 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. 🙂
12/13/2023 at 1:10 PM #225220Maybe 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 ?
-
AuthorPosts
Find exclusive trading pro-tools on