Machine learning in trading: theory, models, practice and algo-trading - page 114

 
Dr.Trader:
I do it manually, I just create models in a loop.
Can you show me in code how models are created in a loop?
 

Committee creation, and testing:

library(randomForest)

data(iris)

totalModels <- 100

trainSample <- sample(1:nrow(iris), round(nrow(iris)*2/3))
validationSample <- setdiff(1:nrow(iris), trainSample)

#train
modelVector <- c()
for(i in 1:totalModels){
        modelVector[[i]] <- randomForest(x=iris[trainSample, 1:(ncol(iris)-1)], y=iris[trainSample, ncol(iris)])
}

#validate
predictionMatrix <- matrix(NA, ncol=length(validationSample), nrow=0)
for(i in 1:totalModels){
        prediction <- predict(object = modelVector[[i]], newdata = iris[validationSample, 1:(ncol(iris)-1)])
        predictionMatrix <- rbind(predictionMatrix, prediction)
}
finalPrediction <-c()
for(i in 1:length(validationSample)){
        finalPrediction <- c(finalPrediction, names(sort(table(predictionMatrix[,i]), decreasing=TRUE)[1]))
}
"Accuracy:"
mean(finalPrediction == as.numeric(iris[validationSample, ncol(iris)]))

There's a problem in that the original factor type classes, and the result in the matrix is converted to the order numbers corresponding to the factors. So at the end the comparison goes through as.numberic().

For everything to work properly with factors, I need to create predictionMatrix as data.frame, but after that my rbind function gave out varnings, I need to change something else, I did not understand what is wrong there.

 
Dr.Trader:

Establishing a committee, and testing:

thank you

 

Well and in continuation of the topic, the signal that was earlier turned out to be quite working. However there are not many profits, but the last buy on the sequent, the blue dot, the network recognized as "I don't know", which suggests that it may be profitable, or may not, in any case the two models have diverged. So do nothing, and continue to monitor the volume....

I had a surrender on a BU, as you can see.... Just went for vitamins, so I didn't take any chances and converted to CU, but as they say, you put CU, you get CU. The law works...

 
Mihail Marchukajtes:

Well and in continuation of the topic, the signal that was earlier turned out to be quite working. However there are not many profits, but the last buy on the sequent, the blue dot, the network recognized as "I don't know", which suggests that it may be profitable, or may not, in any case, the two models have diverged. So we do nothing, and continue to monitor the volume....

I had a surrender on a BU, as you can see.... Just went for vitamins, so I didn't take any chances, I converted to CU, but as they say, you put CU, you get CU. The law works...

How did the algorithm trade on Friday?

 
Dr.Trader:

Committee creation, and testing:

There's a problem in that the original factor type classes, and the result in the matrix is converted to the order numbers corresponding to the factors. So at the end the comparison goes through as.numberic().

I need to create predictionMatrix as data.frame to make it work properly with factors, but after that my rbind function gave out varnings, I need to change something else, I haven't figured out what's wrong there.

Thanks for the useful code.
 

Tell me ... If you run this data through your machine learning ... What can you find out?

# SL
trailing stoprise
1
-40-5
0
2
-9
-
0
3
-23
70
91
4
-26
-14
21
5
-42
-
0
6
-43
-8
5
7
-11
12
65
8
-64
-12
0
9
-1499126
10
-32
-
10


# - trade number, SL - stop loss size, trailing stop - tra iling stop, red - closing with loss, green - closing with profit, dash - closing at stop loss,

Theamount of movement which could be taken, 0 - there was no movement (possible profit which could be taken on this deal). All it is specified in points ...

Take Profit is absent.


If anyone knows if we run these three variables-curves through MatLab or Statistica - what data can be obtained ?

 
Itum:

Tell me ... And if you run this data through your machine learning ... What can you find out ?

what data can be obtained ?

the question is not posed correctly, the question is what do you want to get from this data ?

the answer to your question is nothing?

 
mytarmailS:

the question is not posed correctly, the question is what do you want to get from this data?

The answer to your question is nothing.

  • I want to get how these variables are related (is there a trend), is there a correlation between them.
  • To what extent does the drawdown affect future movement (recovery)
  • I need indicators that will maximally show-predict the future trend.
 
Itum:
  • I want to get how these variables are related (whether there is a trend), whether there is a correlation between them.
  • To what extent does the drawdown affect future movement (recovery)
  • I need indicators that will maximally show-predict the further trend.

1) we can build a correlation matrix

2) you should probably build a drawdown dependence on the future movement

3) build a model that predicts a trend and look at the importance of the variables in it

p.s. don't ask me to do it for you... judging by the vagueness of your questions, you're little familiar with machine learning, so I recommend you first google and learn some of the programs you cited above, or go into programming

Reason: