TradingView
lastguru
27 cze 2021 23:14

VWMA with kNN Machine Learning: MFI/ADX 

Bitcoin / TetherUS PERPETUAL CONTRACTBinance

Opis

This is an experimental strategy that uses a Volume-weighted MA (VWMA) crossing together with Machine Learning kNN filter that uses ADX and MFI to predict, whether the signal is useful. k-nearest neighbours (kNN) is one of the simplest Machine Learning classification algorithms: it puts input parameters in a multidimensional space, and then when a new set of parameters are given, it makes a prediction based on plurality vote of its k neighbours.

Money Flow Index (MFI) is an oscillator similar to RSI, but with volume taken into account. Average Directional Index (ADX) is an indicator of trend strength. By putting them together on two-dimensional space and checking, whether nearby values have indicated a strong uptrend or downtrend, we hope to filter out bad signals from the MA crossing strategy.

This is an experiment, so any feedback would be appreciated. It was tested on BTC/USDT pair on 5 minute timeframe. I am planning to expand this strategy in the future to include more moving averages and filters.

Informacje o Wersji

fixed a misleading comment

Informacje o Wersji

new parameters:
  • Apply kNN filter - if you want to try just the MA crossing without the kNN filter
  • kNN minimum difference - skews the number of votes needed for the decision, so this many more votes are needed to allow taking a position (e.g., if this is 1, the position would not be taken if there are 3 agains 3 votes, but would be taken if there are 4 agains 3 votes)
Komentarze
Invest0rStallone
Looks awesome! with what Risk/reward ratio ur working testing with?
lastguru
@Invest0rStallone, thank you. Right now there is no risk management in the script. I can try to grade the ML majority vote into entry if there is an overwhelming majority, and just exit, if about tied. I can also try to classify the results based not only on just price going lower or higher, but also if it goes significantly or not, however I don't know what would be the best metric to use for this… do I just mark like 0.1% change as insignificant or base it on ATR or some other stat? Any ideas?
lastguru
@Invest0rStallone, I updated the script to allow for entry only when an overwhelming majority of kNN votes are for it - new parameter "kNN minimum difference" controls it. You can try it out.
lastguru
FYI: I reimplemented kNN filter as a library: tradingview.com/script/5wbvaWZT-kNN/
kanesidiki023
Is the Script still performing well
trustingBoa68688
in two different accounts, our different signals in the same currency are the same. this is repainted
mentalRock19315
Fail to load > 40 sec
GarethSA
Great

I am getting an error saying: cannot create an order with negative quantity. Current qty_type is percent_of_equity and equity is less than 0

How do i fix this?
Redder_Hotter
Looks promising. Great work!
Więcej