xmd79

CC Sessions

Apr 30th, 2023
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. // © CryptoCurl
  2.  
  3. //@version=5
  4. indicator('CC Sessions', overlay=true)
  5.  
  6. timeinrange(res, sess) =>
  7. time(res, sess) != 0
  8.  
  9. iKZNY = input(true, title='New York')
  10. iOpenKZLondon = input(true, title='London')
  11. iAsiaKZ = input(true, title='Asia')
  12. iClose = input(true, title='Close')
  13.  
  14. AsiaKZ = input('0000-0559:1234567', title='Asia')
  15. LondonOpenKZ = input('0600-1159:1234567', title='London')
  16. KZNY = input('1200-1959:1234567', title='New York')
  17. closeKZ = input('2000-2359:1234567', title='Close')
  18.  
  19. onlyLastperiode = input(title='show only last periode', defval=true)
  20.  
  21.  
  22. OnePeriod() =>
  23. timeframe.ismonthly ? 40320 * timeframe.multiplier : timeframe.isweekly ? 10080 * timeframe.multiplier : timeframe.isdaily ? 1440 * timeframe.multiplier : timeframe.multiplier
  24. bgOffset = 1440 / OnePeriod() == math.floor(1440 / OnePeriod()) ? 1440 / OnePeriod() : 0
  25.  
  26.  
  27. asia = time(timeframe.period, AsiaKZ)
  28. london = time(timeframe.period, LondonOpenKZ)
  29. ny = time(timeframe.period, KZNY)
  30. closeSession = time(timeframe.period, closeKZ)
  31.  
  32. closeTime = request.security(syminfo.tickerid, 'D', time_close[0], lookahead=barmerge.lookahead_on)
  33.  
  34. //closeTime is in ms; bgOffset in minutes
  35. paintitNot = timenow > closeTime + 24 * 60 * 1000 * 60
  36.  
  37. bgcolor(iAsiaKZ and not na(asia) ? onlyLastperiode and paintitNot ? na : color.yellow : na, offset=bgOffset, transp=95)
  38. bgcolor(iAsiaKZ and not na(asia) ? onlyLastperiode and paintitNot ? na : color.yellow : na, transp=95)
  39. bgcolor(iOpenKZLondon and na(asia) and not na(asia[1]) ? onlyLastperiode and paintitNot ? na : color.green : na, offset=bgOffset, transp=70)
  40. bgcolor(iOpenKZLondon and na(asia) and not na(asia[1]) ? onlyLastperiode and paintitNot ? na : color.green : na, transp=70)
  41. bgcolor(iOpenKZLondon and not na(london) ? onlyLastperiode and paintitNot ? na : color.green : na, offset=bgOffset, transp=95)
  42. bgcolor(iOpenKZLondon and not na(london) ? onlyLastperiode and paintitNot ? na : color.green : na, transp=95)
  43. bgcolor(iKZNY and na(london) and not na(london[1]) ? onlyLastperiode and paintitNot ? na : color.purple : na, offset=bgOffset, transp=70)
  44. bgcolor(iKZNY and na(london) and not na(london[1]) ? onlyLastperiode and paintitNot ? na : color.purple : na, transp=70)
  45. bgcolor(iKZNY and not na(ny) ? onlyLastperiode and paintitNot ? na : color.purple : na, transp=95)
  46. bgcolor(iClose and na(ny) and not na(ny[1]) ? onlyLastperiode and paintitNot ? na : color.white : na, offset=bgOffset, transp=70)
  47. bgcolor(iClose and na(ny) and not na(ny[1]) ? onlyLastperiode and paintitNot ? na : color.white : na, transp=70)
  48. bgcolor(iAsiaKZ and na(closeSession) and not na(closeSession[1]) ? onlyLastperiode and paintitNot ? na : color.yellow : na, offset=bgOffset, transp=70)
  49. bgcolor(iAsiaKZ and na(closeSession) and not na(closeSession[1]) ? onlyLastperiode and paintitNot ? na : color.yellow : na, transp=70)
  50.  
  51.  
Advertisement
Add Comment
Please, Sign In to add comment