joshuaulrich / TTR

Technical analysis and other functions to construct technical trading rules with R
GNU General Public License v2.0
325 stars 102 forks source link

how can i buy and finish a operation in R? #119

Closed igorpw4 closed 2 years ago

igorpw4 commented 2 years ago

Description

How can i buy when rsi(2) are under 25 and sell on the max of the previus candle?

Minimal, reproducible example

library(quantmod) library(TTR) library(data.table) library(ggplot2)

getSymbols("EQTL3.sa", src = "yahoo" ) startdate <- as.Date("2019-01-01") enddate <- as.Date("2022-01-01")

chartSeries(EQTL3.SA, TA=NULL) addRSI(n= 2)

EQTL3.SA <- as.data.frame(EQTL3.SA) ifr2 <- RSI(EQTL3.SA$EQTL3.SA.Open, n = 2)

TradeRule <- ifelse(ifr2$rsi < 25, 1, 0)

EQTL3.SA$compra <- TradeRule$rsi [Insert sample data and code]

joshuaulrich commented 2 years ago

Take a look at my blog post, RSI(2) with position sizing. You might also be interested in David Varadi's RSI(2) alternative.

I'm going to close this because it's not something that needs to be fixed. But feel free to continue the discussion.