Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=4
- study(title="Ichimoku Cloud", shorttitle="Ichimoku", overlay=true)
- usecurrent = input(title="Use Current Time Frame?", defval=true)
- timeFrameX = input(title="Hourly Time Frame (use 24hr chart for daily)", defval=24)
- timeFrame = timeFrameX * 60
- conversionPeriods = input(20, minval=1, title="Conversion Line Periods"),
- basePeriods = input(60, minval=1, title="Base Line Periods")
- laggingSpan2Periods = input(120, minval=1, title="Lagging Span 2 Periods"),
- rawdisplacement = input(30, minval=1, title="Displacement")
- //donchian(len) => avg(security(syminfo.tickerid, tostring(timeFrame), lowest(len)), security(syminfo.tickerid, tostring(timeFrame), highest(len)))
- donchian(len) => avg(lowest(len), highest(len))
- rawconversionLine = donchian(conversionPeriods)
- rawbaseLine = donchian(basePeriods)
- rawleadLine1 = avg(rawconversionLine, rawbaseLine)
- rawleadLine2 = donchian(laggingSpan2Periods)
- conversionLine = usecurrent? rawconversionLine : security(syminfo.tickerid, tostring(timeFrame), rawconversionLine)
- baseLine = usecurrent? rawbaseLine : security(syminfo.tickerid, tostring(timeFrame), rawbaseLine)
- leadLine1 = usecurrent? rawleadLine1 : security(syminfo.tickerid, tostring(timeFrame), rawleadLine1)
- leadLine2 = usecurrent? rawleadLine2 : security(syminfo.tickerid, tostring(timeFrame), rawleadLine2)
- laggingspan = usecurrent? close : security(syminfo.tickerid, tostring(timeFrame), close)
- displacement = usecurrent? rawdisplacement : ((timeFrame / timeframe.multiplier) * rawdisplacement)
- extraoffset = usecurrent? 1 : (timeFrame / timeframe.multiplier)
- plot(conversionLine, color=#0496ff, title="Conversion Line")
- plot(baseLine, color=#991515, title="Base Line")
- plot(laggingspan, offset = (-displacement) + extraoffset, color=#ffeb3b, transp=50, title="Lagging Span") // +1
- p1 = plot(leadLine1, offset = (displacement - extraoffset), color=color.green, title="Lead 1")
- p2 = plot(leadLine2, offset = (displacement - extraoffset), color=color.red, title="Lead 2")
- fill(p1, p2, color = leadLine1 > leadLine2 ? color.green : color.red)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement