xmd79

Forex/Crypto/Custom Market Sessions v2

Apr 30th, 2023
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.03 KB | None | 0 0
  1. //@version=5
  2. indicator('Forex/Crypto/Custom Market Sessions v2', overlay=true)
  3.  
  4. //credit goes to TradeMasterSavis for providing the original code
  5.  
  6. //MENU/////////////
  7.  
  8. ShowMarketSessions = input(true, title='Show Market Sessions')
  9.  
  10. //Market Sessions
  11.  
  12. MarketSessionsSettings = input.string(title='Market Sessions Settings', defval='ON', options=['ON'])
  13.  
  14. ForexORCrypto = input.string(title='Forex, Crypto, OR Custom Market', defval='Forex', options=['Forex', 'Crypto', 'Custom Market'])
  15.  
  16. Forex = input.string(title='Forex Settings', defval='ON', options=['ON'])
  17.  
  18. /////FOREX/////
  19. //Inputs
  20. Ft1 = input.session(title='Forex Sydney Session (xxxx-xxxx to define a interval):', defval='1700-2000:1234567', confirm=false)
  21. Ft2 = input.session(title='Forex Tokyo Session (xxxx-xxxx to define a interval):', defval='2000-0300:1234567', confirm=false)
  22. Ft3 = input.session(title='Forex London Session (xxxx-xxxx to define a interval):', defval='0300-0800:1234567', confirm=false)
  23. Ft4 = input.session(title='Forex New York Session (xxxx-xxxx to define a interval):', defval='0800-1400:1234567', confirm=false)
  24. Ft5 = input.session(title='NO TRADE ZONE (xxxx-xxxx to define a interval):', defval='1400-1700:1234567', confirm=false)
  25.  
  26. //CryptoSessions
  27. ForexSession1 = ForexORCrypto == 'Forex' ? not na(time('1', Ft1)) : true
  28. ForexSession2 = ForexORCrypto == 'Forex' ? not na(time('1', Ft2)) : true
  29. ForexSession3 = ForexORCrypto == 'Forex' ? not na(time('1', Ft3)) : true
  30. ForexSession4 = ForexORCrypto == 'Forex' ? not na(time('1', Ft4)) : true
  31. ForexSession5 = ForexORCrypto == 'Forex' ? not na(time('1', Ft5)) : true
  32.  
  33. //Plot BGColor
  34. bgcolor(ShowMarketSessions and ForexSession1 and ForexORCrypto == 'Forex' ? color.red : na, title='Forex Sydney Session', transp=75)
  35. bgcolor(ShowMarketSessions and ForexSession2 and ForexORCrypto == 'Forex' ? color.orange : na, title='Forex Tokyo Session', transp=75)
  36. bgcolor(ShowMarketSessions and ForexSession3 and ForexORCrypto == 'Forex' ? color.yellow : na, title='Forex London Session', transp=75)
  37. bgcolor(ShowMarketSessions and ForexSession4 and ForexORCrypto == 'Forex' ? color.green : na, title='Forex New York Session', transp=75)
  38. bgcolor(ShowMarketSessions and ForexSession5 and ForexORCrypto == 'Forex' ? #000000 : na, title='NO TRADE ZONE', transp=0)
  39.  
  40.  
  41. Crypto = input.string(title='Crypto Settings', defval='ON', options=['ON'])
  42.  
  43. /////CRYPTO/////
  44. //Inputs
  45. Ct1 = input.session(title='Crypto Sydney Session (xxxx-xxxx to define a interval):', defval='2100-0000:1234567', confirm=false)
  46. Ct2 = input.session(title='Crypto Tokyo Session (xxxx-xxxx to define a interval):', defval='0000-0800:1234567', confirm=false)
  47. Ct3 = input.session(title='Crypto London Session (xxxx-xxxx to define a interval):', defval='0800-1200:1234567', confirm=false)
  48. Ct4 = input.session(title='Crypto New York Session (xxxx-xxxx to define a interval):', defval='1200-1800:1234567', confirm=false)
  49. Ct5 = input.session(title='NO TRADE ZONE (xxxx-xxxx to define a interval):', defval='1800-2100:1234567', confirm=false)
  50.  
  51. //CryptoSessions
  52. CryptoSession1 = ForexORCrypto == 'Crypto' ? not na(time('1', Ct1)) : true
  53. CryptoSession2 = ForexORCrypto == 'Crypto' ? not na(time('1', Ct2)) : true
  54. CryptoSession3 = ForexORCrypto == 'Crypto' ? not na(time('1', Ct3)) : true
  55. CryptoSession4 = ForexORCrypto == 'Crypto' ? not na(time('1', Ct4)) : true
  56. CryptoSession5 = ForexORCrypto == 'Crypto' ? not na(time('1', Ct5)) : true
  57.  
  58. //Plot BGColor
  59. bgcolor(ShowMarketSessions and CryptoSession1 and ForexORCrypto == 'Crypto' ? color.red : na, title='Crypto Sydney Session', transp=75)
  60. bgcolor(ShowMarketSessions and CryptoSession2 and ForexORCrypto == 'Crypto' ? color.orange : na, title='Crypto Tokyo Session', transp=75)
  61. bgcolor(ShowMarketSessions and CryptoSession3 and ForexORCrypto == 'Crypto' ? color.yellow : na, title='Crypto London Session', transp=75)
  62. bgcolor(ShowMarketSessions and CryptoSession4 and ForexORCrypto == 'Crypto' ? color.green : na, title='Crypto New York Session', transp=75)
  63. bgcolor(ShowMarketSessions and CryptoSession5 and ForexORCrypto == 'Crypto' ? #000000 : na, title='NO TRADE ZONE', transp=0)
  64.  
  65.  
  66. CustomMarket = input.string(title='Custom Settings', defval='ON', options=['ON'])
  67.  
  68. /////CRYPTO/////
  69. //Inputs
  70. CSt1 = input.session(title='Custom Market Session 1 (xxxx-xxxx to define a interval):', defval='0100-0500:1234567', confirm=false)
  71. CSt2 = input.session(title='Custom Market Session 2 (xxxx-xxxx to define a interval):', defval='0500-1200:1234567', confirm=false)
  72. CSt3 = input.session(title='Custom Market Session 3 (xxxx-xxxx to define a interval):', defval='1200-1600:1234567', confirm=false)
  73. CSt4 = input.session(title='Custom Market Session 4 (xxxx-xxxx to define a interval):', defval='1600-2200:1234567', confirm=false)
  74. CSt5 = input.session(title='NO TRADE ZONE (xxxx-xxxx to define a interval):', defval='2200-0100:1234567', confirm=false)
  75.  
  76. //CryptoSessions
  77. CustomMarketSession1 = ForexORCrypto == 'Custom Market' ? not na(time('1', CSt1)) : true
  78. CustomMarketSession2 = ForexORCrypto == 'Custom Market' ? not na(time('1', CSt2)) : true
  79. CustomMarketSession3 = ForexORCrypto == 'Custom Market' ? not na(time('1', CSt3)) : true
  80. CustomMarketSession4 = ForexORCrypto == 'Custom Market' ? not na(time('1', CSt4)) : true
  81. CustomMarketSession5 = ForexORCrypto == 'Custom Market' ? not na(time('1', CSt5)) : true
  82.  
  83. //Plot BGColor
  84. bgcolor(ShowMarketSessions and CustomMarketSession1 and ForexORCrypto == 'Custom Market' ? color.red : na, title='Custom Market Session 1', transp=75)
  85. bgcolor(ShowMarketSessions and CustomMarketSession2 and ForexORCrypto == 'Custom Market' ? color.orange : na, title='Custom Market Session 2', transp=75)
  86. bgcolor(ShowMarketSessions and CustomMarketSession3 and ForexORCrypto == 'Custom Market' ? color.yellow : na, title='Custom Market Session 3', transp=75)
  87. bgcolor(ShowMarketSessions and CustomMarketSession4 and ForexORCrypto == 'Custom Market' ? color.green : na, title='Custom Market Session 4', transp=75)
  88. bgcolor(ShowMarketSessions and CustomMarketSession5 and ForexORCrypto == 'Custom Market' ? #000000 : na, title='NO TRADE ZONE', transp=0)
  89.  
  90.  
Advertisement
Add Comment
Please, Sign In to add comment