I want to document my experiments somewhere. This seems like a decent place. I like forums. Feedback is welcome.
------------------------
Cycles
My latest obsession is cycles. Been thinking a lot about what would be good ways to utilize Hilbert's Transform Dominant Cycle.
So today wrote a small script to compare how fixed length SMA looks compared to dc_period long SMA to see if I spot anything meaningful.
Code
#include <profile.c>
function run()
{
set(PLOTNOW);
BarPeriod = 1;
LookBack = 100;
StartDate = 20210702;
EndDate = 20210816;
vars seriesClose = series(priceClose());
var sma23 = SMA(seriesClose,23);
var period = HTDcPeriod(seriesClose);
plot("SMA 23", sma23, MAIN, RED);
plot("ASMA", adaptiveSma, MAIN, GREEN);
}
Conclusions are kind of obvious: - lags less when dominant cycle is shorter than fixed one - lags more when longer
Picked length 23 cause it looked like kind of average of what dominant cycle tends to spin around.
So I thought: "Ok... but how that visually compares to The Shapeshifter of MA`s aka KAMA"?
Code
var kama = KAMA(seriesClose, 23);
var veryAdaptiveKama = KAMA(seriesClose, period);
plot("KAMA 23", kama, MAIN, SILVER);
plot("VAKAMA", veryAdaptiveKama, MAIN, GREY);
The effect is same although SMA behaves much differently than KAMA.
So really... No huge revelations here.
Lets smash in some trade signals!!!111eleven
Code
#include <profile.c>
function run()
{
set(PLOTNOW);
BarPeriod = 1;
LookBack = 100;
StartDate = 20210702;
EndDate = 20210816;
vars seriesClose = series(priceClose());
var period = HTDcPeriod(seriesClose);
var sma22 = SMA(seriesClose,22);
var adaptiveSma = SMA(seriesClose,period);
var kama22 = KAMA(seriesClose, 22);
var veryAdaptiveKama = KAMA(seriesClose, period);
if (
price() > veryAdaptiveKama &&
veryAdaptiveKama > kama22 &&
veryAdaptiveKama > adaptiveSma &&
adaptiveSma > sma22 &&
rising(series(sma22))
) {
exitShort();
if (ProfitOpen >= 0) enterLong();
}
if (
price() < veryAdaptiveKama &&
veryAdaptiveKama < kama22 &&
veryAdaptiveKama < adaptiveSma &&
adaptiveSma < sma22 &&
falling(series(sma22))
) {
exitLong();
if (ProfitOpen >= 0) enterShort();
}
plot("SMA 22", sma22, MAIN, RED);
plot("ASMA", adaptiveSma, MAIN, GREEN);
plot("KAMA 22", kama22, MAIN, SILVER);
plot("VAKAMA", veryAdaptiveKama, MAIN, GREY);
plot("Profit Open", ProfitOpen, NEW, RED);
plot("HT Dc Period", period, NEW, BLACK);
}
Quote
Monte Carlo Analysis... Median AR 2509% Win 9100$ MI 6082$ DD 810$ Capital 2774$ Trades 2485 Win 42.7% Avg +36.6p Bars 67 AR 2631% PF 1.82 SR 0.00 UI 0% R2 1.00
For such randomness - PF of 1.82 ain't total disaster.