I am still thinking about the design for the genetic algorithm. Here are a few random thoughts:
* I think you need to add one more ‘gen’ to each chromosome. The value that the gen can have can be either ‘0’ or ‘1’ (buy or sale) or you can have three values -1 (sell) 0 (do nothing) 1 (buy). As with the previous genes this value will be randomly generated. I’ll call this gen D (as in decision)
* For the other two values, instead of figuring out the range, we will use random numbers from 0 to 1 as ‘weights’ for the real number, that you get from the historical data.
* The idea is to end with a formula like: w1 x RSI + w2 x MACD = M then if M < a => Sell, if M > b => Buy, if a < M < b => Do Nothing. We don’t know yet what values we will set for ‘a’ and ‘b’. RSI and MACD we can take from a given stock at a given day. w1 and w2 will be generated randomly for each chromosome.
* We will use the genetic algorithm to determine w1 and w2. As a ‘by-product’ we will also get the ‘optimal’ values for ‘a’ and ‘b’
* Once we have each chromosome we will put w1 and w2 into the formula and get M. Then we will take the other gen ‘D’ and compare the decision with the stock price for the following day p(tomorrow)
* Then F(xi) will have three ways of being calculated:
** if D = -1 (sell) F(xi) = P(today) – P(tomorrow)
** if D = 1 (buy) F(xi) = P(tomorrow) – P(today)
** if D = 0 (do nothing) F(xi) = abs(P(tomorrow) – P(today)) (if you do ‘nothing’ and the stock moves significantly you lose either way)
* The formula above is not complete since we need to incorporate M into it. I’m not sure yet how.