OPEN-SOURCE SCRIPT

Machine Learning Z-Score Buy and Sell [SS]

353
Hey everyone,

Releasing this Z-Score based buy and sell indicator.

What it does

This indicator:

  • Uses Z-score and trend to identify potential buy and sell areas.
  • Signals those buy and sell areas and provides a target price based on the mean.
  • Plots the target price for buy and sell signals as a red line (for sell signals) or green line (for buy signals).
  • Has some "machine learning" aspects, namely, it is able to auto select its lookback length based on its analysis of the trend using Pienscript's trend correlation function iterated over multiple lengths, in order for the indicator to identify:
    a) The strongest trend; and
    b) The correct target price



What is Z-Score

Z-Score is a measure of the mean. Thus, this is a mean reverting type strategy, as it uses z-score to determine price's distance from the mean (or a Z-Score of 0) and then it looks at historic deviations from the mean to signal the buy and sell signals (i.e. how far has price traditionally drifted from the mean before reverting).

Z-Score is a powerful tool in this sense, and if you folow my other indicators, you will know how much I love Z-score!

How to use the indicator

If you want to use the full Machine Learning capabilities of the indicator, its best to just leave all default settings. These default settings will automatically adjust the mean target price and buy and sell signals to align with the current price action.

If you want to be more aggressive in your
  • Target Price; and
  • Signals


Then you can opt to manually input a lookback length and mean reversion standard deviation. However, I generally suggest to avoid this as you are then making your own determination of trend by qualitative assessment. It can work, but its just not suggested.

In the input menu, you will see the option to "Manually select lookback" thus over-riding the auto-determination of trend and targets.

You will also see "manual pullback" enabler and "Pullback Standard Deviation". You can set your pullback standard deviation if you want to be more aggressive. The indicator will naturally shift to conservative target prices based on a neutral mean. However, if you want to increase the aggressiveness of the target price, you can increase or decrease the pullback standard deviation.

General Tips about Manually Adjusting Pullback Target

Here are some tips if you want to manually adjust the pullback targets:

  • The pullback target needs to be in a standard deviation value, this can be anywhere from 0 to 4 or 0 to -4 (you can theoretically go higher but its not really realistic). You can also do decimals, so 1.5 or 1.25 etc.
  • To determine whether you should be doing negative or positive standard deviation, you should determine the trend. If it is a downtrend and you are looking to short the rips, you will want to select a negative number, like -1.
  • If it is an uptrend and you want to buy the dips, you should be selecting a positive number, like 1 or 1.5.


Again, I do suggest leaving the indicator to decide for itself, but the options are there for those who wish.


Overall strategy
This is a mean reverting strategy. So if you are a mean reversion trader, this may be of particular interest to you.

Optional

Optionally, you can have the indicator plot the target prices or not, simply toggle this functionality off or on in the settings menu.


Concluding remarks

That is the indicator in a nutshell!

I hope you enjoy it and find it helpful.
Feel free to check out my other Z-Score based indicators if you find this interesting or want to learn more about the power of Z-Score in trading!

Thanks all and safe trades!

免責事項

これらの情報および投稿は、TradingViewが提供または保証する金融、投資、取引、またはその他の種類のアドバイスや推奨を意図したものではなく、またそのようなものでもありません。詳しくは利用規約をご覧ください。