SHARE
TWEET

info label v1

memer1952 Sep 22nd, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //@version=4
  2.  
  3. study(title="info label", shorttitle="info label", overlay=true)
  4. src = close
  5. PI = 3.14159265359
  6. s2 = 0.0
  7. s3 = 0.0
  8. delta = 0.0
  9. inst = 0.0
  10. len = 0.0
  11. v1 = 0.0
  12. v2 = 0.0
  13. v4 = 0.0
  14.  
  15. v1 := close - close[7]
  16. s2 := 0.2*(v1[1] + v1)*(v1[1] + v1) + 0.8*nz(s2[1])
  17. s3 := 0.2*(v1[1] - v1)*(v1[1] - v1) + 0.8*nz(s3[1])
  18. if (s2 != 0)
  19.     v2 := sqrt(s3/s2)
  20. if (s3 != 0)
  21.     delta := 2*atan(v2)
  22. for i = 0 to 100
  23.     v4 := v4 + delta[i]
  24.     if (v4 > 2*PI and inst == 0.0)
  25.         inst := i - 1
  26. if (inst == 0.0)
  27.     inst := inst[1]
  28. len := 0.25*inst + 0.75*nz(len[1])
  29.  
  30. //
  31.  
  32. _len = input(5)
  33. mean = sma(close, _len)
  34. meanadj = close - mean
  35. z = cum(meanadj)
  36. range = highest(z, _len) - lowest(z, _len)
  37. stdev = stdev(meanadj, _len)
  38. rescaledrange = log(range / stdev)
  39.  
  40.  
  41. sum_x = _len * (_len + 1) / 2
  42. sum_y = float(0)
  43. sum_xy = float(0)
  44. xyproductsum = 0
  45. sum_xx = 0
  46. for _i = 1 to _len by 1
  47.     sum_y := sum_y + rescaledrange[_i]
  48.     sum_xy := _i * rescaledrange[_i] + sum_xy
  49.     sum_xx := _i * _i + sum_xx
  50.     sum_xx
  51. m = (_len * sum_xy - sum_x * sum_y) / (_len * sum_xx - sum_x * sum_x)
  52. b = sum_y / _len - m * sum_x / _len
  53. H = 0.5 + sma(rescaledrange - b, _len)
  54.  
  55. //
  56.  
  57. Price = hl2
  58. Imult = float(0.635)
  59. Qmult = float(0.338)
  60. InPhase = float(0.0)
  61. Quadrature = float(0.0)
  62. Amplitude = float(0.0)
  63. Range = float(0.0)
  64. Value2 = float(0.0)
  65.  
  66. if(bar_index>8)
  67.     var Value1 = Price - Price[7]
  68.     Range := .2*(high - low) + .8*nz(Range[1])
  69.     InPhase := 1.25*(Value1[4] - Imult*Value1[2]) + Imult*nz(InPhase[3])
  70.     Quadrature := Value1[2] - Qmult*Value1 + Qmult*nz(Quadrature[2])
  71.     Value2 := .2*(InPhase*InPhase + Quadrature*Quadrature) + .8*nz(Value2[1])
  72.     if(Value2 < .001)
  73.         Value2 := .001
  74.     if(Range > 0)
  75.         Amplitude := .25*(10*log(Value2/(Range*Range))/log(10) + 9) + .75*nz(Amplitude[1])
  76.  
  77.  
  78. isless = Amplitude < Amplitude[1] ? true : false
  79. //plot(series=barssince(isless)*1, title="Consecutive Bars Down", linewidth=2)
  80.  
  81. yeet = barssince(isless)*1
  82.  
  83. //
  84.  
  85. rsi = rsi(close,5)
  86. cci = cci(close,5)
  87.  
  88. labelText =  ""
  89. stats =  "\nSNR:Ratio: " + tostring(yeet, '#.##') +
  90.          "\nH-Exponent: " + tostring(H, '#.##') +
  91.          "\nCosine IFM: " + tostring(len, '#.##')
  92. labelColor = color.white
  93. whiteColor = color.black
  94.  
  95. var label pnfLabel = label.new(
  96.      x=bar_index,
  97.      y=na,
  98.      text="",
  99.      color=labelColor,
  100.      textcolor=whiteColor,
  101.      style=label.style_labeldown,
  102.      size=size.normal
  103.      )
  104.  
  105. label.set_text(pnfLabel, stats)
  106. label.set_xy(pnfLabel, bar_index, highest(close, 10))
  107.  
  108.  
  109.  
  110.  
  111. stats1 = "\nRSI(5): " + tostring(rsi, '#.##') +
  112.          "\nCCI(5): " + tostring(cci, '#.##')
  113. labelColor1 = color.white
  114. whiteColor1 = color.black
  115.  
  116. var label pnfLabel1 = label.new(
  117.      x=bar_index,
  118.      y=na,
  119.      text="",
  120.      color=labelColor1,
  121.      textcolor=whiteColor1,
  122.      style=label.style_labelup,
  123.      size=size.normal
  124.      )
  125.  
  126. label.set_text(pnfLabel1, stats1)
  127. label.set_xy(pnfLabel1, bar_index, lowest(close, 10))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top