R/meanPrice.R

Defines functions getMeanPrice

source("R/dbInterface.R")

getMeanPrice <- function(Symbol, SymbolName)
{
  mePrice <- meanPrice(unlist(strsplit(SymbolName, "[.]"))[1])

  if(is.null(mePrice))
    return(NULL)

  mPrice = xts(rep(mePrice,length(index(Symbol))), index(Symbol))

  assign("mPrice", mPrice, .GlobalEnv)

  col <- 3
  if(as.double(last(Cl(Symbol))) < mePrice)
    col <- 2

  return(sprintf("addTA(mPrice, lwd=1, on=1, col=%d)", col))
}
wanderaraujo/trade-bot-r documentation built on Dec. 24, 2019, 12:17 a.m.