Machine learning in trading: theory, models, practice and algo-trading - page 279
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Speak straight, it's Sunday, there is no hurry, and there is some truth in everything. I do not think that your method is charlatan, a pretty good method with a fundamental basis.
What's to say? I didn't say anything about "my" method.
You're laughing about something so tell me and let's laugh together.
Thank you, I laughed already.
Thank you, I laughed already.
It would be desirable to see the results of calculations
But I advise you to check on your own instruments, because the problem may lie in the small nuances of the implementation of individual functions. For example the display of ZZ in "categorical view" can be shifted to the right for one bar, at me it is not shifted, where the knee ZZ finishes and there changes of the indicator of the derivative ZZ sign. The main thing is that the signs should be without peeking, and targetets must peek, that is their essence. But the fact is that ZZ (its slope) is a target at once, because it shows the trend with a view into the future and the ideal position direction at the moment.
Okay, I'll have half a day off.
in R it can be done in 3 minutes, so if Sanych wants a pruf so badly he could have spent those three minutes
Do you even understand what you have to do in these "three minutes"? If you understand, then record a video camtasia, where you do it in three minutes, without speeding up and editing the first time.
Do you even understand what you have to do in these "three minutes"? If you understand, then record a video camtasia, where you do it in three minutes, without speeding up and editing the first time.
here...
Only I put a noise on the sinusoid, because the pure sinusoid is predictable and the model in both cases predicted without error
make.sin <- function(){
t <- seq(0,50,0.1)
s <- sin(t)
return(s)
}
S <- make.sin()
noise <- rnorm(length(S))
S <- (S+noise)+1000
# х енкель для создания скользящего окна
hankel <- function(data, r=5) {
do.call(cbind,
lapply(0:(r-1),function(i) { data[(i+1):(length(data)-(r-1-i))]}))}
S <- hankel(S)
# делаем зиг и целевую с него
library(TTR)
make.zz <- function(ch=0.2){
zz <- ZigZag(S[,ncol(S)], change = ch, percent = T, retrace = F, lastExtreme = T)
n <- 1:length(zz);
for(i in n) { if(is.na(zz[i])) zz[i] = zz[i-1]}
dz<-c(NA,diff(zz))
sig<-ifelse(dz>0, 1, ifelse(dz<0, 0, NA))
return(list(label=sig , zz=zz))
}
Y <- make.zz()
layout(1:2)
# рисуем для наглядности синусоиду ,
# зигзаг на ней и внизу бинарный сигнал бай/сел
plot(S[,ncol(S)],t="l")
lines(Y$zz,col=4,lwd=2)
plot(Y$label ,t="l")
# подготовка данных
dat <- na.omit( cbind.data.frame(var=S, label=Y$label) )
label <- as.factor(dat$label)
dat <- dat[,-ncol(dat)]
# тренировки модели
tr <- 1:400
ts <- 401:nrow(S)
library(randomForest)
# тренируем модель как есть те целевая
# не заглядывает в будущее на один шаг
rf1 <- randomForest(label[tr]~., dat[tr,])
pr1 <- predict(rf1, dat[ts,])
# теперь тренируем вторую модель которая
# уже пробует предсказать следующее значение
label2 <- label[-1]
dat2 <- dat[-nrow(dat),]
rf2 <- randomForest(label2[tr]~., dat2[tr,])
pr2 <- predict(rf2, dat2[ts,])
# проверяем результаты
library(caret)
#ошибка без попытки предсказать
confusionMatrix(pr1,label[ts])
#ошибка с предсказанием на шаг
confusionMatrix(pr2,label2[ts])
average without prediction
Accuracy : 0.7895
With prediction
Accuracy : 0.6702
P.S. I didn't read it carefully, that's why I have the sine wave itself instead of momentum in the predictors. Five values with noise on top
mytarmailS:
Average with no prediction
Accuracy : 0.7895
with prediction
Accuracy : 0.6702
So...
The acceleration on the forest is 10% higher without shifting ZZ, which was required to prove, because ZZ predicts the future at a specific moment, there is no need to shift it.
Here we go...
The foreshortening on the forest is 10% more without shifting ZZ, which was required to prove, because ZZ predicts the future in a particular moment, there is no need to shift it.
It doesn't prove anything.
The rule is simple: when preparing data for training , shift the target to the left ("into the future") by one bar, regardless of how you generated the signal. Do you have any idea why?
If you do not know, I will describe it in detail.
Good luck