Guest User

Untitled

a guest
Jul 15th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. # Packages
  2. using Indicators
  3.  
  4. # Build H L C matrix
  5. h = data1_h
  6. l = data1_l
  7. c = data1_c
  8. m = Array{Float64}(zeros(length(data1_c),0))
  9. m = hcat(m,h)
  10. m = hcat(m,l)
  11. m = hcat(m,c)
  12.  
  13. # True Range
  14. t_r = tr(m)
  15.  
  16. # Function for adjusting the price by a % of the true range
  17. noise_perc = function(x::Array{Float64}; perc::Float64=.4)
  18. noise_out = zeros(t_r)
  19. for i =1:size(t_r,1)
  20. if isnan(t_r[i]) == 0
  21. percs = (perc* (t_r[i]))
  22. pos_range = collect(0.0:.25:percs)
  23. neg_range = -(pos_range)
  24. all_range = vcat(pos_range,neg_range)
  25. noise_out[i] = (x[i]) + sample(all_range) # sample() to choose a random number between 0 and up perc= maximum
  26. else
  27. noise_out[i] = 0
  28. end
  29. end
  30. return noise_out
  31. end
  32.  
  33. # Run function
  34. # perc= sets the maximum % to adjust the prices by
  35. noise_perc(data1_c,perc=.4)
Add Comment
Please, Sign In to add comment