Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fractalindicator.up <- function(x) {
- High <- Hi(x); Bars <- nrow(x)
- afFrUp <- rep(NA, Bars)
- for(iBar in seq(8,Bars-2))
- {
- if(High[iBar-1]<High[iBar-2] && High[iBar]<High[iBar-2])
- {
- #Fractal type 1
- if( High[iBar-4]<High[iBar-2] &&
- High[iBar-3]<High[iBar-2] )
- afFrUp[iBar+1]=High[iBar-2];
- }
- }
- names(afFrDn) <- "F.Up"
- }
- fractalindicator.dn <- function(x) {
- Low <- Lo(x); Bars <- nrow(x)
- afFrDn <- rep(NA, Bars)
- for(iBar in seq(8,Bars-2))
- {
- if(Low[iBar-1]>Low[iBar-2] && Low[iBar]>Low[iBar-2])
- {
- #Fractal type 1
- if( Low[iBar-4]>Low[iBar-2] &&
- Low[iBar-3]>Low[iBar-2] )
- afFrDn[iBar+1]=Low[iBar-2];
- }
- }
- names(afFrDn) <- "F.Down"
- }
- #Add indicators
- add.indicator(strategy = "fractal", name = "fractalindicator.up",
- arguments = list(x = quote(mktdata)), label="fractalup")
- #Add indicators
- add.indicator(strategy = "fractal", name = "fractalindicator.dn",
- arguments = list(x = quote(mktdata)), label="fractaldn")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement