This is a trading item or a component that was created using QuantShare by one of our members.
This item can be downloaded and used by QuantShare Trading Software.
Trading items are of different types. There are data downloaders, trading indicators, trading systems, watchlists, composites/indices...
You can use this item and hundreds of others for free by downloading QuantShare.
Top Reasons Why You Should Use QuantShare:
Works with US and international markets (stock, forex, options, futures, ETF...)
Offers you the tools that will help you become a profitable trader
Allows you to implement any trading ideas
Exchange items and ideas with other QuantShare users
Our support team is very responsive and will answer any of your questions
We will implement any features you suggest
Very low price and much more features than the majority of other trading software
This indicator makes a prediction for the returns of the current bar based upon averaging the returns of the NumClosest (parameter) candlestick patterns that were most similar to the current bar's pattern in the Lookback (parameter) period. "Similarity" here is the squared euclidean distance between vectors describing the two patterns.
The Filter (parameter) can be useful for training the forecast under differing market regimes; any pattern where the filter is false on the final bar of the pattern will be excluded from the "training" set. The indicator will also produce a prediction of 0 for any bars where the filter is false.
Examples:
kpCandlePatternForecast(1000, 3, 50, 1) -> would form a prediction by averaging the next day returns of the 50 3 bar candle patterns most similar to the current 3 bar candle pattern found in the previous 1000 bars.
kpCandlePatternForecast(1000, 3, 50, close > sma(close, 20)) -> same as above but would only include patterns in the training set if the final bar of the pattern closes above the 20 period SMA. The forecast would also be zero for any bar whose close is below the 20 period SMA.
kpCandlePatternForecast(90, 2, 10, 1) -> would form a prediction by averaging the next day returns of the 10 2 bar candle patterns most similar to the current 2 bar candle pattern found in the previous 90 bars.
Interpreting the results:
Any bar where the indicator produces an excessively high or low result may be a good signal to go long / short for the next day as similar patterns have generated an unusually high / low return over the lookback period. Playing with the filter parameter can also be a good way to visually get an idea of the tendencies of an instrument for the filter regime over the lookback period.
Important: Forecasted returns are from close of the current day to the next day's close. Make sure to SetSimTiming appropriately when you're backtesting.
Credit:
K Nearest Neighbors is certainly not a novel idea, but this page:
Got me interested enough to code up the indicator for QS. Have a look there for a nice writeup including performance statistics as well as some ideas for improving things even further.
Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.