Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7811943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:20:54+00:00 2026-06-02T04:20:54+00:00

I am trying to run the code provided with Data Mining With R book

  • 0

I am trying to run the code provided with Data Mining With R book. It basically takes the quotes data for SP500 index(GSPC) and builds a prediction function (T.ind) to predict the quotes for next n days.

library(DMwR)
#load S&P500 Dataset
data(GSPC)

# Create a Prediction function T based on which Buy / Sell / Hold decision
# will be taken. target variation margin is 2.5%
T.ind <- function(quotes,tgt.margin=0.025,n.days=10) {
  v <- apply(HLC(quotes),1,mean)
  r <- matrix(NA,ncol=n.days,nrow=NROW(quotes))

  for(x in 1:n.days) {
    r[,x] <- Next(Delt(v,k=x),x)
  }

  x <- apply(r,1,function(x) sum(x[x > tgt.margin | x < -tgt.margin]))

  if (is.xts(quotes))
    xts(x,time(quotes))
  else
    x
}

#Plot candle chart for 3 months of Index with Avg. price and Parameter T.
candleChart(last(GSPC,'3 months'),theme='white',TA=NULL)

addAvgPrice <- newTA(FUN=avgPrice,col=1,legend='AvgPrice')
addT.ind <- newTA(FUN=T.ind,col='red',legend='tgtRet')
addT.ind()

My question is how T.ind is called from newTA() function call. How are the values of quotes from selected period passed on to the T.ind function. Please let me know.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T04:20:56+00:00Added an answer on June 2, 2026 at 4:20 am

    It’s quite a bit like lattice or ggolot2 plots but without the “+” signs. However, the operation that is equivalent to “feature addition” is being delivered via side-effects. The plot is not just a 2D display but is also an object in the workspace. When you call addT.ind() its effects are being applied to the currently active chart object that has the data gathered by HLC() in the context of having implicit access to the results of candleChart()’s product.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to run these two .data files from my c++ code for
I am trying to run code on several cores (I tried both the snow
I am trying to run the code below but it keeps locking up my
I'm trying to run this code: let coins = [50, 25, 10, 5, 2,1]
I am trying to run this code: ItemTaxonomy iTaxonomy = from itemTaxonomy in connection.ItemTaxonomy
I am trying to run this code : exec myStoredProcedure Cast('c5b48202-36af-4597-9780-5366d4188f55' AS uniqueidentifier), 744,
I'm trying to run the code from here MDN: Generators and Iterators function fib()
when I trying to run following code. var result = from c in db.brand
Ultimately I am trying to run some code which depends on the value (or
I am getting an error while trying to run CFmx code on a remote

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.