OPEN-SOURCE SCRIPT

Stochastic Ensembling of Outputs

124
Stochastic Ensembling of Outputs

🙏🏻 This is a simple tool/method that would solve naturally many well known problems:
  • “Price reversed 1 tick before the actual level, not executing my limit order”
  • “I consider intraday trend change by checking whether price is above/below VWAP, but is 1 tick enough? What to do, price is now whipsawing around vwap...”.
  • “I want to gradually accumulate a position around a chosen anchor. But where exactly should I put my orders? And I want to automate it ofc.“
  • “All these DSP adepts are telling you about some kind of noise in the markets… But how can I actually see it?”


The easy fix is to make things more analog less digital, by synthesizing numerous noise instances & adding it to any price-applied metric of yours. The ones who fw techno & psytrance, and other music, probably don’t need any more explanations. Then by checking not just 2 lines or 1 process against another one, you will be checking cloud vs cloud of lines, even allowing you to introduce proxies of probabilities. More crosses -> more confirmation to act.


How-to use:
The tool has 2 inputs: source and target:
  • Sources should always be the underlying process. If you apply the tool to price based metric, leave it hlcc4 unless you have a better one point estimate for each bar;
  • Target is your target, e.g if you want to apply it to VWAP, pick VWAP as target. You can thee on the chart above how trading activity recently never exactly touched VWAP, however noised instances of VWAP 'were' touched


The code is clean and written in modular form, you can simply copy paste it to any script of yours if you don't want to have multiple study-on-study script pairs.


snapshot
^^ applied to prev days highs and lows


snapshot
^^ applied to MBAD extensions and basis


snapshot
^^ applied to input series itself


Here’s how it works, no ML, no “AI”, no 1k lines of code, just stats:
The problem with metrics, even if they are time aware like WMA, is that they still do not directly gain information about “changes” between datapoints. If we pick noise characteristics to match these changes, we’d effectively introduce this info into our ops.


snapshot
^^ this screenshot represents 2 very different processes: a sine wave and white noise, see how the noise instances learned from each process differ significantly.


Changes can be represented as AR1 process. It’s dead simple, no PHD needed, it’s just how the current datapoint is related (or not) to the previous datapoint, no more than 1, and how this relationship holds/evolves over time. Unlike the mainstream approach like MLE, I estimate this relationship (phi parameter) via MoM but giving more weights to more recent datapoints via exponential smoothing over all the data available on your charts (so I encode temporal information), algocomplexity is O(1), lighting fast, just one pass. <- that gives phi, we’d use it as color for our noise generator

Then we just need to estimate noise amplitude (gamma) via checking what AR1 model actually thought vs the reality, variance of these innovations. Same via exponential smoothing, time aware, O(1), one pass, it’s all it does.

Then we generate white gaussian noise, and apply 2 estimated parameters (phi and gamma), and that’s all.


Omg, I think I just made my first real DSP script xd

Just like Monte Carlo for risk management, this is so simple and natural I can’t believe so many “pros” hide it and never talk about it in open access. Sharing it here on TradingView would’ve not done anything critical for em, but many would’ve benefited.


Clause de non-responsabilité

Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.