- 评论 (1)
- 评论 (5)
If you like trading by candle patterns and want to reinforce this approach by modern technologies, this indicator and other related tools are for you. In fact, this indicator is a part of a toolbox, that includes a neural network engine implementing Self-Organizing Map (SOM) for candle patterns recognition, prediction, and provides you with an option to explore input and resulting data. The toolbox contains:
- SOMFX1Builder - a script for training neural networks; it builds a file with generalized data about most characteristic price figures which can be used for next bars prediction either in a built-in sub-window (see SOMFX1 below), or directly on the chart (see SOMFX1Predictor below);
- SOMFX1 - the indicator for price pattern prediction and visual analysis of a trained neural network, input and resulting data (in a separate sub-window);
- SOMFX1Predictor - this indicator for predicting price patterns just in the main window;
In brief, all the process of price analysis, network training, pattern recognition and prediction supposes the following steps:
- Build a neural network by SOMFX1Builder;
- Analyze the resulting neural network performance by means of SOMFX1; if not satisfied, repeat step 1 with new settings; you may skip this step if you wish;
- Use final neural network for price pattern prediction using SOMFX1Predictor.
How it works
This indicator is the most simple part of the neural network toolbox. It takes a file with a trained network and shows you prediction of the network on the chart. This is a red line which can be partially thick and partially thin. Thick fragments denote bars where the network is more confident in its prediction than on thin fragments. The prediction starts on the vertical dotted line in yellow named "FromPastToFuture". You can drag the line to an arbitrary position, and the indicator will read current sample at this position, and run SOM against this sample, so you'll see new prediction. The current price sample is a fragment of price deltas taken from PatternSize bars to the left of the "FromPastToFuture" line. When you open the indicator first time, the line is placed at LearnStop bar. If you move the line to 0-th bar, the indicator will automatically keep the line on new 0-th bars which will appear in future, that is the line will stick to the latest bar.
Please note, that the prediction starts at the current bar, that is the current bar is also predicted. This is done because current bar is usually unfinished and requires prediction as well. Moreover, if we could take currently unfinished bar into consideration, it will make prediction inconsistent (unstable during current bar lifetime). Due to the fact that current bar is predicted, the red line with prediction starts 1 bar left to the vertical line "FromPastToFuture" - it shows how price should change on the current bar.
The indicator can optionaly show the neural network itself, when ShowMap is true. In this case the indicator displays 2 square maps on the main chart.
The left square denotes current activity of every neuron: neurons with high excitation are shown in red, and neurons with high inhibition are shown in blue. In other words, the redder the cell on the map, the better it fits to current price sample.
The second - right-side - square map displays "population density" of every unit, that is its color denotes number of samples occured in the trainig data, which are landed to corresponding cell and formed corresponding price pattern. Again red color means relatively high population, and blue - relatively small. Gray cells do not have corresponding samples in training data.
- LearnStart - number of a bar in history, or an exact date and time of the bar (in the format "YYYY.MM.DD HH:MM"), where training data began; this parameter is a string, whick allows you to enter either a number or a date; this parameter is used here not for training but for building actual price samples (corresponded to the network), which is important if UseAverage parameter is true (see below), as well as for map "population" visualization; default value - 5001; if you enter an automatically generated filename in NetFileName parameter (see below), the indicator parses the name and overrides this parameter by a value from the name; in other words, this parameter has no effect when an automatically generated filename is specified in NetFileName parameter.
- LearnStop - number of a bar in history, or an exact date and time of the bar (in the format "YYYY.MM.DD HH:MM"), where training data ended; this parameter is also a string; default value - 1; this parameter is used here not for training but for building actual price samples (corresponded to the network), which is important if UseAverage parameter is true, and for map "population" visualization; this parameter has no effect when an automatically generated filename is specified in NetFileName parameter;
- PatternSize - number of bars in a single pattern; default value - 5; this parameter has no effect when an automatically generated filename is specified in NetFileName parameter;
- GridSize - dimentions of the map; this is a number of cells/units on X and Y axes; allowed values: 3 - 50; default value - 7; this parameter has no effect when an automatically generated filename is specified in NetFileName parameter;
- PredictionBars - number of bars to predict; default value - 10; please note, that every next bar is predicted with less accuracy than previous, because unavoidable errors on every bar are accumulated;
- UseAverage - this is a special mode switch; when disabled (false, default value) predictions are made using weights of winning neurons, that is they are product of the map; when enabled (true), predictions are based on average values of all price samples mapped into winning neuron; this requires not only the map, but the training data as it was used for the network training, which is why it's important to specify exact date and time where sampling has been made during training; you may "play" with this parameter to obtain better results: using weight vectors is the conventional approach, but using averages adds more data awareness;
- PriceType - price type to use for sampling; default value - close; this parameter has no effect when an automatically generated filename is specified in NetFileName parameter;
- AddInvertedPrice - enable/disable a mode, when inverted price movements are added into the samples; default - true;
- NetFileName - a filename of the trained neural network generated by SOMFX1Builder script; if the name was generated automatically, it comprises several necessary components to restore most of abovementioned parameters, so a user may fill in only this one parameter; the filename structure is the following: SOM-V-D-SYMBOL-TF-YYYYMMDDHHMM-YYYYMMDDHHMM-P.candlemap, where V - PatternSize, D - GridSize, SYMBOL - current work symbol, TF - current timeframe, YYYYMMDDHHMM - LearnStart and LearnStop respectively; P - PriceType;
- CellSize - size of a single unit visualized on the chart (if ShowMap is true); default value - 20, which is ok for maps with dimentions up to 10; for larger map choose smaller cell size, or otherwise the two map views will overlap;
- PrintData - enable/disable debug logging; default - false;
- ShowMap - an option to visualize map on the chart in the same way as it's done by SOMFX1 indicator; default - false;
If some of parameters are incorrect, the indicator prints an error message into the log. For example, you can load a map only on a chart with the same symbol and timeframe that was used during training.
Visual testing is supported with some limitations: the UseAverage mode is not available, the ShowMap mode is not available. Full testing is impossible due to the tester's limitation of provided data range.