Advertisement
PineCoders

Thirteen Friends

Feb 20th, 2020
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. // LOVE JOY PEACE PATIENCE KINDNESS GOODNESS FAITHFULNESS GENTLENESS SELF-CONTROL
  2. // © JoshuaMcGowan
  3.  
  4. //@version=4
  5. // Murat Notes: Calculate the volume from the core trading session opening 9.30-9.45 EST of the last 30 days. Build an average. This is the relative volume= RVol
  6. // Than look for the volume opening of the day. If it is 20% above the the Rvol it is a trending market. Means support and resistance levels rarely will hold. a break out or flush through resistance levels are quite probable.
  7. // in a range of +20%- -20% it is a normal trading day.
  8. // If opening volume is under 20% than it will probably be a ranging market (inside day, so inside last days volume area.)
  9.  
  10. study("Thirteen Friends - Relative Volume", overlay = false, format = format.volume, max_bars_back = 5000)
  11.  
  12. sessions = input(30, "Quantity of sessions back")
  13. timeSession = input("0930-0945", type = input.session)
  14. inSession = time(timeframe.period, timeSession)
  15.  
  16. sessionBeginning = inSession and not inSession[1]
  17.  
  18. f_avgBarsBetweenCondition(_cond) =>
  19. b = barssince(_cond)
  20. cumTotal = cum(b == 0 ? b[1] + 1 : 0)
  21. cumCount = cum(b == 0 ? 1 : 0)
  22. cumTotal / cumCount
  23.  
  24. f_sum(src,p) => a = cum(src), a - a[max(p,0)]
  25.  
  26. // Avg
  27. avgBarsBetweenSessions = f_avgBarsBetweenCondition(sessionBeginning)
  28. totVolume = f_sum(sessionBeginning ? volume : 0, sessions * avgBarsBetweenSessions + 1)
  29. totOccurrences = f_sum(sessionBeginning ? 1 : 0, sessions * avgBarsBetweenSessions + 1)
  30. avgVol = totVolume / totOccurrences
  31. plot(avgVol, "avgVol")
  32. plotchar(sessionBeginning, "sessionBeginning", "▲", location.top)
  33. plotchar(totVolume, "totVolume", "", location.top)
  34. plotchar(totOccurrences, "totOccurrences", "", location.top)
  35. plotchar(avgBarsBetweenSessions, "avgBarsBetweenSessions", "", location.top)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement