lefnire / tforce_btc_trader

TensorForce Bitcoin Trading Bot
http://ocdevel.com/podcasts/machine-learning/26
GNU Affero General Public License v3.0
814 stars 234 forks source link

Can we add a support and resistance indicator? #37

Open lorrp1 opened 6 years ago

methenol commented 6 years ago

With a support/resistance indicator, I'm assuming the context comes from the value of the current price in relation to the support/resistance line, similar to a bbands strategy. It might be best to calculate a percentage of where the current price is between the two, or work off true/false if it crosses the line. I don't have a good grasp on what's going on with the price scaling in the environment but anticipate that if they are scaled independently that the relationship between the price and the support/resistance lines would get skewed.

There's a school of thought that you really don't want to feed the network stuff that it can calculate on it's own mathematically (not sure how true this is). For example, if RSI is a mathematical function of price, then feeding it in is just adding more data for it to determine the relevance of and clutters the signal. However, if the value is based on data outside of the window that the LSTM layer is looking at, then there may be value added.

This is on my list of things to try, currently trying to get the environment isolated from hypers to better test things like this.

A really rough implementation of an ema crossover/under that I used in a different environment looks like this, if it helps anyone:

        self.series['emaCrossover'] = np.where(self.series['MA_5'] < self.series['MA_10'], 1, 0)
        self.series['emaCrossunder'] = np.where(self.series['MA_5'] > self.series['MA_10'], 1, 0)

Also, I don't see anything for support/resistance in the talib or jhtalib libraries. However, there's this (I didn't write it) that would be easy to implement:

#Pivot Points, Supports and Resistances
def PPSR(df):
    PP = pd.Series((df['high'] + df['low'] + df['close']) / 3)
    R1 = pd.Series(2 * PP - df['low'])
    S1 = pd.Series(2 * PP - df['high'])
    R2 = pd.Series(PP + df['high'] - df['low'])
    S2 = pd.Series(PP - df['high'] + df['low'])
    R3 = pd.Series(df['high'] + 2 * (PP - df['low']))
    S3 = pd.Series(df['low'] - 2 * (df['high'] - PP))
    psr = {'PP':PP, 'R1':R1, 'S1':S1, 'R2':R2, 'S2':S2, 'R3':R3, 'S3':S3}
    PSR = pd.DataFrame(psr)
    df = df.join(PSR)
    return df