Sessions on Chart
- This topic has 1 reply, 2 voices, and was last updated 4 years ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
Similar topics:
Forums › ProRealTime English forum › ProBuilder support › Sessions on Chart
Hi, I was looking for an indicator that visualize the London and US session (open/ close times) with a vertical color zone. I found exactly what I was looking for on Tradingview. https://www.tradingview.com/script/nY823NXq-Sessions-on-Chart/
Is there anybody with enough technical knowledge to translate this indicator to a PRT (V11) version?
The included code below is the tradingview code!
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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
//@version=4 study("Sessions", overlay=true) bgColor = input(title="Activate High/Low View", type=input.bool, defval=false) LondonColor = color.green NYColor = color.red AsiaColor = color.yellow SydneyColor = color.navy ///Sessions res = input(title="Resolution", type=input.resolution, defval="D", options=["D","W","M"]) london = input(title="London Session", type=input.session, defval="0300-1200") ny = input(title="New York Session", type=input.session, defval="0800-1700") tokyo = input(title="Tokyo Session", type=input.session, defval="2000-0215") sydney = input(title="Sydney Session", type=input.session, defval="1700-0200") //Bars is_newbar(sess) => t = time(res, sess) na(t[1]) and not na(t) or t[1] < t is_session(sess) => not na(time(timeframe.period, sess)) //London London = input(title="London Session", type=input.bool, defval=true) londonNewbar = is_newbar(london) londonSession = is_session(london) float londonLow = na londonLow := if londonSession if londonNewbar low else min(londonLow[1],low) else londonLow[1] float londonHigh = na londonHigh := if londonSession if londonNewbar high else max(londonHigh[1],high) else londonHigh[1] plotLL = plot(londonLow, transp = 100) plotLH = plot(londonHigh, transp = 100) fill(plotLL, plotLH, color = londonSession and London and bgColor ? LondonColor : na) bgcolor(londonSession and London and not bgColor ? LondonColor : na) //New York NY = input(title="New York Session", type=input.bool, defval=true) nyNewbar = is_newbar(ny) nySession = is_session(ny) float nyLow = na nyLow := if nySession if nyNewbar low else min(nyLow[1],low) else nyLow[1] float nyHigh = na nyHigh := if nySession if nyNewbar high else max(nyHigh[1],high) else nyHigh[1] plotNYL = plot(nyLow, transp = 100) plotNYH = plot(nyHigh, transp = 100) fill(plotNYL, plotNYH, color = nySession and NY and bgColor ? color.red : na) bgcolor(nySession and NY and not bgColor ? NYColor : na) //Tokyo Tokyo = input(title="Tokyo Session", type=input.bool, defval=true) tokyoNewbar = is_newbar(tokyo) tokyoSession = is_session(tokyo) float tokyoLow = na tokyoLow := if tokyoSession if tokyoNewbar low else min(tokyoLow[1],low) else tokyoLow[1] float tokyoHigh = na tokyoHigh := if tokyoSession if tokyoNewbar high else max(tokyoHigh[1],high) else tokyoHigh[1] plotTL = plot(tokyoLow, transp = 100) plotTH = plot(tokyoHigh, transp = 100) fill(plotTL, plotTH, color = tokyoSession and Tokyo and bgColor ? color.yellow : na) bgcolor(tokyoSession and Tokyo and not bgColor ? AsiaColor : na) //Tokyo Sydney = input(title="Sydney Session", type=input.bool, defval=false) sydneyNewbar = is_newbar(sydney) sydneySession = is_session(sydney) float sydneyLow = na sydneyLow := if sydneySession if sydneyNewbar low else min(sydneyLow[1],low) else sydneyLow[1] float sydneyHigh = na sydneyHigh := if sydneySession if sydneyNewbar high else max(sydneyHigh[1],high) else sydneyHigh[1] plotSL = plot(sydneyLow, transp = 100) plotSH = plot(sydneyHigh, transp = 100) fill(plotSL, plotSH, color = sydneySession and Sydney and bgColor ? color.navy : na) bgcolor(sydneySession and Sydney and not bgColor ? SydneyColor : na) |
I wrote this code for the Asian session, but it can easily modified to accomodate other sessions.
You can remove the part where the highest high and lowest low are detected and plotted.
https://www.prorealcode.com/reply/66423/
Find exclusive trading pro-tools on