Comments (6)
I don't use it for visualization. I use it as a trading indicator. It would
also mean having to extend the xts object, which I'm not quite sure how to
do.
On Sun, Dec 14, 2014 at 8:22 PM, Nash [email protected] wrote:
Using the ichimoku indicator
https://github.com/IlyaKipnis/IKTrading/blob/master/R/ichimoku.R, I am
attempting to plot Ichimoku Cloud, with the below implementation:require(quantmod)
require(IKTrading)
getSymbols('IBM', src='google', from='2014-04-01')
ibm_ic = ichimoku(IBM)
ibm_icPlot <- ibm_ic[,1:5]
chart.TimeSeries(ibm_icPlot, legend.loc = "topleft")After running the above code, all the five lines are rendered in the Chart
(i.e. turning line, base line, Span A, Span B, plotSpan), here's the
screenshot of my RStudio with the plot:Well, the problem is with the 'Span A' & 'Span B' lines (i.e. future
cloud), which are not projected ('nMed=26') into the future. This
projection is very important aspect of visualizing an Ichimoku Cloud in its
entirety. Any suggestion on how to make the ichimoku indicator
https://github.com/IlyaKipnis/IKTrading/blob/master/R/ichimoku.R to
plot the future cloud? Or is there something wrong in the above
implementation?—
Reply to this email directly or view it on GitHub
#3.
from iktrading.
If you are using the ichimoku indicator as a pure trading indicator, the future cloud formation still needs to be inclusive. Because the future cloud helps to determine the market sentiment (i.e. a measure of equilibrium according to Goichi Hosoda), hence this future cloud can signal potential trend reversals that is either bullish or bearish, which can be a viable flag in an Ichimoku based Algo. A brief theory and application of pairing the 'SpanA' & 'SpanB' lines can be found here.
Well, this is my attempt to render the 'Span A' & 'Span B' lines (i.e. future cloud). Now, 'Span A' & 'Span B' lines are projected 26 periods into the future. This was achieved without any data-loss considering how the 'Span A' & 'Span B' data-points are calculated at present in the ichimoku indicator, I presume this data-loss is intentional for 'Span A' & 'Span B'... Is it?
Here's the implementation code & screenshot of the plot:
require(quantmod)
require(IKTrading)
getSymbols('IBM', src='google', from='2014-04-01')
ProjectTimeseriesToFuture <- function(dataset, projectionPeriod) {
extendedIndex <- timeBasedSeq(paste(end(dataset),end(dataset),sep="/"), length.out=projectionPeriod+1)
out <- merge(dataset, xts(, extendedIndex[2:length(extendedIndex)]))
return(out)
}
ichimoku <- function(HLC, nFast=9, nMed=26, nSlow=52) {
turningLine <- (runMax(Hi(HLC), nFast)+runMin(Lo(HLC), nFast))/2
baseLine <- (runMax(Hi(HLC), nMed)+runMin(Lo(HLC), nMed))/2
spanA <- lag(ProjectTimeseriesToFuture((turningLine+baseLine)/2, nMed), nMed)
spanB <- lag(ProjectTimeseriesToFuture((runMax(Hi(HLC), nSlow)+runMin(Lo(HLC), nSlow))/2, nMed), nMed)
plotSpan <- lag(Cl(HLC), -nMed)
out <- cbind(turnLine=turningLine, baseLine=baseLine, spanA=spanA, spanB=spanB, plotSpan=plotSpan)
colnames(out) <- c("turnLine", "baseLine", "spanA", "spanB", "plotLagSpan")
return (out)
}
ibm_ic = ichimoku(IBM)
ibm_icPlot <- ibm_ic[,1:5]
chart.TimeSeries(ibm_icPlot, legend.loc = "topleft")
Comments & suggestions are welcome :)
from iktrading.
Looks good, actually. Thanks a lot =).
On Mon, Dec 15, 2014 at 10:03 PM, Nash [email protected] wrote:
If you are using the ichimoku indicator
https://github.com/IlyaKipnis/IKTrading/blob/master/R/ichimoku.R as a
pure trading indicator, the future cloud formation still needs to be
inclusive. Because the future cloud helps to determine the market sentiment
(i.e. a measure of equilibrium according to Goichi Hosoda), hence this
future cloud can signal potential trend reversals that is either bullish or
bearish, which can be a viable flag in an Ichimoku based Algo. A brief
theory and application of pairing the 'SpanA' & 'SpanB' lines can be found
here
http://www.kumotrader.com/ichimoku_wiki/index.php?title=Ichimoku_components#Senkou_Span_A.Well, this is my attempt to render the 'Span A' & 'Span B' lines (i.e.
future cloud). Now, 'Span A' & 'Span B' lines are projected 26 periods into
the future. This was achieved without any data-loss considering how the
'Span A' & 'Span B' data-points are calculated at present in the ichimoku
indicator
https://github.com/IlyaKipnis/IKTrading/blob/master/R/ichimoku.R, I
presume this data-loss is intentional for 'Span A' & 'Span B'... Is it?Here's the implementation code & screenshot of the plot:
require(quantmod)
require(IKTrading)
getSymbols('IBM', src='google', from='2014-04-01')ProjectTimeseriesToFuture <- function(dataset, projectionPeriod) {
extendedIndex <- timeBasedSeq(paste(end(dataset),end(dataset),sep="/"), length.out=projectionPeriod+1)
out <- merge(dataset, xts(, extendedIndex[2:length(extendedIndex)]))
return(out)
}ichimoku <- function(HLC, nFast=9, nMed=26, nSlow=52) {
turningLine <- (runMax(Hi(HLC), nFast)+runMin(Lo(HLC), nFast))/2
baseLine <- (runMax(Hi(HLC), nMed)+runMin(Lo(HLC), nMed))/2
spanA <- lag(ProjectTimeseriesToFuture((turningLine+baseLine)/2, nMed), nMed)
spanB <- lag(ProjectTimeseriesToFuture((runMax(Hi(HLC), nSlow)+runMin(Lo(HLC), nSlow))/2, nMed), nMed)
plotSpan <- lag(Cl(HLC), -nMed)out <- cbind(turnLine=turningLine, baseLine=baseLine, spanA=spanA, spanB=spanB, plotSpan=plotSpan) colnames(out) <- c("turnLine", "baseLine", "spanA", "spanB", "plotLagSpan") return (out)
}
ibm_ic = ichimoku(IBM)
ibm_icPlot <- ibm_ic[,1:5]
chart.TimeSeries(ibm_icPlot, legend.loc = "topleft")Comments & suggestions are welcome :)
—
Reply to this email directly or view it on GitHub
#3 (comment).
from iktrading.
Hi, @knshetty
When I try your code, I get the following error:
Error in lag(Cl(HLC), -nMed) : n must be a single positive integer
Wonder where did I go wrong?
from iktrading.
I found the issue lied in the order which you load dplyr package and the xts package. See: joshuaulrich/xts#131
The quickest fix I found to be loading xts after or not loading dplyr if you don't have to.
Hope that helps!
from iktrading.
Many thanks. This was most helpful.
from iktrading.
Related Issues (11)
- Installing error HOT 3
- ATR <- stats::lag(ATR, lag)
- Error message on IKTrading Build HOT 1
- Ilyas
- FAAreturns loses date info HOT 2
- Error while installing IKTrading HOT 1
- using sigAND with doParallel results in error when combining HOT 3
- IKTrading and DSTrading installation for R3.3.0 HOT 3
- quandClean
- Can't install IKTrading HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from iktrading.