Price Analysis with Neural Networks
1 2

thread: Price Analysis with Neural Networks

  1. #1
    Junior Member Jorgefer_10's Avatar
    28

    Price Analysis with Neural Networks

    About This Journal

    This is my private journal detailing my development of an artificial neural network to attempt to gain a statistical advantage on the market on multiple time frames. I shall post my progress as I reach milestones, and we'll see together whether it is in fact possible to gain a statistically significant advantage with a machine learning method.

    I shall also discuss how I process money management connected to whatever statistical advantage I might gain with my student. I will post probabilistic simulations of my student's performance utilizing various money management techniques.

    Please note that I currently trade fairly successfully (on a little, ~4K live account) using simple chart patterns and S/R analysis. I am also a fulltime engineering student, but so it could be highly preferable to have an automated agent either trade in my absence or alert me of high-probability setups. In case my development of this indior/EA is effective in gaining an edge, maybe I shall release it into the community in some form.

    I'd love your thoughtful input into the ribbon. Development works best when you're watching, constructively critical spouses - or so the open minded program movement has instructed us. Therefore, if you have something valuable to add, then please by all means post it.

  2. #2
    Junior Member Jorgefer_10's Avatar
    28
    Initial Design Concepts

    First of all, an explanation of the theory of neural networks. The neural network arrangement I will be using is comparable to the one displayed in the picture below.

    Http://www.gamedev.net/reference/pro...nn/figure1.png

    Each circle you see from the picture is called a node. Each of those nodes functions as a type of operator. Information moves from the inputs to the outputs, from the left to the right in the image. At every node, the inputs are summed to create the output. Each input has a flexible weight, or scaling variable, by which it is multiplied before they're all summed at the node.

    Okay... so we have got nodes that include scaled values. How in the world are we going to forecast future price action for this thing?? Well, it turns out that if you fix these weights in a smart way, you can essentially train this network to recognize patterns on the input and produce the outputs you desire according to those patterns.

    So here is the design for the network:

    Inputs

    Time-delayed pip movements. Basically these are values whose magnitudes correspond to the dimensions of every bar on a chart of a particular timeframe. By way of example, let us say you've got the following chart:



    If your neural network were designed to examine four-bar patterns, it would have 12 total inputs. This is, for each pub, it would have an input for the lower wick, the bar body, and also the top back. Both wick values are either zero or positive, and the bar body value would be either positive or negative. So for your candle chart above, you'd see the following inputs (roughly ) from the arrangement top |body|reduced:

    0.02|-0.26|0.18|0.06|-0.12|0.00|0.20|-0.03|0.23|0.00|0.30|0.10

    because you may have seen, all of these values are under 1.0; that's because the inputs to the neural network has to be a match between 1 and -1.

    Outputs

    So now we have inputs. What do we want for the outputs? Let us select downside and upside risk indiors for various timeframes. Say... two on every side. In summary:
    One output for your future high after 1 hour.
    One output for your future after 4 hours.
    One output for your future low after 1 hour.
    One output for your future low after 4 hours.

    To train the system, we look at the highs and lows after the input pattern, calculate the outputs, then use what's called a back-propogation algorithm to adjust the network weights so that the desired outputs arise when we present that input pattern. We then do this over a large number of input/output combinations, and we will hopefully arrive with a community that, when presented with a new set of inputs, can forecast the future highs and lows with some degree of accuracy.

    When we have a community that may forecast future highs and lows, we can place trades with TP and SL levels that maximize our probability of success. We can also choose to just take trades that have a good risk-reward ratio. By way of example, we may choose to just buy when the network predicts a 2:1 high to low ratio, and just sell for the inverse. This can help restrict market exposure to risk, while maximizing the statistical chance of success.

    If you desire more information about neural networks, take a look at the Wikipedia entry on http://en.wikipedia.org/wiki/Artificial_neural_network.

    Expect another article soon about the (custom) software and information I'll use for network training and setup.

  3. #3
    Junior Member Jorgefer_10's Avatar
    28
    Well, NNs are not dinner table conversation. Either you get what I'm saying or you don't. Hope it helps.
    They are at my home . Or at least when I worked back at the Neuroengineering department at UPenn.

    The hope is the network will have the ability to learn complex patterns after a large number of illuions. I will be separating the data into sections and performing round-robin training/testing/validation with many reincarnations of the neural networks in question.

    I'll have networks for significant timeframes. Perhaps one for the 15min, one for the 1hr, one for the 4hr, and one to the daily. Once each is appropriately trained, I will have to experiment with different trading conclusion schemas. Most obvious are a majority-voting or maybe unanimous decision-making process. These progr could also only function as an alert to get a high-probability installation, and then discretionary technical and mental analysis could notify the last trading decision.

  4. #4
    Junior Member Jorgefer_10's Avatar
    28
    Software

    I will be writing my own customized C/C progr that handle the input data and assemble training/testing information collections. My progr will also handle the training and testing of these neural networks created.

    The neural systems themselves will probably be executed using a high-performance software package called Fast Artificial Neural Network (http://leenissen.dk/fann/). It has bindings for many languages, but I will be bundling the library right with a C/C program for maximum efficiency.

    Finally I will probably inspect the results visually by programming an MT4 indior that shows the outputs of the system onto the chart.

  5. #5
    Junior Member pknino_mdc's Avatar
    22
    Everything seems great, it resembles that many people got interested in neural networks employed in Foreign Exchange after great success of EA according to neural networks in EA contest.

  6. #6
    Junior Member Jorgefer_10's Avatar
    28
    everything seems good, it looks like that many people got interested in neural networks applied in Foreign Exchange following great success of EA according to neural networks in EA contest.
    I suppose. My interest was certainly renewed after viewing this at the MetaTrader Automated Trading Championship, but I initially started researching NNs and other machine learning methods in relation to market analysis in late 2006. In addition, this neural network will probably be reading price action directly rather than computed indiors, as the current winner's EA did.

    I've some new alterations to my plan that I'll post when I am more alert and don't have to finish a VHDL design before 11am tomorrow .

  7. #7
    Junior Member Jorgefer_10's Avatar
    28
    Instead of converting the numerical value of these presses to pip values, it will probably be preferable to instead lead a kind of probability histogram. That is, for every time period under consideration, have a pair of outputs as follows (for example):

    Likelihood of prospective high 100 pips
    Likelihood of prospective high 50 pips
    Likelihood of prospective high 30 pips
    Likelihood of prospective high 20 pips
    Likelihood of prospective high 10 pips
    Likelihood of prospective low -10 pips
    Likelihood of prospective low -20 pips
    Likelihood of prospective low -30 pips
    Likelihood of prospective low -50 pips
    Likelihood of prospective low -100 pips

    Therefore, each output signal would predict the likelihood, given the current pattern on the input signal, the future high or low are a specific distance apart from the current price.

    These presses will probably be preferable for reasons that become apparent once you've utilized NNs for a while. All machine learning tools end up being a type of statistical analysis, but NNs are especially so, since the purpose beneath minimization is your mean-squared-error within the data collection of their outputs versus the aims. Translated: the outputs generally tend to the mean of their aims. So if you've got 100 illuions of a pattern and its own future highs change around some mean, the network will learn to just output that mean. Sad to say, the mean does not tell us anything about the form of this supply. Imagine if 50 from these 100 cases move only ten pips up, along with another 50 transfer 100 pips up? The network will tell us that the expected move is mean(10,100) = 55 pips, when this movement never even happens!

    Working with a histogram-based pair of sparks, however, we would see that the output strengths of those nodes which correspond to 10 and 100 are both 0.5, and the inherent strengths of these other nodes are 0. Thus, when building algorithms which truly use this output to trade, we could analyze not only the mean of the expected price change but the supply.

    Note that by dividing the upcoming range into sufficient price bins and timeframes, we would end up getting a pair of outputs that looks like a picture such as the following:


    To train, test, and notably trade automatically based from the image would be exceedingly time-consuming, however, so we will adhere to a more compact pair of bins and timeframes for the time being. All parameters of this network and training/testing system will be dispersed, however, so if the network turns out to be valuable and trains/tests quickly as is, maybe we can try to raise the resolution by incorporating more bins and timeframes.

  8. #8
    Junior Member Oxni1957's Avatar
    25
    Hi Drummer!


    I expect that this thread is going to be a lot of fun and a wonderful learning experience! I have a few questions, one on inputs and one on outputs.

    1. Will you be changing the amount of bars used to generate the input parameters easily? If this is so, this creates another degree of freedom but it may provide an insight to the way the length of a predictive pattern affects functionality. Are 4-bar NNs more or less successful than 10-bar NNs, that type of thing.

    2. I know why you switched to a distribution, like I usually look at quartile breakdowns in my research. However, it's still hard to exchange from a distribution. What about utilizing real trading choices as the output? There might be three factors; an action variable for buy, hold or sell with worth (-1,0,1), an SL value in pips and a TP value in pips (because your inputs are measured in pips that I believe).

    If you back-propogate, then you'd be comparing the real outputs with the perfect outputs. By way of instance, if over the course of the test period, price reached a low of 37 pips below the close of the last output and 19 pips over that close, then the ideal trade could have turned into a sale using a halt of 19 pips and a TP of 37 pips, i.e. an outcome of (-1,19,37).

    I have never worked with NN software and that I only know the basics of the theory and arrangement of nets, so this may actually not make sense. What do you believe?

  9. #9
    Junior Member Jorgefer_10's Avatar
    28
    1. Will you be varying the number of bars used to generate the input parameters readily? If this is so, this creates another level of freedom but it may provide an insight into the way the span of a predictive pattern affects performance. Are 4-bar NNs more or less effective than 10-bar NNs, that sort of thing.
    Yes

    2. I know why you changed to a supply, as I generally look at quartile breakdowns in my own research. However, it's still hard to exchange out of a supply. What about using real trading choices as the output signal? There might be three variables; an action variable for buy, hold or sell with worth (-1,0,1), an SL value in pips and a TP value in pips (since your inputs are measured in pips that I believe).

    When you back-propogate, then you'd be comparing the real outputs with the perfect outputs. By way of instance, if over the course of the evaluation interval, price reached a low of 37 pips below the close of the previous output and 19 pips above that near, then the perfect trade could have turned into a sale with a stop of 19 pips and a TP of 37 pips, i.e. an outcome signal of (-1,19,37).

    I have never worked with NN software and that I only know the basics of the concept and structure of nets, so this may actually not make sense. What do you believe?
    The perfect trade data you mentioned is actually what I talked about in my next post in this journal. What you are referring to is targeting the future low and high for every input pattern. The buy/sell signal is actually redundant, provided that you can calculate it by the saying (highgt;low)*2-1. After coaching on a large set of these patterns, but the neural net will probably learn to output the sense of these values over the set of comparable patterns.

    Rather, I prefer to have the network learn the supply. Knowing the previous statistical distribution permits you to make egies based upon the calculated probability of hitting different price points. For example, we are utilized to the concept of taking trades with a 2:1 or 3:1 TP into SL ratio, but we can not make certain that they'll actually increase our winnings, as without a predictive edge, a closer stop is generally more likely to be hit than the further take profit. If we knew the statistical distribution of price points during the next hour (or day, or week... anything ), we could set stops which, historically, are actually twice less likely to be struck than our take profit level.

    Ideally, we would have the ability to choose trades that are extremely high-probability and high-reward, where the end is unlikely to be struck, the take profit is quite likely to be hit, and the take profit is significantly farther than the end. Warren Buffet always attributes his success to creating low-risk, high-reward investments. Our aim should be the same - that is, to maximize the probability of winning while decreasing the probability of losing - or in trader's conditions: to have an edge on the market.

  10. #10
    Hi Drummer,

    I don't have any actual experience with NN but it seems a lot like distributed (parallel) programming, so I think I have a notion what you're seeking to along with your program and your explanation was of your NN would be is very good. I might be jumping the gun with this question but I have to ask.

    Are you really going to look at news reports to get extra info as soon as you get the raw inputs trained? I think it might be a valid data set if the correct filtering and resources could be found and used. What are your thoughts?

    I'm currently working on just such programming for news for a indior for trade signals. It is functional but needs adjusting and teasing before I will be using it for trades.

  •