Moment-Based Adaptive DetectionMBAD (Moment-Based Adaptive Detection) : a method applicable to a wide range of purposes, like outlier or novelty detection, that requires building a sensible interval/set of thresholds. Unlike other methods that are static and rely on optimizations that inevitably lead to underfitting/overfitting, it dynamically adapts to your data distribution without any optimizations, MLE, or stuff, and provides a set of data-driven adaptive thresholds, based on closed-form solution with O(n) algo complexity.
1.5 years ago, when I was still living in Versailles at my friend's house not knowing what was gonna happen in my life tomorrow, I made a damn right decision not to give up on one idea and to actually R&D it and see what’s up. It allowed me to create this one.
The Method Explained
I’ve been wandering about z-values, why exactly 6 sigmas, why 95%? Who decided that? Why would you supersede your opinion on data? Based on what? Your ego?
Then I consciously noticed a couple of things:
1) In control theory & anomaly detection, the popular threshold is 3 sigmas (yet nobody can firmly say why xD). If your data is Laplace, 3 sigmas is not enough; you’re gonna catch too many values, so it needs a higher sigma.
2) Yet strangely, the normal distribution has kurtosis of 3, and 6 for Laplace.
3) Kurtosis is a standardized moment, a moment scaled by stdev, so it means "X amount of something measured in stdevs."
4) You generate synthetic data, you check on real data (market data in my case, I am a quant after all), and you see on both that:
lower extension = mean - standard deviation * kurtosis ≈ data minimum
upper extension = mean + standard deviation * kurtosis ≈ data maximum
Why not simply use max/min?
- Lower info gain: We're not using all info available in all data points to estimate max/min; we just pick the current higher and lower values. Lol, it’s the same as dropping exponential smoothing with alpha = 0 on stationary data & calling it a day.
You can’t update the estimates of min and max when new data arrives containing info about the matter. All you can do is just extend min and max horizontally, so you're not using new info arriving inside new data.
- Mixing order and non-order statistics is a bad idea; we're losing integrity and coherence. That's why I don't like the Hurst exponent btw (and yes, I came up with better metrics of my own).
- Max & min are not even true order statistics, unlike a percentile (finding which requires sorting, which requires multiple passes over your data). To find min or max, you just need to do one traversal over your data. Then with or without any weighting, 100th percentile will equal max. So unlike a weighted percentile, you can’t do weighted max. Then while you can always check max and min of a geometric shape, now try to calculate the 56th percentile of a pentagram hehe.
TL;DR max & min are rather topological characteristics of data, just as the difference between starting and ending points. Not much to do with statistics.
Now the second part of the ballet is to work with data asymmetry:
1) Skewness is also scaled by stdev -> so it must represent a shift from the data midrange measured in stdevs -> given asymmetric data, we can include this info in our models. Unlike kurtosis, skewness has a sign, so we add it to both thresholds:
lower extension = mean - standard deviation * kurtosis + standard deviation * skewness
upper extension = mean + standard deviation * kurtosis + standard deviation * skewness
2) Now our method will work with skewed data as well, omg, ain’t it cool?
3) Hold up, but what about 5th and 6th moments (hyperskewness & hyperkurtosis)? They should represent something meaningful as well.
4) Perhaps if extensions represent current estimated extremums, what goes beyond? Limits, beyond which we expect data not to be able to pass given the current underlying process generating the data?
When you extend this logic to higher-order moments, i.e., hyperskewness & hyperkurtosis (5th and 6th moments), they measure asymmetry and shape of distribution tails, not its core as previous moments -> makes no sense to mix 4th and 3rd moments (skewness and kurtosis) with 5th & 6th, so we get:
lower limit = mean - standard deviation * hyperkurtosis + standard deviation * hyperskewness
upper limit = mean + standard deviation * hyperkurtosis + standard deviation * hyperskewness
While extensions model your data’s natural extremums based on current info residing in the data without relying on order statistics, limits model your data's maximum possible and minimum possible values based on current info residing in your data. If a new data point trespasses limits, it means that a significant change in the data-generating process has happened, for sure, not probably—a confirmed structural break.
And finally we use time and volume weighting to include order & process intensity information in our model.
I can't stress it enough: despite the popularity of these non-weighted methods applied in mainstream open-access time series modeling, it doesn’t make ANY sense to use non-weighted calculations on time series data . Time = sequence, it matters. If you reverse your time series horizontally, your means, percentiles, whatever, will stay the same. Basically, your calculations will give the same results on different data. When you do it, you disregard the order of data that does have order naturally. Does it make any sense to you? It also concerns regressions applied on time series as well, because even despite the slope being opposite on your reversed data, the centroid (through which your regression line always comes through) will be the same. It also might concern Fourier (yes, you can do weighted Fourier) and even MA and AR models—might, because I ain’t researched it extensively yet.
I still can’t believe it’s nowhere online in open access. No chance I’m the first one who got it. It’s literally in front of everyone’s eyes for centuries—why no one tells about it?
How to use
That’s easy: can be applied to any, even non-stationary and/or heteroscedastic time series to automatically detect novelties, outliers, anomalies, structural breaks, etc. In terms of quant trading, you can try using extensions for mean reversion trades and limits for emergency exits, for example. The market-making application is kinda obvious as well.
The only parameter the model has is length, and it should NOT be optimized but picked consciously based on the process/system you’re applying it to and based on the task. However, this part is not about sharing info & an open-access instrument with the world. This is about using dem instruments to do actual business, and we can’t talk about it.
∞
Of
ICT Commitment of Traders° by toodegreesDescription:
The Commitment of Traders (COT) is a valuable raw data report released weekly by the Commodity Futures Trading Commission (CFTC). This report offers insights into the current long and short positions of three key market entities:
Commercial Traders ( usually represented in red )
Large Traders ( typically depicted in green )
Small Speculator Traders ( commonly shown in blue )
The concept of utilizing the COT data as a strategic trading tool was first introduced by Larry Williams, who emphasized the importance of monitoring Commercial Speculators – large corporate producers or consumers of commodities.
The Inner Circle Trader (ICT) prompts us to delve deeper into this data. While we can easily determine their Net Position (also referred to as the Main Program) by subtracting Commercial Short Positions from the Commercial Long Positions, this calculation doesn't reveal their ongoing Hedge Program .
Merely following the Main Program won't provide a trading edge. Aligning with the Hedge Program can be an invaluable weapon in your trading arsenal.
The Commercial Speculators' Hedge Program can be unveiled by examining the highest and lowest reading of their Net Position over a chosen time period and setting a new "zero line" between these extremes. This process generates a novel "COT Graph" providing a detailed understanding of the Commercial Speculators' current market activity.
When the Hedge Program, Seasonality, and Open Interest are cross-referenced with Institutional Orderflow, a trader can construct a very clear medium-to-long-term market narrative.
Features:
Access COT Data for the Commercial Speculators via Tradingview's reliable data source
Automate calculations and display the 3-month, 6-month, 12-month, 2-year, and 3-year Hedge Program
Define your own Custom Time Range for the Hedge Program
Display the Main Program and all Hedge Programs in an easy-to-understand table format
Additionally, by following the included instructions, you can augment your table with COT data from multiple markets. This extra information can help monitor correlated markets and develop a more robust market narrative:
Power Of Stocks - Bollinger Band & 5Ema Indicator - Keanu_RiTz
Power of Stocks - Bollinger band & 5ema Strategy
In this script you get to take Buy/Sell trades using the 3 options mentioned below.(Alerts with price levels for buy/sell at , SL & Target are included in this one)
1. Combined Strategy :- uses confirmation from both strategies to trade.
2. Bollinger band Strategy :- use the Bollinger band Strategy to trade.
3. 5ema Strategy :- use the 5ema Strategy to trade.
1. Combined Strategy :-
for Selling :- we will go short/sell only when conditions of both strategies are satisfied.
i.e. when a candle is completely above the upper Bollinger band & completely above the 5ema then it will be our Alert Candle.
We Short/Sell only when the low of the Alert candle is broken or when the candle closes below the close of the Alert Candle.
SL will be above high of the Alert Candle. Target will be minimum 1:3 or as per your emotions.
for Buying:- we will go Long/Buy only when conditions of both strategies are satisfied.
i.e. when a candle is completely below the lower Bollinger band & completely below the 5ema then it will be our Alert Candle.
We go Long/Buy only when the high of the Alert candle is broken or when the candle closes above the close of the Alert Candle.
SL will be below low of the Alert Candle. Target will be minimum 1:3 or as per your emotions.
2. Power of Stocks - Bollinger Band Strategy :-
Bollinger band with standard deviation = 1.5
when a candle is completely above the upper Bollinger band, that candle will be called a signal/alert candle.
Initiate a Sell trade when that alert candles low is broken. SL will be above high of that alert candle.
Risk to reward ratio will be 1:4 i.e. target will be 4 times the SL.
when a candle is completely below the lower Bollinger band, that candle will be called a signal/alert candle.
Initiate a Buy trade when that alert candles high is broken. SL will be below low of that alert candle.
Risk to reward ratio will be 1:4 i.e. target will be 4 times the SL.
other rules for Options buying:- minimum 15min timeframe
The day you initiate the position , you should be in profit above 10%-15% then only you should carry forward that position overnight, otherwise squareoff your trade on that day only.
Buy ATM or slightly OTM, SL max 100 points , target 1:4
for Long-term/Investing :- Minimum Weekly
If candle is outside the lower band then initiate a Buy trade when that candles High is broken. Sl will be below Low of that candle.
for Long-term Target will be according to your emotions.
3. Power of Stocks - 5ema Strategy (target minimum 1:3)
Timeframe -
5 min for Selling (Sell Futures/index/stocks or buy Put)
15 min for Buying (Buy Futures/index/stocks or sell Put)
for selling stocks :-
you should enter trade within 10am , don't look for entries after that time. take only 2 entries a day.
for selling Index(Banknifty) :-
you can take trade at anytime of the day whenever conditions get satisfied. you can take multiple entries in banknifty as it is very volatile.
for options choose atm strikes: selling trade
sl for premium between 200-300 :- 20-30 points SL
sl for premium between 400-500 :- 40-50 points SL
sl for premium between 500-600 :- 50-60 points SL
Subhashish Pani's (power of stocks) 5 EMA Strategy:-
It plots 5 EMA and Buy/Sell signals with Target & Stoploss levels.
What is Subhashish Pani's (power of stocks) 5 EMA Strategy :-
His strategy is very simple to understand. for intraday use 5 minutes timeframe for selling. You can sell futures, sell call or buy Puts in selling strategy.
What this strategy tries to do is , it tries to catch the tops, so when you sell at top & it turns out to be a reversal point then you can get good profit.
this will hit stop losses often, but stop losses are small and minimum target should be 1:3. but if you stay with the trend you can get big profits.
According to Subhashish Pani this strategy has 60% success rate.
Strategy for Selling (Short future/Call/stock or buy Put)
When ever a Candle closes completely above 5 ema (no part of candle should be touching the 5ema), then that candle should be considered as Alert Candle.
If the next candle is also completely above 5 ema and it has not broken the low of previous alert candle, Then the previous Alert Candle should be ignored and the new candle should be considered as new Alert Candle.
so if this goes on then continue shifting the Alert Candle, but whenever the next candle breaks the low of the Alert Candle we should take the Short trade (Short future/Call/stock or buy Put).
Stoploss will be above high of the Alert Candle and minimum target will be 1:3.
Strategy for Buying (Buy future/Call/stock or sell Put)
When ever a Candle closes completely below 5 ema (no part of candle should be touching the 5ema), then that candle should be considered as Alert Candle.
If the next candle is also completely below 5 ema and it has not broken the high of previous alert candle, Then the previous Alert Candle should be ignored and the new candle should be considered as new Alert Candle.
so if this goes on then continue shifting the Alert Candle, but whenever the next candle breaks the high of the Alert Candle we should take the Long trade (Buy future/Call/stock or sell Put).
Stoploss will be below low of the Alert Candle and minimum target will be 1:3.
Buy/Sell with extra conditions :
it just adds 1 more condition to buying/selling
1. checks if closing of current candle is lower than alert candles closing for Selling & checks if closing of current candle is higher than alert candles closing for Buyling.
This can sometimes save you from false moves but by using this, you can also miss out on big moves as you'll enter trade after candle closing instead of entering at break of high/low.
Note :- According to Subhashish Pani Timeframe for intraday buying should be 15 minutes Timeframe.
If you haven't understood the strategy by reading above description, then search for "Subhashish Pani's (power of stocks) 5 EMA Strategy" on YouTube to get a deeper understanding.
Note:- This is not only for Intraday trading , you can use this strategy for Positional/Swing trading as well. If you use this on Monthly Timeframe then it can be very good for Long Term Investing as well.
Rules will be same for all types of trades & Timeframes.
Moving average of 1-period Percent ChangeAnother way of finding the average range of the bars using 1 period percentage change of the price and taking an average of them. It's given in percentages and the absolute value of the average can be shown when the option is turned on, or the average including the up and down bars can be shown. Perhaps an alternative way of looking at volatility or range of the bars. If you prefer a line version over histogram, just simply change the style under the settings of the indicator.
Exponential Regression Slope Annualized with R-squared HistogramMy other indicator shows the linear regression slope of the source. This one finds the exponential regression slope and optionally multiplies it by R-squared and optionally annualizes it. Multiplying by R-squared makes sure that the price movement was significant in order to avoid volatile movements that can throw off the slope value. Annualizing the exponential slope will let you see how much percentage you will make in a year if the price continues at its current pace.
The annualized number is the number of trading days in a year. This and the length might need adjusting for the extra bars that might be in futures or other markets. The number does not have to be a year. For example, it can be a month if you set the number to 20 or so trading days to find how much you would make in a month if price continues at its current pace, etc. This can also be used as an alternative to relative strength or rate of change.
Open Interest Rank-BuschiEnglish:
One part of the "Commitment of Traders-Report" is the Open Interest which is shown in this indicator (source: Quandl database).
Unlike my also published indicator "Open Interest-Buschi", the values here are not absolute but in a ranking system from 0 to 100 with individual time frames-
The following futures are included:
30-year Bonds (ZB)
10-year Notes ( ZN )
Soybeans (ZS)
Soybean Meal (ZM)
Soybean Oil (ZL)
Corn ( ZC )
Soft Red Winter Wheat (ZW)
Hard Red Winter Wheat (KE)
Lean Hogs (HE)
Live Cattle ( LE )
Gold ( GC )
Silver (SI)
Copper (HG)
Crude Oil ( CL )
Heating Oil (HO)
RBOB Gasoline ( RB )
Natural Gas ( NG )
Australian Dollar (A6)
British Pound (B6)
Canadian Dollar (D6)
Euro (E6)
Japanese Yen (J6)
Swiss Franc (S6)
Sugar ( SB )
Coffee (KC)
Cocoa ( CC )
Cotton ( CT )
S&P 500 E-Mini (ES)
Russell 2000 E-Mini (RTY)
Dow Jones Industrial Mini (YM)
Nasdaq 100 E-Mini (NQ)
Platin (PL)
Palladium (PA)
Aluminium (AUP)
Steel ( HRC )
Ethanol (AEZ)
Brent Crude Oil (J26)
Rice (ZR)
Oat (ZO)
Milk (DL)
Orange Juice (JO)
Lumber (LS)
Feeder Cattle (GF)
S&P 500 ( SP )
Dow Jones Industrial Average Index (DJIA)
New Zealand Dollar (N6)
Deutsch:
Ein Bestandteil des "Commitment of Traders-Report" ist das Open Interest, das in diesem Indikator dargestellt wird (Quelle: Quandl Datenbank).
Anders als in meinem ebenfalls veröffentlichten Indikator "Open Interest-Buschi" werden hier nicht die absoluten Werte dargestellt, sondern in einem Ranking-System von 0 bis 100 mit individuellen Zeitrahmen.
Folgende Futures sind enthalten:
30-jährige US-Staatsanleihen (ZB)
10-jährige US-Staatsanleihen ( ZN )
Sojabohnen(ZS)
Sojabohnen-Mehl (ZM)
Sojabohnen-Öl (ZL)
Mais( ZC )
Soft Red Winter-Weizen (ZW)
Hard Red Winter-Weizen (KE)
Magerschweine (HE)
Lebendrinder ( LE )
Gold ( GC )
Silber (SI)
Kupfer(HG)
Rohöl ( CL )
Heizöl (HO)
Benzin ( RB )
Erdgas ( NG )
Australischer Dollar (A6)
Britisches Pfund (B6)
Kanadischer Dollar (D6)
Euro (E6)
Japanischer Yen (J6)
Schweizer Franken (S6)
Zucker ( SB )
Kaffee (KC)
Kakao ( CC )
Baumwolle ( CT )
S&P 500 E-Mini (ES)
Russell 2000 E-Mini (RTY)
Dow Jones Industrial Mini (YM)
Nasdaq 100 E-Mini (NQ)
Platin (PL)
Palladium (PA)
Aluminium (AUP)
Stahl ( HRC )
Ethanol (AEZ)
Brent Rohöl (J26)
Reis (ZR)
Hafer (ZO)
Milch (DL)
Orangensaft (JO)
Holz (LS)
Mastrinder (GF)
S&P 500 ( SP )
Dow Jones Industrial Average Index (DJIA)
Neuseeland Dollar (N6)
Open Interest-Buschi
English:
One part of the "Commitment of Traders-Report" is the Open Interest which is shown in this indicator (source: Quandl database).
The following futures are included:
30-year Bonds (ZB)
10-year Notes (ZN)
Soybeans (ZS)
Soybean Meal (ZM)
Soybean Oil (ZL)
Corn (ZC)
Soft Red Winter Wheat (ZW)
Hard Red Winter Wheat(KE)
Lean Hogs (HE)
Live Cattle (LE)
Gold (GC)
Silver (SI)
Copper (HG)
Crude Oil (CL)
Heating Oil (HO)
RBOB Gasoline (RB)
Natural Gas (NG)
Australian Dollar (A6)
British Pound (B6)
Canadian Dollar (D6)
Euro (E6)
Japanese Yen (J6)
Swiss Franc (S6)
Sugar (SB)
Coffee (KC)
Cocoa (CC)
Cotton (CT)
S&P 500 E-Mini (ES)
Russell 2000 E-Mini (RTY)
Dow Jones Industrial Mini (YM)
Nasdaq 100 E-Mini (NQ)
Platin (PL)
Palladium (PA)
Aluminium (AUP)
Steel (HRC)
Ethanol (AEZ)
Brent Crude Oil (J26)
Rice (ZR)
Oat (ZO)
Milk (DL)
Orange Juice (JO)
Lumber (LS)
Feeder Cattle (GF)
S&P 500 (SP)
Dow Jones Industrial Average Index (DJIA)
New Zealand Dollar (N6)
Deutsch:
Ein Bestandteil des "Commitment of Traders-Report" ist das Open Interest, das in diesem Indikator dargestellt wird (Quelle: Quandl Datenbank).
Folgende Futures sind enthalten:
30-jährige US-Staatsanleihen (ZB)
10-jährige US-Staatsanleihen (ZN)
Sojabohnen(ZS)
Sojabohnen-Mehl (ZM)
Sojabohnen-Öl (ZL)
Mais(ZC)
Soft Red Winter-Weizen (ZW)
Hard Red Winter-Weizen (KE)
Magerschweine (HE)
Lebendrinder (LE)
Gold (GC)
Silber (SI)
Kupfer(HG)
Rohöl (CL)
Heizöl (HO)
Benzin (RB)
Erdgas (NG)
Australischer Dollar (A6)
Britisches Pfund (B6)
Kanadischer Dollar (D6)
Euro (E6)
Japanischer Yen (J6)
Schweizer Franken (S6)
Zucker (SB)
Kaffee (KC)
Kakao (CC)
Baumwolle (CT)
S&P 500 E-Mini (ES)
Russell 2000 E-Mini (RTY)
Dow Jones Industrial Mini (YM)
Nasdaq 100 E-Mini (NQ)
Platin (PL)
Palladium (PA)
Aluminium (AUP)
Stahl (HRC)
Ethanol (AEZ)
Brent Rohöl (J26)
Reis (ZR)
Hafer (ZO)
Milch (DL)
Orangensaft (JO)
Holz (LS)
Mastrinder (GF)
S&P 500 (SP)
Dow Jones Industrial Average Index (DJIA)
Neuseeland Dollar (N6)
Commercial / Open Interest-Buschi
English:
Another view the Commitment of Traders (CoT) data
Since the Commercials are often a good indicator for future market movements, I tampered a little bit with their positioning (long or short) in relation to the open interest to visualize some kind of "commercial buying (long) or selling (short) power". It's definitely nothing more than work in progress, but I decided to publish it anyway. Critical comments are mostly welcome.
Deutsch:
Ein weiterer Blick auf die Commitment of Traders (CoT) Daten
Da die Commercials häufig ein guter Indikator für zukünftige Marktbewegungen sind, habe ich ein wenig mit ihrer Positionierung (long oder short) im Verhältnis zum Open Interest herumgebastelt, um eine Art von "kommerzieller Kauf- (long) oder Verkaufs-Kraft" abzubilden. Es ist momentan noch im absoluten Teststadium, aber ich habe mich dazu entschlossen, es trotzdem zu veröffentlichen. Kritische Anmerkungen sind sehr willkommen.
Balance of Power [Lake Oats] Balance of Power indicator - Useful tool for finding great Timing upon Entering Postions and Existing Postions, Also Useful for finding Normal and Hidden Divergences
HEIKIN ASHI COLOUR CHANGE ALERTThis can be used to trigger an alert if Heikin Ashi bar changes color :)
Rate Of Change - Absolute ValueMeasures the period's change in terms of the instrument's value (e.g. pip, dollar, etc) instead of as a percentage. I generally use it on a daily time frame with a period=1 to see how the current day's move compares with prior days' moves in order to gain a perspective into how this move ranks historically.
SN Smoothed Balance of Power v2Hi all,
here is an updated version of the indicator script I published yesterday.
The goal of this indicator is to try and find darkpool activity. The indicator itself is not enough to fully identify darkpool but it should be able to detect quiet accumulation. What makes this Balance of Power different from others on TV is that it is smoothed by using a moving average.
Notes:
- The values that are default are completely arbitrary except for the VWMA length (a 14-day period for the 1D chart is the norm). For instance the limit where it shows red/green I picked because it works best for the 1D chart I am using. Other TF's and charts will need tweaking of all the values you find in the options menu to get the best results.
- I modified the indicator such that it is usable on charts that do not show volume. HOWEVER, this chart is default to NYMEX: CL1!. To get different volume data this needs to be changed in the option menu.
- I am in no way an expert on darkpool/HFT trading and am merely going from the information I found on the internet. Consider this an experiment.
Credits:
- Lazybear for some of the plotting-code
- Igor Livshin for the formula
- TahaBintahir for the Symbol-code (although I'm not sure who the original author is...)