Hi I finished decision tree in trading. I am so confused now i have two quastions:
1-) how to combine Cross Validation and Hyperparameter Tuning in one kernel ? İ think the best way to make a best model use Cross Validation and Hyperparameter Tuning together ?
2-) I learnd one predictions whic is priece is high or low in nex day to buy or sell thats mean 1 or 0 . But my stratgy is not about one days I have stoplost , take1 and take 2. How can i adjust y_predict ?
Hello Aytac,
1) So, to do both CV and Hyperparameter tuining together you can you the GridSearchCV from sklearn. So, for every parameter in the grid it iterates over, it finds the average accuracy and other list of metrics by using the cross-validation method.
2) Prediction isn't related to stop-loss. Prediction is what your model thinks will happen the future. Based on that you take a long or short position the next day. Now, when the next day arrives, if you took the long position and the prices fell and it hit a lower threshold, you can sell and exit position. This is called stop-loss. Similarly for take-profit.
Thank for respond i got you but i had more dreams for prediction for example get a signal then put a 1 ATR stoploss, The difference between stoploss and signal is twice the result of the calculation is takepoint, can my signal get those all pip point thats my prediction can i set this ?
Hello aytac,
From what I understood, do you want to predict the exact number of pips the stock price will move up or down in the next interval?
Absolutely yes but I have to set Y_train and Y_test so that if it stops, give it zero and give one when it comes to take point
Right. So, there is a method called the triple barrier method for exactly this. You can set Y_train and Y_test correctly based on the stop-loss and take-profit.
In this method, for each data point (X,y), the X which is the input vector is set based on an initial price window of M bars. The y is set using the subsequent N bars after these M input bars. Since we are talking about how to factor in the thresholds let us focus on the path the price takes in the N bars used to decipher the label.
In these N bars, we set 3 price barriers. Two are horizontal, set for the stop-loss and take profit and one is vertical. Three or triple barriers. We look at the path the price takes. If the price touches the upper price barrier we take y=1. This means that in this N bar window we took profit. If the price touches the lower price barrier we take y=-1. This means that in this N bar window we stopped loss. If the price path does not touch either barrier and touches the vertical barrier, at the end of the N bars, we take y=0. y=0 implies that for the input of the M bars before these N bars we should take a neutral position. Same way y=1 or y=-1 implies that for the input of N bars before these M bars we should take a long or short position.
This and other methods have been covered in detail in our course Data and Feature Engineering for Trading.
Thanks you so much for your support that is so valuable for me after finish deep learning it is so hard than i thought for me i am gonig to attemp to data and feature engineering
My pleasure!