Title: | Point and Figure Package |
---|---|
Description: | A set of functions to analyze and print the development of a commodity using the Point and Figure (P&F) approach. A P&F processor can be used to calculate daily statistics for the time series. These statistics can be used for deeper investigations as well as to create plots. Plots can be generated as well known X/O Plots in plain text format, and additionally in a more graphical format. |
Authors: | Sascha Herrmann |
Maintainer: | Sascha Herrmann <[email protected]> |
License: | GPL-3 |
Version: | 1.0.5 |
Built: | 2024-12-18 06:53:40 UTC |
Source: | CRAN |
rpnf is a tool set to create and analyze Point & Figure Charts for given time series or data frame objects.
Sascha Herrmann [email protected]
Project Home Page http://rpnf.r-forge.r-project.org
Dorsey, Thomas J. Point and Figure Charting: The Essential Application for Forecasting and Tracking Market Prices. 3rd ed. Wiley Trading. Hoboken, N.J: John Wiley & Sons, 2007.
German version, which is the base for the package: Dorsey, Thomas. Sicher anlegen mit point & figure: klare Signale mit einfachen Methoden. Munich: FinanzBuch-Verl., 2000.
# Load rpnf library library(rpnf) # Load free available sample data data(DOW) # Determine point and figure informations for a linear chart with boxsize of 1 point pnfdata <- pnfprocessor( high=DOW$High, low=DOW$Low, date=DOW$Date, boxsize=1L, log=FALSE) # Show the object obtained str(pnfdata) # Show the data obtained pnfdata # Create a TXT based plot with X and O's pnfplottxt(pnfdata,boxsize=1L,log=FALSE) # Create a more graphical plot pnfplot(pnfdata) ## Not run: ### Second example: logarithmc example # For most stocks and indices it is useful # to do the analysis on a logarithmic scale. # This can be done with pnfprocessor, too. # Ensure to make use of the getLogBoxsize() function # for an appropriate boxsize of a logarithmic chart. # Determine point and figure informations for a logarithmic chart with boxsize 2\% symbol.pnf <- pnfprocessor( high=DOW$High, low=DOW$Low, date=DOW$Date, boxsize=getLogBoxsize(2), log=TRUE) # View the result tail(symbol.pnf) #View(symbol.pnf) # or plot it as a modern chart pnfplot(symbol.pnf,main="P&F Plot DOW (log)") # Or in the old traditional TXT style pnfplottxt(symbol.pnf,boxsize=getLogBoxsize(2),log=TRUE,main="P&F Plot DOW (log)") ### Additional examples # Examples for additional uses cases like # - relative strength vs index # - bullish percent of an index # - and many others # can be found in your local package library directory. # Search for rpnf-example1.R, rpnf-example2.R and so on. ## End(Not run)
# Load rpnf library library(rpnf) # Load free available sample data data(DOW) # Determine point and figure informations for a linear chart with boxsize of 1 point pnfdata <- pnfprocessor( high=DOW$High, low=DOW$Low, date=DOW$Date, boxsize=1L, log=FALSE) # Show the object obtained str(pnfdata) # Show the data obtained pnfdata # Create a TXT based plot with X and O's pnfplottxt(pnfdata,boxsize=1L,log=FALSE) # Create a more graphical plot pnfplot(pnfdata) ## Not run: ### Second example: logarithmc example # For most stocks and indices it is useful # to do the analysis on a logarithmic scale. # This can be done with pnfprocessor, too. # Ensure to make use of the getLogBoxsize() function # for an appropriate boxsize of a logarithmic chart. # Determine point and figure informations for a logarithmic chart with boxsize 2\% symbol.pnf <- pnfprocessor( high=DOW$High, low=DOW$Low, date=DOW$Date, boxsize=getLogBoxsize(2), log=TRUE) # View the result tail(symbol.pnf) #View(symbol.pnf) # or plot it as a modern chart pnfplot(symbol.pnf,main="P&F Plot DOW (log)") # Or in the old traditional TXT style pnfplottxt(symbol.pnf,boxsize=getLogBoxsize(2),log=TRUE,main="P&F Plot DOW (log)") ### Additional examples # Examples for additional uses cases like # - relative strength vs index # - bullish percent of an index # - and many others # can be found in your local package library directory. # Search for rpnf-example1.R, rpnf-example2.R and so on. ## End(Not run)
Returns the lower bound value for a given boxnumber
box2lower(boxnumber, boxsize = 1, log = FALSE)
box2lower(boxnumber, boxsize = 1, log = FALSE)
boxnumber |
An integer boxnumber |
boxsize |
single numeric value, used as the boxsize |
log |
TRUE, if logarithmic scales should be used |
Returns the upper bound value for a given boxnumber
box2upper(boxnumber, boxsize = 1, log = FALSE)
box2upper(boxnumber, boxsize = 1, log = FALSE)
boxnumber |
An integer boxnumber |
boxsize |
single numeric value, used as the boxsize |
log |
TRUE, if logarithmic scales should be used |
This function identifies chart signals in an [0,100]-Points Bullish Percent Chart
bp.signalprocessor(data)
bp.signalprocessor(data)
data |
Input data |
Identifiy for a given P&F Table the current vertical price objective triggered by the last signal reversal.
currentVPOBreakoutMethod(data, reversal, boxsize, log)
currentVPOBreakoutMethod(data, reversal, boxsize, log)
data |
Input data |
reversal |
Number of boxes for reversal |
boxsize |
Size of one box |
log |
Use logarithmic scale |
Identifiy for a given P&F Table the current vertical price objective triggered by the last signal reversal.
currentVPOReversalMethod(data, reversal, boxsize, log)
currentVPOReversalMethod(data, reversal, boxsize, log)
data |
Input data |
reversal |
Number of boxes for reversal |
boxsize |
Size of one box |
log |
Use logarithmic scale |
returns true if given column c matches exactly previous column of same type (this is always column c-2)
doubleBottom(redData, column)
doubleBottom(redData, column)
redData |
Data to consider |
column |
Column to consider |
Returns true if given column c matches exactly previous column of same type (this is always column c-2)
doubleTop(redData, column)
doubleTop(redData, column)
redData |
Data to consider |
column |
Column to consider |
End of day open, high, low, close and volume, dividends and splits, and split/dividend adjusted open, high, low close and volume for Dow Chemical Company (The) (DOW). Data are freely available at https://www.quandl.com/data/WIKI/DOW, and may be copy, distribute, disseminate or include the data in other products for commercial and/or noncommercial purposes. This data is part of Quandl's Wiki initiative to get financial data permanently into the public domain. Quandl relies on users like you to flag errors and provide data where data is wrong or missing. Get involved: [email protected]
Sascha Herrmann [email protected]
https://www.quandl.com/data/WIKI/DOW
Returns true if given column c drops below prevois column of same type (this is always column c-2)
fallingBottom(redData, column)
fallingBottom(redData, column)
redData |
Data to consider |
column |
Column to consider |
returns true if given column c drops below previous column of same type (this is always column c-2)
fallingTop(redData, column)
fallingTop(redData, column)
redData |
Data to consider |
column |
Column to consider |
This function returns an appropriate boxsize if you want to do your point and figure analysis with an logarithmic scale.
getLogBoxsize(percent)
getLogBoxsize(percent)
percent |
a numeric value defining the percent |
a numeric value which is equivalent to the percental change given on a logarithmic scale
# apply it with pnfprocessor library(rpnf) # Load rpnf library data(DOW) # Load some example data # return appropriate value for 1% boxsize getLogBoxsize(percent=1) pnfprocessor( high=DOW$High, low=DOW$Low, date=DOW$Date, boxsize=getLogBoxsize(percent=1), log=TRUE)
# apply it with pnfprocessor library(rpnf) # Load rpnf library data(DOW) # Load some example data # return appropriate value for 1% boxsize getLogBoxsize(percent=1) pnfprocessor( high=DOW$High, low=DOW$Low, date=DOW$Date, boxsize=getLogBoxsize(percent=1), log=TRUE)
Returns the maximum box number in given column
maxBox(redData, column)
maxBox(redData, column)
redData |
Data to consider |
column |
Column to consider |
Returns the minimum box number in given column
minBox(redData, column)
minBox(redData, column)
redData |
Data to consider |
column |
Column to consider |
Note: offset should only be used for reversal calculation
nextBox(quote, status, boxsize = 1, log = FALSE)
nextBox(quote, status, boxsize = 1, log = FALSE)
quote |
A single quote or a vector of quotes. |
status |
A single character indicating the current XO-status. |
boxsize |
A single numeric value, indicating the boxsize to be considered. |
log |
TRUE, if logarithmic scales should be used. |
Determine the next reversal frontier for current quote(s) given a recent XO-status.
nextReversal(quote, status, reversal = 3L, boxsize = 1, log = FALSE)
nextReversal(quote, status, reversal = 3L, boxsize = 1, log = FALSE)
quote |
A single quote or a vector of quotes. |
status |
A single character indicating the current XO-status. |
reversal |
number of boxes needed to make a reversal |
boxsize |
A single numeric value, indicating the boxsize to be considered. |
log |
TRUE, if logarithmic scales should be used. |
Generate a modern point and figure plot
pnfplot(data, reversal = 3, boxsize = 1, log = FALSE, ...)
pnfplot(data, reversal = 3, boxsize = 1, log = FALSE, ...)
data |
a data frame object containing point and figure informations to be plotted |
reversal |
number of boxes used in pnfprocessor |
boxsize |
the boxsize used in pnfprocessor |
log |
are calculations done in logarithmic mode |
... |
any additional options for the plot command |
http://rpnf.r-forge.r-project.org
library(rpnf) # Load rpnf library data(DOW) # (Offline) Load free available sample data from https://www.quandl.com/data/WIKI/DOW pnfdata <- pnfprocessor( high=DOW$High, low=DOW$Low, date=DOW$Date, boxsize=1L, log=FALSE) pnfplot(pnfdata,boxsize=1L,log=FALSE)
library(rpnf) # Load rpnf library data(DOW) # (Offline) Load free available sample data from https://www.quandl.com/data/WIKI/DOW pnfdata <- pnfprocessor( high=DOW$High, low=DOW$Low, date=DOW$Date, boxsize=1L, log=FALSE) pnfplot(pnfdata,boxsize=1L,log=FALSE)
THIS FUNCTION IS STILL UNDER DEVELOPMENT, THEREFORE IT MIGHT BE SUBJECT TO CHANGE!
pnfplottxt(data, reversal = 3, boxsize = 1, log = FALSE, main = NULL, sub = NULL)
pnfplottxt(data, reversal = 3, boxsize = 1, log = FALSE, main = NULL, sub = NULL)
data |
a data frame object containing point and figure informations to be plotted |
reversal |
number of boxes used in pnfprocessor |
boxsize |
the boxsize used in pnfprocessor |
log |
are calculations done in logarithmic mode |
main |
a string used as a main title of the chart |
sub |
a string used as a sub title of the chart |
http://rpnf.r-forge.r-project.org
library(rpnf) # Load rpnf library data(DOW) # (Offline) Load free available sample data from https://www.quandl.com/data/WIKI/DOW pnfdata <- pnfprocessor( high=DOW$High, low=DOW$Low, date=DOW$Date, boxsize=1L, log=FALSE) pnfplottxt(pnfdata,boxsize=1L,log=FALSE)
library(rpnf) # Load rpnf library data(DOW) # (Offline) Load free available sample data from https://www.quandl.com/data/WIKI/DOW pnfdata <- pnfprocessor( high=DOW$High, low=DOW$Low, date=DOW$Date, boxsize=1L, log=FALSE) pnfplottxt(pnfdata,boxsize=1L,log=FALSE)
Please ensure that high, low and date are all ordered according to the Date column.
pnfprocessor(high, low = high, date, reversal = 3L, boxsize = 1L, log = FALSE, style = "xo")
pnfprocessor(high, low = high, date, reversal = 3L, boxsize = 1L, log = FALSE, style = "xo")
high |
a vector containing the high quotes |
low |
a (optional) vector containing the low quotes |
date |
a vector of dates the quotes belong |
reversal |
number of boxes needed to make a reversal |
boxsize |
the boxsize to be used |
log |
should we do the calculations on a logarithmic scale |
style |
the style the pnfprocessor is working with. Can be {xo,rs,bp}. |
returns a data table with all point and figure information in it
http://rpnf.r-forge.r-project.org
library(rpnf) # Load rpnf library data(DOW) # (Offline) Load free available sample data from https://www.quandl.com/data/WIKI/DOW pnfdata <- pnfprocessor( high=DOW$High, low=DOW$Low, date=DOW$Date, boxsize=1L, log=FALSE) pnfdata
library(rpnf) # Load rpnf library data(DOW) # (Offline) Load free available sample data from https://www.quandl.com/data/WIKI/DOW pnfdata <- pnfprocessor( high=DOW$High, low=DOW$Low, date=DOW$Date, boxsize=1L, log=FALSE) pnfdata
Converts a single or a vector of quotes into integer boxnumbers for P&F-Analysis.
quote2box(quote, boxsize = 1, log = FALSE)
quote2box(quote, boxsize = 1, log = FALSE)
quote |
a single quote, or a vector of quotes |
boxsize |
single numeric value, used as the boxsize |
log |
TRUE, if logarithmic scales should be used |
a single or a vector of integer boxnumbers This function transforms a given quote into an unique integer box number
Determines the boxnumber for a given tuple of quotes,status,boxsize and log.
quoteToBoxnumber(quote, status, boxsize, log)
quoteToBoxnumber(quote, status, boxsize, log)
quote |
a numeric vector of quotes |
status |
current status, either "X" or "O" |
boxsize |
boxsize |
log |
use log scale, either TRUE or FALSE |
a vector of integer boxnumbers
Scales a quote. In case log==TRUE this is logarithmic scale, original scale otherwise.
quoteToScale(x, log)
quoteToScale(x, log)
x |
a numeric vector of quotes |
log |
TRUE or FALSE |
scaled quote
returns true if given column c exceeds prevois column of same type (this is always column c-2)
raisingBottom(redData, column)
raisingBottom(redData, column)
redData |
Data to consider |
column |
Column to consider |
Returns true if given column c exceeds previous column of same type (this is always column c-2)
raisingTop(redData, column)
raisingTop(redData, column)
redData |
Data to consider |
column |
Column to consider |
Finding the appropriate trendlines is explained very good at http://stockcharts.com/school/doku.php?id=chart_school:chart_analysis:pnf_charts:pnf_trendlines.
rs.signal.processor(data)
rs.signal.processor(data)
data |
Input data |
http://stockcharts.com/school/doku.php?id=chart_school:chart_analysis:pnf_charts:pnf_trendlines
Rescales a scaled quote to original scale.
scaleToQuote(x, log)
scaleToQuote(x, log)
x |
a numeric vector of scaled quotes |
log |
TRUE or FALSE |
scaled quote
analyze transitions of signal states
signalanalyzer(signal, probability = TRUE)
signalanalyzer(signal, probability = TRUE)
signal |
Signal to identify |
probability |
Report probability |
Finding the appropriate price objectives has been explained very good at http://stockcharts.com/school/doku.php?id=chart_school:chart_analysis:point_and_figure_pri, but this documentation is no longer available. The function adds columns vpo_bm_boxnumber and vpo_bm_price to the given P&F Table. vpo_bm_bonumber contains the boxnumber of the price objective, while vpo_bm_price contains the real price objective.
xo.priceobjective.processor(data, reversal, boxsize, log)
xo.priceobjective.processor(data, reversal, boxsize, log)
data |
Input data |
reversal |
Number of boxes for reversal |
boxsize |
Size of one box |
log |
Use logarithmic scale |
Analyzes a given PNF time-series for Buy&Sell patterns
xo.signalprocessor(data, reversal = 3)
xo.signalprocessor(data, reversal = 3)
data |
Input data |
reversal |
Number of boxes for reversal |