TradingView
jasonnyberg
2 מרץ 2021 15:35

Particle Physics Moving Average 

Invesco QQQ Trust, Series 1NASDAQ

תיאור

This indicator simulates the physics of a particle attracted by a distance-dependent force towards the evolving value of the series it's applied to.

Its parameters include:
  • The mass of the particle
  • The exponent of the force function f=d^x
  • A "medium damping factor" (viscosity of the universe)
  • Compression/extension damping factors (for simulating spring-damping functions)


This implementation also adds a second set of all of these parameters, and tracks 16 particles evenly interpolated between the two sets.

It's a kind of Swiss Army Knife of Moving Average-type functions; For instance, because the position and velocity of the particle include a "historical knowlege" of the series, it turns out that the Exponential Moving Average function simply "falls out" of the algorithm in certain configurations; instead of being configured by defining a period of samples over which to calculate an Exponential Moving Average, in this derivation, it is tuned by changing the mass and/or medium damping parameters.

But the algorithm can do much more than simply replicate an EMA... A particle acted on by a force that is a linear function of distance (force exponent=1) simulates the physics of a sprung-mass system, with a mass-dependent resonant frequency. By altering the particle mass and damping parameters, you can simulate something like an automobile suspension, letting your particle track a stock's price like a Cadillac or a Corvette (or both, including intermediates) depending on your setup. Particles will have a natural resonance with a frequency that depends on its mass... A higher mass particle (i.e. higher inertia) will resonate at a lower frequency than one with a lower mass (and of course, in this indicator, you can display particles that interpolate through a range of masses.)

The real beauty of this general-purpose algorithm is that the force function can be extended with other components, affecting the trajectory of the particle; For instance "volume" could be factored into the current distance-based force function, strengthening or weakening the impulse accordingly. (I'll probably provide updates to the script that incoroprate different ideas I come up with.)

As currently pictured above, the indicator is interpolating between a medium-damped EMA-like configuration (red) and a more extension-damped suspension-like configuration (blue).

This indicator is merely a tool that provides a space to explore such a simulation, to let you see how tweaking parameters affects the simulations. It doesn't provide buy or sell signals, although you might find that it could be adapted into an MACD-like signal generator... But you're on your own for that.

הערות שחרור


Changed defaults to have a little more spread
תגובות
AItraders
Unique script, I look forward to better works in the future.
jasonnyberg
@AItraders, Thank you very much!
Yelian
Is it me or does the update not load up and display well?
jasonnyberg
@Yelian, I'll take a look at it again... It's working fine for me afaict
Yelian
@jasonnyberg, That's odd. I just tried it again and same thing, it just doesn't go on the chart like the prior script does. It looks all distorted and the scale on the right hand side goes out of whack when I put it on
jasonnyberg
@Yelian, can you check the parameters you're using? The defaults are (in order, when you click the indicator's settings "gear"):
2, 2, 3.5, .5, 0, 0,
close,
0, .9, -.3, 0, .5

I usually change "Mass" from 2 to 10 to give a wider spread of tracks, and it looks "good" to me at any time scale...
jasonnyberg
All those values are there in the captured chart at top as well, so you can compare against that as well.
If you can post a link to a simple chart that's exhibiting the issue, I can take a look at that too.
Yelian
This is amazing! It is exactly what I was looking for and can't wait to play around with it and see how it fits in my system. THANK YOU!

This is a silly question if we assume all empirical finds to be correct (empirical findings = markets are complex adaptive dynamic systems better understood and modeled using the physics of complexity theory) but I wonder if there are "optimal" parameters to be applied to all markets/time series. My gut feeling is that the "optimal" parameters are adaptive and dynamic and thus a unique to each time series and constantly evolving as the "true" optimal parameters would constitute a non-observable continuous random variable.

I'm also quite curious about further work on a mental model I have where prices as a proxy for the inner workings of the complex adaptive dynamic system (aka the pricing mechanism or "the markets") must obey Heisenberg's uncertainty principle when price is mapped onto a 2-dimensional Euclidean surface (your screen)...ok I'm done otherwise I'll be here typing for days and we all got better things to do. Thank you again!
kurtsmock
This is an idea that I am also pretty fascinated with. Markets clearly have physics... but real the illusive trick is identifying the proper way of measuring them so that you could create an accurate forecast. I appreciate you publishing this script.
jasonnyberg
@kurtsmock, Thank you! I too view the price of a commodity as being pushed and pulled on by many different forces. To me this script is a platform built to try to make sense out of these forces.
Alas, the hard part is trying to predict what the forces will be in the future, and that's a different animal entirely. :)
עוד