What do you think of this trading strategy -Add more indicators for parameter optimisation.

Joined
May 3, 2023
Messages
1
Reaction score
0
maxRows <- 9700

getOrders <- function(store, newRowList, currentPos, info, params) {

zeroPositions <- rep(0, length(newRowList))

if (is.null(store)) {
store <- initStore(newRowList, params$series_a)
}
store <- updateStore(store, newRowList, params$series_a)

positions <- zeroPositions

if (store$iter > params$lookback) {
startIndex <- store$iter - params$lookback

for (i in 1:length(params$series)) {
# Recognize overbought and oversold signals-price change signals
closePrice <- newRowList[[params$series_a]]$Close
rsiValue <- last(RSI(store$cl[startIndex:store$iter, i], n = 26,
maType = list(maUp = list(EMA), maDown = list(WMA))))

if (!is.na(rsiValue)) {
if (rsiValue < 20) {
positions[params$series] <- params$posSizes_a[params$series]
} else if (rsiValue > 80) {
positions[params$sera] <- -params$posSizes_a[params$series
}
}
}
}

if (store$iter > params$macdLookback) {
startIndex <- store$iter - params$macdLookback

for (i in 1:length(params$series_a)) {
macdValues <- MACD(store$cl[startIndex:store$iter, i],
nFast = params$macdFast, nSlow = params$macdSlow,
maType = params$macdMa, percent = TRUE)

# Sell signal when MACD is implemented
if (macdValues["signal"] > macdValues["macd"]) {
positions[params$series_a] <- -1
}
}
}

return(positions)
}
 

Members online

No members online now.

Forum statistics

Threads
473,813
Messages
2,569,696
Members
45,483
Latest member
TedDvb6626

Latest Threads

Top