Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2015
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. fractalindicator.up <- function(x) {
  2.  
  3. High <- Hi(x); Bars <- nrow(x)
  4. afFrUp <- rep(NA, Bars)
  5.  
  6. for(iBar in seq(8,Bars-2))
  7. {
  8. if(High[iBar-1]<High[iBar-2] && High[iBar]<High[iBar-2])
  9. {
  10. #Fractal type 1
  11. if( High[iBar-4]<High[iBar-2] &&
  12. High[iBar-3]<High[iBar-2] )
  13. afFrUp[iBar+1]=High[iBar-2];
  14. }
  15. }
  16.  
  17. names(afFrDn) <- "F.Up"
  18. }
  19.  
  20. fractalindicator.dn <- function(x) {
  21.  
  22. Low <- Lo(x); Bars <- nrow(x)
  23. afFrDn <- rep(NA, Bars)
  24.  
  25. for(iBar in seq(8,Bars-2))
  26. {
  27. if(Low[iBar-1]>Low[iBar-2] && Low[iBar]>Low[iBar-2])
  28. {
  29. #Fractal type 1
  30. if( Low[iBar-4]>Low[iBar-2] &&
  31. Low[iBar-3]>Low[iBar-2] )
  32. afFrDn[iBar+1]=Low[iBar-2];
  33. }
  34. }
  35.  
  36. names(afFrDn) <- "F.Down"
  37. }
  38.  
  39. #Add indicators
  40. add.indicator(strategy = "fractal", name = "fractalindicator.up",
  41. arguments = list(x = quote(mktdata)), label="fractalup")
  42.  
  43. #Add indicators
  44. add.indicator(strategy = "fractal", name = "fractalindicator.dn",
  45. arguments = list(x = quote(mktdata)), label="fractaldn")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement