4 registered members (7th_zorro, Quad, VoroneTZ, 1 invisible),
623
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Lapsa's very own thread
#483948
08/17/21 13:08
08/17/21 13:08
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
I want to document my experiments somewhere. This seems like a decent place. I like forums. Feedback is welcome. ------------------------ CyclesMy 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.
#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"?
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
#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);
}
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.
Last edited by Lapsa; 08/17/21 20:45.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#483949
08/17/21 20:10
08/17/21 20:10
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Ehler's "Modified Simple Moving Averages"
#include <profile.c>
var ModifiedSMA(var* Data, var* FractionalCoefficients)
{
var sum=0., coefficientSum=0.;
int i;
int period=sizeof(FractionalCoefficients);
for(i=0; i<period; i++) {
sum += (Data[i] * FractionalCoefficients[i]);
coefficientSum += FractionalCoefficients[i];
}
return sum / coefficientSum;
}
function run()
{
set(PLOTNOW);
BarPeriod = 1;
LookBack = 100;
StartDate = 20210702;
EndDate = 20210816;
vars seriesClose = series(priceClose());
var sma = SMA(seriesClose, 4);
var coefficients[] = {.5,1,1,1,.5};
var modifiedSMA = ModifiedSMA(seriesClose, coefficients);
var weirdCoefficients[] = {.2,1,1.6,1,.2};
var weirdSMA = ModifiedSMA(seriesClose, weirdCoefficients);
var weirderCoefficients[] = {.1,1,1,1.7,.2};
var weirderSMA = ModifiedSMA(seriesClose, weirderCoefficients);
var shouldBeFastestCoefficients[] = {2,.2,1.2,.2,.4};
var shouldBeFastest = ModifiedSMA(
seriesClose, shouldBeFastestCoefficients
);
plot("SMA 4", sma, MAIN, RED);
plot(".5 1 1 1 .5", modifiedSMA, MAIN, BLUE);
plot(".2 1 1.6 1 .2", weirdSMA, MAIN, GREEN);
plot(".1 1 1 1.7 .2", weirderSMA, MAIN, MAGENTA);
plot("2 .2 1.2 .2 .4", shouldBeFastest, MAIN, CYAN);
}
Last edited by Lapsa; 08/17/21 20:45.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#483950
08/17/21 20:44
08/17/21 20:44
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
EMA RibbonSo I've been reading that book. Yesterday it got me wondering - how exactly EMAs with varying alphas look like.
#include <profile.c>
function run()
{
set(PLOTNOW);
BarPeriod = 1;
LookBack = 100;
StartDate = 20210702;
EndDate = 20210816;
vars closes = series(priceClose());
var ema1 = EMA(closes,.1);
var ema2 = EMA(closes,.2);
var ema3 = EMA(closes,.3);
var ema4 = EMA(closes,.4);
var ema5 = EMA(closes,.5);
var ema6 = EMA(closes,.6);
var ema7 = EMA(closes,.7);
var ema8 = EMA(closes,.8);
var ema9 = EMA(closes,.9);
var ema10 = EMA(closes,.15);
plot(".1", ema1, MAIN, RED);
plot(".2", ema2, MAIN, GREEN);
plot(".3", ema3, MAIN, BLUE);
plot(".4", ema4, MAIN, ORANGE);
plot(".5", ema5, MAIN, BLACK);
plot(".6", ema6, MAIN, MAGENTA);
plot(".7", ema7, MAIN, OLIVE);
plot(".8", ema8, MAIN, PURPLE);
plot(".9", ema9, MAIN, LIGHTBLUE);
plot(".15", ema10, MAIN, MAROON);
}
Looks beautiful. Can't help but see that graph in 3D. Reminds me of Sietches from Dune. Ohkay... Is there an application for bunch of EMAs? One of the most obvious "Market inefficiencies" for an algo trader to exploit is automation itself. Got me wondering how would ribbon look like with more commonly used time periods.
#include <profile.c>
function run()
{
set(PLOTNOW);
BarPeriod = 1;
LookBack = 1500;
StartDate = 20210703;
EndDate = 20210816;
vars closes = series(priceClose());
var ema2 = EMA(closes,2);
var ema5 = EMA(closes,5);
var ema15 = EMA(closes,15);
var ema30 = EMA(closes,30);
var ema45 = EMA(closes,45);
var ema60 = EMA(closes,60);
var ema120 = EMA(closes,120);
var ema180 = EMA(closes,180);
var ema240 = EMA(closes,240);
var ema1440 = EMA(closes,1440);
plot("2", ema2, MAIN, SILVER + TRANSP);
plot("5", ema5, MAIN, CYAN + TRANSP);
plot("15", ema15, MAIN, GREEN + TRANSP);
plot("30", ema30, MAIN, MAGENTA);
plot("45", ema45, MAIN, BLUE);
plot("60", ema60, MAIN, DARKBLUE);
plot("120", ema120, MAIN, PURPLE);
plot("180", ema180, MAIN, MAROON);
plot("240", ema240, MAIN, RED);
plot("1440", ema1440, MAIN, BLACK);
}
Frikin sea waves! Lets smash in some trade signals!!!111eleven
#include <profile.c>
function run()
{
set(NFA|PRELOAD|PLOTNOW);
BarPeriod = 1;
LookBack = 2000;
StartDate = 20210703;
EndDate = 20210716;
BarMode = BR_FLAT;
History = "*.t6";
Amount = 8;
Capital = 600;
// MaxLong = 5;
// MaxShort = 5;
// Stop = ATR(100) * 10;
vars closes = series(priceClose());
vars ema2 = series(KAMA(closes,2));
vars ema5 = series(EMA(closes,5));
vars ema15 = series(EMA(closes,14));
vars ema30 = series(EMA(closes,27));
vars ema45 = series(EMA(closes,44));
vars ema60 = series(EMA(closes,60));
vars ema120 = series(EMA(closes,120));
vars ema180 = series(EMA(closes,181));
vars ema240 = series(EMA(closes,235));
vars ema1440 = series(EMA(closes,1433));
if (
rising(ema2)
&& rising(ema5)
&& rising(ema15)
&& rising(ema30)
&& rising(ema45)
&& rising(ema60)
&& rising(ema120)
&& rising(ema180)
&& rising(ema240)
&& rising(ema1440)
&& ema2[0] > ema15[0]
&& ema15[0] > ema30[0]
&& ema30[0] > ema45[0]
&& ema45[0] > ema60[0]
&& ema120[0] > ema180[0]
&& ema180[0] > ema240[0]
&& ema240[0] < ema1440[0]
) enterLong(Amount);
if (
falling(ema2)
&& falling(ema5)
&& falling(ema15)
&& falling(ema30)
&& falling(ema45)
&& falling(ema60)
&& falling(ema120)
&& falling(ema180)
&& falling(ema240)
&& falling(ema1440)
&& ema2[0] < ema15[0]
&& ema15[0] < ema30[0]
&& ema30[0] < ema45[0]
&& ema45[0] < ema60[0]
&& ema120[0] < ema180[0]
&& ema180[0] < ema240[0]
&& ema240[0] > ema1440[0]
) enterLong(Amount);
if (crossUnder(ema5, ema45))
exitShort();
if (crossOver(ema5, ema45))
exitLong();
}
Monte Carlo Analysis... Median AR 2070% Win 10650$ MI 23156$ DD 2952$ Capital 666$ Trades 532 Win 62.6% Avg +25.0p Bars 59 CAGR 163492235397780660000000000000000000.00% PF 2.41 SR 0.00 UI 0% R2 1.00 Chart...
Finetuned af. Likes to randomly pop up Margin Calls.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#483960
08/18/21 10:58
08/18/21 10:58
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Ehler's "Modified Least-Squares Quadratics"
#include <profile.c>
var ModifiedSMA(var* Data, var* FractionalCoefficients)
{
var sum=0., coefficientSum=0.;
int i;
int period=sizeof(FractionalCoefficients);
for(i=0; i<period; i++) {
sum += (Data[i] * FractionalCoefficients[i]);
coefficientSum += FractionalCoefficients[i];
}
return sum / coefficientSum;
}
function run()
{
set(PLOTNOW);
BarPeriod = 1;
LookBack = 100;
StartDate = 20210702;
EndDate = 20210816;
vars seriesClose = series(priceClose());
var sma = SMA(seriesClose, 5);
var c1[] = {7,24,34,24,7};
var c2[] = {1,6,12,14,12,6,1};
var c3[] = {-1,28,78,108,118,108,78,28,-1};
var c4[] = {-11,18,88,138,168,178,168,138,88,18,-11};
var m1 = ModifiedSMA(seriesClose, c1);
var m2 = ModifiedSMA(seriesClose, c2);
var m3 = ModifiedSMA(seriesClose, c3);
var m4 = ModifiedSMA(seriesClose, c4);
// [7 24 34 24 7] / 96
// [1 6 12 14 12 6 1] / 52
// [−1 28 78 108 118 108 78 28 −1] / 544
// [−11 18 88 138 168 178 168 138 88 18 −11] / 980
plot("SMA 5", sma, MAIN, RED);
plot("c1", m1, MAIN, BLUE);
plot("c2", m2, MAIN, GREEN);
plot("c3", m3, MAIN, MAGENTA);
plot("c4", m4, MAIN, CYAN);
}
Last edited by Lapsa; 08/18/21 10:58.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#483962
08/18/21 11:26
08/18/21 11:26
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
2 Pole Butterworth filter The Butterworth filter is a type of signal processing filter designed to have a frequency response as flat as possible in the passband. It is also referred to as a maximally flat magnitude filter.
Properties of the Butterworth filter are: - monotonic amplitude response in both passband and stopband - Quick roll-off around the cutoff frequency, which improves with increasing order - Considerable overshoot and ringing in step response, which worsens with increasing order - Slightly non-linear phase response - Group delay largely frequency-dependent
#include <profile.c>
var Butterworth2Pole(var* Data, int Period)
{
var a = exp(-1.414*PI/Period);
var b = 2*a*cos(1.414*1.25*180/Period);
var c2 = b;
var c3 = -a*a;
var c1 = 1-c2-c3;
var* Filt = series(*Data,3);
// syntax error? TODO: check what happened w/ SETSERIES
// SETSERIES(Data,0);
series(Data[0],0); // is that an equivalent?
return Filt[0] = c1*Data[0] + c2*Filt[1] + c3*Filt[2];
}
function run()
{
set(PLOTNOW);
BarPeriod = 1;
LookBack = 100;
StartDate = 20210702;
EndDate = 20210816;
vars seriesClose = series(priceClose());
var sma = SMA(seriesClose, 5);
var butt = Butterworth2Pole(seriesClose, 5);
var butt3Pole = Butterworth(seriesClose, 5);
plot("SMA 5", sma, MAIN, SILVER);
plot("2 Pole Butt", butt, MAIN, RED);
plot("3 Pole Butt", butt3Pole, MAIN, BLUE);
}
Last edited by Lapsa; 08/18/21 11:59.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#483964
08/18/21 18:26
08/18/21 18:26
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Ehler's Decycler Oscillator (fixed) Trigonometric functions (Sine, Cosine etc) expect angles in degrees (0..360), while in C and in most other languages angles are in radians (0..2*PI). Log is the logarithm base e as in C.
Seemingly best use: - set long periods - 0 crossover for uptrend - 0 crossunder for downtrend
#include <profile.c>
var rad(var degrees) { return degrees*PI/180; }
var rcos(var degrees) { return cos(rad(degrees)); }
var rsin(var degrees) { return sin(rad(degrees)); }
var DecyclerOscillator(var* Close, var HPPeriod1, var HPPeriod2) // 30 60
{
var alpha1;
var alpha2;
var* hp1 = series(0,3);
var* hp2 = series(0,3);
alpha1 =
(rcos(.707*360/HPPeriod1)+
rsin(.707*360/HPPeriod1)-1)
/rcos(.707*360/HPPeriod1);
alpha2 =
(rcos(.707*360/HPPeriod2)+
rsin(.707*360/HPPeriod2)-1)/
rcos(.707*360/HPPeriod2);
hp1[0] = (1-alpha1/2)*(1-alpha1/2)*
(Close[0]-2*Close[1]+Close[2])+
2*(1-alpha1)*hp1[1]-(1-alpha1)*
(1-alpha1)*hp1[2];
hp2[0] = (1-alpha2/2)*(1-alpha2/2)*
(Close[0]-2*Close[1]+Close[2])+
2*(1-alpha2)*hp2[1]-(1-alpha2)*
(1-alpha2)*hp2[2];
return hp2[0] - hp1[0];
}
function run()
{
set(PLOTNOW);
BarPeriod = 1;
LookBack = 100;
StartDate = 20210702;
EndDate = 20210816;
vars closes = series(priceClose());
var osc = DecyclerOscillator(closes, 30, 60);
var zma = ZMA(closes, 30);
plot("ZMA", zma, MAIN, BLACK);
plot("Decycler OSC", osc, NEW, BLACK);
}
Refactored:
var DecyclerOscillator(var* Close, var HPPeriod1, var HPPeriod2) // 30 60
{
return HighPass2(Close, HPPeriod2) - HighPass2(Close, HPPeriod1);
}
Last edited by Lapsa; 08/21/21 23:34.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#483967
08/19/21 20:24
08/19/21 20:24
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Ehler's "Adaptive Stochastic Indicator"I'm proud and happy I pulled this one through. Well... Sort of. Running Tests multiple times produces different results. Not sure why. Yay! Something memory, variables, pointers whatnot related. `MaxPwr` looks like potential troublemaker. Interestingly, adaptive CCI source code has this:
//Find Maximum Power Level for Normalization
MaxPwr = .991*MaxPwr[1];
Also - overall computation seems notoriously slow. Like 3 seconds for a single day. Something I've been doing wrong. When it works - results look legit. Haven't finished the book. Not sure if this one is supposed to be equivalent of Zorro's bundled StochEhlers indicator. They do look similar although Zorro's one got some of that buttery smoothing. All in all - fun but unusable. TODO: try to identify the issue by replacing snippets with in-built stuff (e.g. center of gravity)
#include <profile.c>
var rad(var degrees) { return degrees*PI/180; }
var rcos(var degrees) { return cos(rad(degrees)); }
var rsin(var degrees) { return sin(rad(degrees)); }
var AdaptiveStochastic(vars Close)
{
var AvgLength = 3;
var M;
var N;
var X;
var Y;
var alpha1;
var* HP = series(0,3);
var a1;
var b1;
var c1;
var c2;
var c3;
var* Filt = series(0,3);
var Lag;
var count;
var Sx;
var Sy;
var Sxx;
var Syy;
var Sxy;
var Period;
var Sp;
var Spx;
var* MaxPwr = series(0,3);
var DominantCycle;
var* Corr = series(0, 48);
var* CosinePart = series(0, 48);
var* SinePart = series(0, 48);
var* SqSum = series(0, 48);
var R[48][2];
var Pwr[48];
//Highpass filter cyclic components whose periods are shorter than 48 bars
alpha1 = (rcos(.707*360 / 48) + rsin(.707*360 / 48) - 1) / rcos(.707*360 / 48);
HP[0] = (1 - alpha1 / 2)*(1 - alpha1 / 2)*
(Close[0] - 2*Close[1] + Close[2]) +
2*(1 - alpha1)*HP[1] -
(1 - alpha1) * (1 - alpha1)*HP[2];
//Smooth with a Super Smoother Filter from equation 3-3
a1 = exp(-1.414*3.14159 / 10);
b1 = 2*a1*rcos(1.414*180 / 10);
c2 = b1;
c3 = -a1*a1;
c1 = 1 - c2 - c3;
Filt[0] = c1*(HP[0] + HP[1]) / 2 + c2*Filt[1] + c3*Filt[2];
//Pearson correlation for each value of lag
for (Lag = 0; Lag < 48; Lag++) {
//Set the averaging length as M
M = AvgLength;
if (AvgLength == 0) M = Lag;
Sx = 0;
Sy = 0;
Sxx = 0;
Syy = 0;
Sxy = 0;
for (count = 0; count < M - 1; count++) {
X = Filt[count];
Y = Filt[Lag + count];
Sx = Sx + X;
Sy = Sy + Y;
Sxx = Sxx + X*X;
Sxy = Sxy + X*Y;
Syy = Syy + Y*Y;
}
if ( (M*Sxx - Sx*Sx)*(M*Syy - Sy*Sy) > 0 ) {
Corr[Lag] = (M*Sxy - Sx*Sy)/sqrt((M*Sxx-Sx*Sx)*(M*Syy-Sy*Sy));
}
}
for (Period = 0; Period < 48; Period++) {
CosinePart[Period] = 0;
SinePart[Period] = 0;
for(N = 3; N < 48; N++) {
CosinePart[Period] = CosinePart[Period] + Corr[N]*rcos(360*N / Period);
SinePart[Period] = SinePart[Period] + Corr[N]*rsin(360*N / Period);
}
SqSum[Period] = CosinePart[Period]*CosinePart[Period] +
SinePart[Period]*SinePart[Period];
}
for (Period = 0; Period < 48; Period++) {
R[Period][2] = R[Period][1];
R[Period][1] = .2*SqSum[Period]*SqSum[Period] +.8*R[Period][2];
}
// Find Maximum Power Level for Normalization
MaxPwr[0] = .995*MaxPwr[1];
for (Period = 10; Period < 48; Period++) {
if (R[Period][1] > MaxPwr[0]) MaxPwr[0] = R[Period][1];
}
for (Period = 3; Period < 48; Period++) {
Pwr[Period] = R[Period][1] / MaxPwr[0];
}
//Compute the dominant cycle using the CG of the spectrum
Spx = 0;
Sp = 0;
for(Period = 10; Period < 48; Period++) {
if (Pwr[Period] >= .5) {
Spx = Spx + Period*Pwr[Period];
Sp = Sp + Pwr[Period];
}
}
if (Sp != 0) DominantCycle = Spx / Sp;
if (DominantCycle < 10) DominantCycle = 10;
if (DominantCycle > 48) DominantCycle = 48;
//Stochastic Computation starts here
var* HighestC = series(0, 3);
var* LowestC = series(0, 3);
var* Stoc = series(0, 3);
var* SmoothNum = series(0, 3);
var* SmoothDenom = series(0, 3);
var* AdaptiveStochastic = series(0, 3);
HighestC[0] = Filt[0];
LowestC[0] = Filt[0];
for (count = 0; count < DominantCycle - 1; count++ ) {
if (Filt[count] > HighestC[0]) HighestC[0] = Filt[count];
if (Filt[count] < LowestC[0]) LowestC[0] = Filt[count];
}
Stoc[0] = (Filt[0] - LowestC[0]) / (HighestC[0] - LowestC[0]);
return AdaptiveStochastic[0] =
c1*(Stoc[0] + Stoc[1]) / 2 + c2*AdaptiveStochastic[1] + c3*AdaptiveStochastic[2];
}
function run()
{
set(PLOTNOW);
BarPeriod = 1;
LookBack = 500;
StartDate = 20210809;
EndDate = 20210810;
vars closes = series(priceClose(), 48);
var astoch = AdaptiveStochastic(closes);
var original = StochEhlers(closes, 48, 10, 48);
plot("ASTOCH", astoch, NEW, RED);
plot("Zorro`s EStoch", original, NEW, BLUE);
}
Last edited by Lapsa; 08/19/21 20:49.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#483972
08/20/21 17:25
08/20/21 17:25
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Ehler's "Even Better Sinewave"Looks usable.
#include <profile.c>
var rad(var degrees) { return degrees*PI/180; }
var rcos(var degrees) { return cos(rad(degrees)); }
var rsin(var degrees) { return sin(rad(degrees)); }
var EvenBetterSinewave(vars Close, var Duration)
{
var alpha1;
var* HP = series(1,2);
var a1;
var b1;
var c1;
var c2;
var c3;
var* Filt = series(1,3);
var count;
var Wave;
var Pwr;
// HighPass filter cyclic components whose periods are shorter than Duration input
alpha1 = (1 - rsin(360 / Duration)) / rcos(360 / Duration);
HP[0] = .5*(1 + alpha1)*(Close[0] - Close[1]) + alpha1*HP[1];
// Smooth with a Super Smoother Filter from equation 3-3
a1 = exp(-1.414*3.14159 / Duration);
b1 = 2*a1*rcos(1.414*180 / Duration);
c2 = b1;
c3 = -a1*a1;
c1 = 1 - c2 - c3;
Filt[0] = c1*(HP[0] + HP[1]) / 2 + c2*Filt[1] + c3*Filt[2];
// 3 Bar average of Wave amplitude and power
Wave = (Filt[0] + Filt[1] + Filt[2]) / 3;
Pwr = (Filt[0]*Filt[0] + Filt[1]*Filt[1] + Filt[2]*Filt[2]) / 3;
// Normalize the Average Wave to Square Root of the Average Power
return Wave / sqrt(Pwr);
}
function run()
{
set(PLOTNOW);
BarPeriod = 1;
LookBack = 100;
StartDate = 20210702;
EndDate = 20210816;
vars close = series(priceClose());
var evenBetterSinewave = EvenBetterSinewave(close, 10);
plot("EBSW", evenBetterSinewave, NEW, BLACK);
}
Refucktored version:
#include <profile.c>
var EvenBetterSinewave(vars Close, var Duration)
{
var Wave;
var Pwr;
var* HP = series(HighPass1(Close, Duration), 2);
if (HP[0] == 0) HP[0] = 1;
var* Filt = series(Smooth(HP, Duration), 3);
Wave = SMA(Filt, 3);
Pwr = (Filt[0]*Filt[0] + Filt[1]*Filt[1] + Filt[2]*Filt[2]) / 3;
return Wave / sqrt(Pwr);
}
function run()
{
set(PLOTNOW);
BarPeriod = 1;
LookBack = 100;
StartDate = 20210702;
EndDate = 20210816;
vars close = series(priceClose());
var evenBetterSinewave = EvenBetterSinewave(close, 10);
plot("EBSW", evenBetterSinewave, NEW, BLACK);
}
Comparison with [CC] EBSW indicator on TradingView: Interestingly - that one allows setting HighPass length separately from SuperSmoothFilter length. Like this:
var EvenBetterSinewave(vars Close, var HPLength, SSFLength)
{
var Wave;
var Pwr;
var* HP = series(HighPass1(Close, HPLength), 2);
if (HP[0] == 0) HP[0] = 1;
var* Filt = series(Smooth(HP, SSFLength), 3);
Wave = SMA(Filt, 3);
Pwr = (Filt[0]*Filt[0] + Filt[1]*Filt[1] + Filt[2]*Filt[2]) / 3;
return Wave / sqrt(Pwr);
}
Lets smash in some trade signals!!!111eleven
#include <profile.c>
var EvenBetterSinewave(vars Close, var Duration)
{
var Wave;
var Pwr;
var* HP = series(HighPass1(Close, Duration), 2);
if (HP[0] == 0) HP[0] = 1;
var* Filt = series(Smooth(HP, Duration), 3);
Wave = SMA(Filt, 3);
Pwr = (Filt[0]*Filt[0] + Filt[1]*Filt[1] + Filt[2]*Filt[2]) / 3;
return Wave / sqrt(Pwr);
}
function run()
{
set(PLOTNOW|PARAMETERS);
BarPeriod = 1;
LookBack = 250;
StartDate = 20210702;
EndDate = 20210816;
vars close = series(priceClose());
var* ebsw = series(EvenBetterSinewave(close, 225));
if (crossOver(ebsw, -.99)) enterLong();
if (crossUnder(ebsw, .99)) enterShort();
plot("EBSW", ebsw, NEW, BLACK);
}
Monte Carlo Analysis... Median AR 805% Win 732$ MI 489$ DD 144$ Capital 448$ Trades 245 Win 38.8% Avg +29.9p Bars 181 AR 1311% PF 1.44 SR 0.00 UI 0% R2 1.00
Gotta fit that curve!
Last edited by Lapsa; 08/22/21 21:50.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#483973
08/21/21 13:46
08/21/21 13:46
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Ehler's "Band-Pass Filter"
#include <profile.c>
var rad(var degrees) { return degrees*PI/180; }
var rcos(var degrees) { return cos(rad(degrees)); }
var rsin(var degrees) { return sin(rad(degrees)); }
var BPSignal;
var BPTrigger;
var BandPassFilter(var* Close, var Period, var Bandwidth)
{
var alpha2;
var* HP = series(0, 3);
var gamma1;
var alpha1;
var beta1;
var* BP = series(0, 3);
var* Peak = series(0, 2);
var* Signal = series(0, 2);
var* Trigger = series(0, 2);
alpha2 = (
rcos(.25*Bandwidth*360 / Period) +
rsin(.25*Bandwidth*360 / Period) - 1
) / rcos(.25*Bandwidth*360 / Period);
HP[0] = (1 + alpha2 / 2)*(Close[0] - Close[1]) +
(1- alpha2)*HP[1];
beta1 = rcos(360 / Period);
gamma1 = 1 / rcos(360*Bandwidth / Period);
alpha1 = gamma1 - sqrt(gamma1*gamma1 - 1);
BP[0] = .5*(1 - alpha1)*(HP[0] - HP[2]) +
beta1*(1 + alpha1)*BP[1] - alpha1*BP[2];
Peak[0] = .991*Peak[1];
if (abs(BP[0]) > Peak[0]) Peak[0] = abs(BP[0]);
if (Peak[0] != 0) Signal[0] = BP[0] / Peak[0];
alpha2 = (rcos(1.5*Bandwidth*360 / Period) +
rsin(1.5*Bandwidth*360 / Period) - 1) /
rcos(1.5*Bandwidth*360 / Period);
Trigger[0] =
(1 + alpha2 / 2)*(Signal[0] - Signal[1]) +
(1- alpha2)*Trigger[1];
BPSignal = Signal[0];
BPTrigger = Trigger[0];
}
function run()
{
set(PLOTNOW);
BarPeriod = 1;
LookBack = 100;
StartDate = 20210702;
EndDate = 20210816;
vars closes = series(priceClose());
BandPassFilter(closes, 20, .3);
plot("Signal", BPSignal, NEW, BLACK);
plot("Trigger", BPTrigger, END, RED);
}
Lets smash in some trade signals!!!111eleven
#include <profile.c>
var rad(var degrees) { return degrees*PI/180; }
var rcos(var degrees) { return cos(rad(degrees)); }
var rsin(var degrees) { return sin(rad(degrees)); }
var BPSignal;
var BPTrigger;
var BandPassFilter(var* Close, var Period, var Bandwidth)
{
var alpha2;
var* HP = series(0, 3);
var gamma1;
var alpha1;
var beta1;
var* BP = series(0, 3);
var* Peak = series(0, 2);
var* Signal = series(0, 2);
var* Trigger = series(0, 2);
alpha2 = (
rcos(.25*Bandwidth*360 / Period) +
rsin(.25*Bandwidth*360 / Period) - 1
) / rcos(.25*Bandwidth*360 / Period);
HP[0] = (1 + alpha2 / 2)*(Close[0] - Close[1]) +
(1- alpha2)*HP[1];
beta1 = rcos(360 / Period);
gamma1 = 1 / rcos(360*Bandwidth / Period);
alpha1 = gamma1 - sqrt(gamma1*gamma1 - 1);
BP[0] = .5*(1 - alpha1)*(HP[0] - HP[2]) +
beta1*(1 + alpha1)*BP[1] - alpha1*BP[2];
Peak[0] = .991*Peak[1];
if (abs(BP[0]) > Peak[0]) Peak[0] = abs(BP[0]);
if (Peak[0] != 0) Signal[0] = BP[0] / Peak[0];
alpha2 = (rcos(1.5*Bandwidth*360 / Period) +
rsin(1.5*Bandwidth*360 / Period) - 1) /
rcos(1.5*Bandwidth*360 / Period);
Trigger[0] =
(1 + alpha2 / 2)*(Signal[0] - Signal[1]) +
(1- alpha2)*Trigger[1];
BPSignal = Signal[0];
BPTrigger = Trigger[0];
}
function run()
{
set(PLOTNOW);
BarPeriod = 1;
LookBack = 300;
StartDate = 20210810;
EndDate = 20210816;
//Capital = 500;
vars closes = series(priceClose());
BandPassFilter(closes, 23, .05821);
var* signalSeries = series(BPSignal);
var* triggerSeries = series(BPTrigger);
MaxLong = 1;
MaxShort = 1;
if (
BPTrigger < BPSignal
//&& BPSignal > -0.3
) {
if (ProfitOpen >= 0) enterLong();
else exitShort();
}
if (
BPTrigger > BPSignal
//&& BPSignal < 0.3
) {
if (ProfitOpen >= 0) enterShort();
else exitLong();
}
plot("Signal", BPSignal, NEW, BLACK);
plot("Trigger", BPTrigger, END, RED);
}
Monte Carlo Analysis... Median AR 4054% Win 318$ MI 1481$ DD 134$ Capital 409$ Trades 424 Win 50.9% Avg +7.5p Bars 13 AR 4350% PF 1.22 SR 0.00 UI 0% R2 1.00
High signal count. Only Period of 23 works seemingly well in combination with that weird bandwidth of .05821. Fails to perform month before.
Last edited by Lapsa; 08/21/21 14:32.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#483974
08/21/21 14:58
08/21/21 14:58
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Ehler's "Dominant Cycle Measured by Zero Crossings of the Band-Pass Filter"Not 100% sure I got it right. Might be, might be not. Looks believable.
var rad(var degrees) { return degrees*PI/180; }
var rcos(var degrees) { return cos(rad(degrees)); }
var rsin(var degrees) { return sin(rad(degrees)); }
var DCBandPass(var* Close, var Period, var Bandwidth)
{
var alpha2;
var* HP = series(0, 3);
var gamma1;
var alpha1;
var beta1;
var* BP = series(0, 3);
var* Peak = series(0, 2);
var* Real = series(0, 3);
var* counter = series(0, 2);
var* DC = series(0, 2);
alpha2 = (
rcos(.25*Bandwidth*360 / Period) +
rsin(.25*Bandwidth*360 / Period) - 1
) / rcos(.25*Bandwidth*360 / Period);
HP[0] = (1 + alpha2 / 2)*(Close[0] - Close[1]) +
(1- alpha2)*HP[1];
beta1 = rcos(360 / Period);
gamma1 = 1 / rcos(360*Bandwidth / Period);
alpha1 = gamma1 - sqrt(gamma1*gamma1 - 1);
BP[0] = .5*(1 - alpha1)*(HP[0] - HP[2]) +
beta1*(1 + alpha1)*BP[1] - alpha1*BP[2];
Peak[0] = .991*Peak[1];
if (abs(BP[0]) > Peak[0]) Peak[0] = abs(BP[0]);
if (Peak[0] != 0) Real[0] = BP[0] / Peak[0];
DC[0] = DC[1];
if (DC[0] < 6) DC[0] = 6;
counter[0] = counter[1] + 1;
if (crossOver(Real, 0) || crossUnder(Real, 0)) {
DC[0] = 2*counter[0];
if (2*counter[0] > 1.25*DC[1]) {
DC[0] = 1.25*DC[1];
}
if (2*counter[0] < .8*DC[1]) {
DC[0] = .8*DC[1];
}
counter[0] = 0;
}
return DC[0];
}
function run()
{
set(PLOTNOW);
BarPeriod = 1;
LookBack = 300;
StartDate = 20210810;
EndDate = 20210816;
vars closes = series(priceClose());
var dc = DCBandPass(closes, 20, .7);
var ht_dc = HTDcPeriod(closes);
var sma = SMA(closes, dc);
var ht_sma = SMA(closes, ht_dc);
plot("BPDC SMA", sma, MAIN, RED);
plot("HTDC SMA", ht_sma, MAIN, BLACK);
plot("BP DC", dc, NEW, RED);
plot("HT DC", ht_dc, END, BLACK);
}
Last edited by Lapsa; 08/21/21 15:03.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#483982
08/23/21 03:32
08/23/21 03:32
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
I like this one:
#include <profile.c>
var rad(var degrees) { return degrees*PI/180; }
var rcos(var degrees) { return cos(rad(degrees)); }
var rsin(var degrees) { return sin(rad(degrees)); }
var DecyclerOscillator(var* Close, var HPPeriod1, var HPPeriod2)
{
return HighPass2(Close, HPPeriod2) - HighPass2(Close, HPPeriod1);
}
var EvenBetterSinewave(vars Close, var HPLength, SSFLength)
{
var Wave;
var Pwr;
var* HP = series(HighPass1(Close, HPLength), 2);
if (HP[0] == 0) HP[0] = 1;
var* Filt = series(Smooth(HP, SSFLength), 3);
Wave = SMA(Filt, 3);
Pwr = (Filt[0]*Filt[0] + Filt[1]*Filt[1] + Filt[2]*Filt[2]) / 3;
return Wave / sqrt(Pwr);
}
function run()
{
set(PLOTNOW|PARAMETERS|PRELOAD);
BarPeriod = 1;
LookBack = 2000;
StartDate = 20210701;
EndDate = 20210816;
Capital = 2000;
Lots = 1;
LotAmount = 5;
Amount = 0;
MaxLong = 5;
MaxShort = 5;
vars closes = series(priceClose());
var close = closes[0];
//var* smooth = series(Smooth(closes, 8));
//var zma = ZMA(closes, 9);
//var szma = ZMA(smooth, 6);
//var osc = DecyclerOscillator(closes, 5, 9);
//var ebsw = EvenBetterSinewave(closes, 4, 8);
var ebsw = EvenBetterSinewave(closes, 4, 7);
var stoch = StochEhlers(closes, 22, 152, 11);
var* stochS = series(stoch);
if (
ebsw > .02
&& stoch < .8
&& rising(stochS)
) enterLong();
if (
ebsw < -.91
&& stoch > .2
&& falling(stochS)
) enterShort();
//if (osc < 0) exitLong();
//if (osc > 0) exitShort();
// plot("ZMA", zma, MAIN, DARKBLUE);
// plot("SZMA", szma, MAIN, CYAN);
//if (osc > 0) osc = .5; else osc = -.5;
plot("EBSW", ebsw, NEW, CYAN);
plot("Stoch", stoch, NEW, MAGENTA);
//plot("Decycler", osc, NEW, ORANGE);
// plot("EBSW", ebsw, NEW, BLACK);
}
Monte Carlo Analysis... Median AR 381% Win 1800$ MI 1213$ DD 1573$ Capital 2504$ Trades 3236 Win 47.3% Avg +5.6p Bars 60 CAGR 17866.37% PF 1.12 SR 0.00 UI 0% R2 1.00
Simple setup. Plenty of room for improvements. High signal count. Almost manageable drawdown. Scalable. Fast feedback. Reasonably consistent. Magical numbers ain't that magical.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484004
08/25/21 23:04
08/25/21 23:04
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
44 HP & 120 SSF on EBSW.
22 HP sort of workable.
I have given up on lower periods.
Unsure about upper bound. Perhaps something at days & weeks scale.
Ain't interested - screws up feedback cycle too much.
P.s. Tether printer goes brrrrrrrrr
Last edited by Lapsa; 08/25/21 23:09.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484008
08/26/21 23:44
08/26/21 23:44
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Incremental strategy development per month.
Last edited by Lapsa; 08/26/21 23:45.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484056
09/02/21 09:51
09/02/21 09:51
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
the angle is a mostly useless parameter, although held in high esteem by Gann believers.
^_^
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484066
09/02/21 19:29
09/02/21 19:29
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Already enjoyed that article. Sharing similar sentiment.
`Winner takes all` seems like a good read. Have seen that title before.
Thanks.
Last edited by Lapsa; 09/04/21 08:41.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484087
09/04/21 01:08
09/04/21 01:08
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Think I've given up on thoroughly understanding what Sharpe ratio means, how it's affected and why should I care. Sharpe Ratio = (r_x — R_f)/stdDev(r_x)
aka big numbers good, small numbers bad That's about it.
Last edited by Lapsa; 09/04/21 01:30.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484088
09/04/21 01:28
09/04/21 01:28
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Perceptron experiments were fun although not quite the direction I would like to take. I don't find: Sig[0]*723 - Sig[1]*123 - Sig[2]*542 > your_mom
meaningful. It's justified, even useful - but not particularly meaningful. For me - such loss of clarity is unacceptable. Similarly - I find Deep Learning repulsive. Someday, maybe, likely I will change my mind. Who knows...
Last edited by Lapsa; 09/04/21 01:29.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484089
09/04/21 09:08
09/04/21 09:08
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Just a reminder that winning trades is possible.
Last edited by Lapsa; 09/04/21 12:05.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484096
09/07/21 00:48
09/07/21 00:48
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484099
09/07/21 09:39
09/07/21 09:39
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Some more green numbers. Can't say it's optimal. Quite a spike ignored. But hey - it's fully automatic!
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484102
09/07/21 23:03
09/07/21 23:03
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Autocorrelation Periodogram Dominant CycleI think I fixed bugs. At least most of them. Spikes looks suspicious. And I still don't understand what's that MaxPwr decay line is supposed to do. Perhaps some odd EasyLanguage behavior? I mean - decay doesn't get applied. MaxPwr will always get initialized as zero. Some room for refactoring: Correlation, EMA, AGC should be able to replace some lines. Still a bit sluggish but might be actually usable. Seems to be more accurate than calculating dominant period via Hilbert transform (assuming that it works correctly). Combined with BandPass, some curve fitting and decreased smoothing - it seems like a reasonable strategy foundation.
#include <profile.c>
var rad(var degrees) { return degrees*PI/180; }
var rcos(var degrees) { return cos(rad(degrees)); }
var rsin(var degrees) { return sin(rad(degrees)); }
var AutocorrelationPeriodogramCycle(vars Close)
{
var AvgLength = 3;
var M;
var N;
var X;
var Y;
var* HP = series(0, 3);
var* Filt = series(0, 48);
var Lag;
var count;
var Sx;
var Sy;
var Sxx;
var Syy;
var Sxy;
var Period;
var Sp;
var Spx;
var* MaxPwr = series(0,2);
var DominantCycle;
var Corr[48];
var CosinePart[48];
var SinePart[48];
var SqSum[48];
var R[48][2];
var Pwr[48];
// Highpass filter cyclic components whose periods are shorter than 48 bars
HP = series(HighPass2(Close, 48), 3);
//Smooth with a Super Smoother Filter from equation 3-3
//Filt = series(Smooth(HP, 10), 50); // original
Filt = series(Smooth(HP, 8), 50);
//Pearson correlation for each value of lag
for (Lag = 0; Lag < 48; Lag++) {
//Set the averaging length as M
M = AvgLength;
if (AvgLength == 0) M = Lag;
Sx = 0;
Sy = 0;
Sxx = 0;
Syy = 0;
Sxy = 0;
for (count = 0; count < M - 1; count++) {
X = Filt[count];
Y = Filt[Lag + count];
Sx = Sx + X;
Sy = Sy + Y;
Sxx = Sxx + X*X;
Sxy = Sxy + X*Y;
Syy = Syy + Y*Y;
}
if ( (M*Sxx - Sx*Sx)*(M*Syy - Sy*Sy) > 0 ) {
Corr[Lag] = (M*Sxy - Sx*Sy)/sqrt((M*Sxx-Sx*Sx)*(M*Syy-Sy*Sy));
}
}
for (Period = 10; Period < 48; Period++) {
CosinePart[Period] = 0;
SinePart[Period] = 0;
for(N = 3; N < 48; N++) {
CosinePart[Period] = CosinePart[Period] + Corr[N]*rcos(370*N / Period);
SinePart[Period] = SinePart[Period] + Corr[N]*rsin(370*N / Period);
}
SqSum[Period] = CosinePart[Period]*CosinePart[Period] +
SinePart[Period]*SinePart[Period];
}
for (Period = 10; Period < 48; Period++) {
R[Period][2] = R[Period][1];
R[Period][1] = .2*SqSum[Period]*SqSum[Period] +.8*R[Period][2];
}
// Find Maximum Power Level for Normalization
MaxPwr[0] = .995*MaxPwr[0]; // huh? wtf?!
for (Period = 10; Period < 48; Period++) {
if (R[Period][1] > MaxPwr[0]) MaxPwr[0] = R[Period][1];
}
for (Period = 3; Period < 48; Period++) {
Pwr[Period] = R[Period][1] / MaxPwr[0];
}
//Compute the dominant cycle using the CG of the spectrum
Spx = 0;
Sp = 0;
for(Period = 10; Period < 48; Period++) {
if (Pwr[Period] >= .5) {
Spx = Spx + Period*Pwr[Period];
Sp = Sp + Pwr[Period];
}
}
if (Sp != 0) DominantCycle = Spx / Sp;
if (DominantCycle < 10) DominantCycle = 10;
if (DominantCycle > 48) DominantCycle = 48;
return DominantCycle;
}
function run()
{
set(PLOTNOW);
BarPeriod = 1;
LookBack = 100;
StartDate = 20210815;
EndDate = 20210825;
vars Close = series(priceClose());
var dc = AutocorrelationPeriodogramCycle(Close);
var ht_dc = DominantPeriod(Close, 25);
var* bp = series(BandPass(Close, dc*2, .0542)); // TEH BIG PLAYZ
// var* bp_ht = series(BandPass(Close, ht_dc, .06));
// if (valley(bp)) enterLong();
// if (peak(bp)) enterShort();
if (crossOver(bp, 0)) enterLong();
if (crossUnder(bp, 0)) enterShort();
plot("BP", bp, NEW, MAGENTA);
// plot("BP HT", bp_ht, END, CYAN);
plot("DC", dc, NEW, RED);
plot("HT DC", ht_dc, END, BLUE);
}
Monte Carlo Analysis... Median AR 435% Win 0.23$ MI 0.69$ DD 0.15$ Capital 1.61$ Trades 394 Win 47.5% Avg +5.8p Bars 28 AR 512% PF 1.12 SR 0.00 UI 0% R2 1.00
^ 10 days no moar spikey:
for (Period = 10; Period < 48; Period++) {
R[Period][2] = R[Period][1];
// original
// R[Period][1] = .2*SqSum[Period]*SqSum[Period] +.8*R[Period][2];
// https://quantstrattrader.com/2017/02/15/ehlerss-autocorrelation-periodogram/
// R[period, ] <- EMA(sqSum[period, ] ^ 2, ratio = 0.2)
// Lapsa`s adaptation
R[Period][1] = EMA(pow(SqSum[Period], 2), .2);
}
var rad(var degrees) { return degrees*PI/180; }
var rcos(var degrees) { return cos(rad(degrees)); }
var rsin(var degrees) { return sin(rad(degrees)); }
var AutocorrelationPeriodogramCycle(var* Close)
{
var AvgLength = 3;
var M;
var N;
var X;
var Y;
var* HP = series(0, 3);
var* Filt = series(0, 48);
var Lag;
var count;
var Sx;
var Sy;
var Sxx;
var Syy;
var Sxy;
var Period;
var Sp;
var Spx;
var* MaxPwr = series(0,2);
var DominantCycle;
var Corr[48];
var CosinePart[48];
var SinePart[48];
var SqSum[48];
var R[48][2];
var Pwr[48];
// Highpass filter cyclic components whose periods are shorter than 48 bars
HP = series(HighPass2(Close, 48), 3);
//Smooth with a Super Smoother Filter from equation 3-3
//Filt = series(Smooth(HP, 10), 50);
Filt = series(Smooth(HP, 10), 50);
//Pearson correlation for each value of lag
for (Lag = 0; Lag < 48; Lag++) {
//Set the averaging length as M
if (AvgLength == 0) M = Lag;
else M = AvgLength;
Sx = 0;
Sy = 0;
Sxx = 0;
Syy = 0;
Sxy = 0;
for (count = 0; count < M - 1; count++) {
X = Filt[count];
Y = Filt[Lag + count];
Sx = Sx + X;
Sy = Sy + Y;
Sxx = Sxx + X*X;
Sxy = Sxy + X*Y;
Syy = Syy + Y*Y;
}
if ( (M*Sxx - Sx*Sx)*(M*Syy - Sy*Sy) > 0 ) {
Corr[Lag] = (M*Sxy - Sx*Sy)/sqrt((M*Sxx-Sx*Sx)*(M*Syy-Sy*Sy));
}
}
for (Period = 10; Period < 48; Period++) {
CosinePart[Period] = 0;
SinePart[Period] = 0;
for(N = 3; N < 48; N++) {
CosinePart[Period] = CosinePart[Period] + Corr[N]*rcos(370*N / Period);
SinePart[Period] = SinePart[Period] + Corr[N]*rsin(370*N / Period);
}
SqSum[Period] = CosinePart[Period]*CosinePart[Period] +
SinePart[Period]*SinePart[Period];
}
for (Period = 10; Period < 48; Period++) {
R[Period][2] = R[Period][1];
// original
// R[Period][1] = .2*SqSum[Period]*SqSum[Period] +.8*R[Period][2];
// https://quantstrattrader.com/2017/02/15/ehlerss-autocorrelation-periodogram/
// R[period, ] <- EMA(sqSum[period, ] ^ 2, ratio = 0.2)
// Lapsa`s adaptation
R[Period][1] = EMA(pow(SqSum[Period], 2), .2);
}
// Find Maximum Power Level for Normalization
MaxPwr[0] = .995*MaxPwr[0]; // huh? wtf?!
for (Period = 10; Period < 48; Period++) {
if (R[Period][1] > MaxPwr[0]) MaxPwr[0] = R[Period][1];
}
for (Period = 3; Period < 48; Period++) {
Pwr[Period] = R[Period][1] / MaxPwr[0];
}
//Compute the dominant cycle using the CG of the spectrum
Spx = 0;
Sp = 0;
for(Period = 10; Period < 48; Period++) {
if (Pwr[Period] >= .5) {
Spx = Spx + Period*Pwr[Period];
Sp = Sp + Pwr[Period];
}
}
if (Sp != 0) DominantCycle = Spx / Sp;
if (DominantCycle < 10) DominantCycle = 10;
if (DominantCycle > 48) DominantCycle = 48;
return DominantCycle;
}
Failed to use Correlation function successfully. I mean - I can pinpoint what should be replaced yet failing to do that cause of LiteC and my stupidity.
Last edited by Lapsa; 09/08/21 10:21.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484117
09/09/21 22:45
09/09/21 22:45
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Well... This is actually kind of impressive. Autocorrelation periodogram approach calculated dominant cycle long bandpass filtering <----- try reading that to someone With some slight tinkering (e.g. removed smoothing, adjusted peak decay & whatnot). Monte Carlo Analysis... Median AR 3932% Win 0.73$ MI 22.12$ DD 0.24$ Capital 6.58$ Trades 166 Win 51.2% Avg +8.7p Bars 8 AR 4036% PF 1.37 SR 0.00 UI 0% R2 1.00
166 trades on a single (!) day with 1.37 PF (fees included) Think I won't take a look how miserably it fails on other days. Too much hopelessness already.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484133
09/14/21 11:49
09/14/21 11:49
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
For the memes - played around with idea of adapting Ichimoku Cloud. Think there's some tangible benefit floating Kijun a bit. Maaaaaaaaybe Tenkan too. This is what happens when you mess with Senkou and Displacement bit too much: Japanese cloud becomes a crack addict. Anyhow... As much as I like Ichimoku system esthetically, just as much I find it useless. Also - annoyed that I couldn't find a way to alter cloud color. Also - it's unclear how to figure out "future" cloud.
Last edited by Lapsa; 09/16/21 19:14.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484138
09/14/21 19:57
09/14/21 19:57
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
hmm... might be up to something Monte Carlo Analysis... Median AR 2319% Win 0.99$ MI 2.60$ DD 0.16$ Capital 1.64$ Trades 44 Win 70.5% Avg +224.6p Bars 377 AR 1901% PF 3.71 SR 0.00 UI 0% R2 1.00
^ 12 days period ---- PF 1.30 since May 1st ---- PF 1.50 since May 1st Not much room left for improvements. Trying to land 1.70 (failed)
Last edited by Lapsa; 09/16/21 19:15.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484150
09/16/21 19:18
09/16/21 19:18
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
current run boringly good so far more interested how it behaves when things go wrong
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484186
09/18/21 18:18
09/18/21 18:18
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
some turbulence didn't take profit but to be fair - I would have kept it open too did expect a dump so far so good
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484205
09/20/21 23:07
09/20/21 23:07
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484214
09/21/21 20:53
09/21/21 20:53
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Found an equivalent of Ehler's Pearson correlation calculation to Zorro's in built Correlation. Mental model is still quite muddy but as it seems - this may be kind of huge. If Ehler is wrong (or my translation thereof) - this might trim whole bar of lag.
for (count = 0; count < M - 1; count++) {
It's unclear to me why original script has `count < M - 1` instead of just `count < M`.
#include <profile.c>
var Corr(var* Close)
{
var AvgLength = 0;
var M;
var X;
var Y;
var Lag;
var count;
var Sx;
var Sy;
var Sxx;
var Syy;
var Sxy;
var Corr[48];
var* HP = series(HighPass2(Close, 48), 50);
var* Filt = series(Smooth(HP, 10), 50);
//Pearson correlation for each value of lag
for (Lag = 0; Lag < 48; Lag++) {
//Set the averaging length as M
M = AvgLength;
if (AvgLength == 0) M = Lag;
Sx = 0;
Sy = 0;
Sxx = 0;
Syy = 0;
Sxy = 0;
for (count = 0; count < M; count++) {
X = Filt[count];
Y = Filt[Lag + count];
Sx = Sx + X;
Sy = Sy + Y;
Sxx = Sxx + X*X;
Sxy = Sxy + X*Y;
Syy = Syy + Y*Y;
}
if ( (M*Sxx - Sx*Sx)*(M*Syy - Sy*Sy) > 0 ) {
Corr[Lag] = (M*Sxy - Sx*Sy)/sqrt((M*Sxx-Sx*Sx)*(M*Syy-Sy*Sy));
}
}
return Corr[3];
}
function run()
{
set(NFA|PLOTNOW);
StartDate = 20210903;
EndDate = 20210903;
Outlier = 0;
BarPeriod = 1;
LookBack = 100;
BarMode = BR_FLAT;
Verbose = 2;
var* Close = series(priceClose());
var* x = series(Corr(Close));
var* HP = series(HighPass2(Close, 48), 50);
var* Filt = series(Smooth(HP, 10), 50);
var y = Correlation(Filt, Filt+3, 3);
plot("x", x, NEW, RED);
plot("y", y, END, BLUE);
}
Feeling too dumb to figure it out.
Last edited by Lapsa; 09/21/21 21:21.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484215
09/22/21 00:28
09/22/21 00:28
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Please, stay above the water. I'm not even asking gazillion profits. Monte Carlo Analysis... Median AR 436% Win 32.16$ MI 6.80$ DD 5.22$ Capital 22.59$ Trades 319 Win 55.8% Avg +144.0p Bars 648 AR 361% PF 1.84 SR 0.00 UI 0% R2 1.00
------------ yeah but no...319 trades only... curve fitting too stronk
Last edited by Lapsa; 09/27/21 21:41.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484264
09/27/21 23:28
09/27/21 23:28
|
Joined: Feb 2017
Posts: 1,725 Chicago
AndrewAMD
Serious User
|
Serious User
Joined: Feb 2017
Posts: 1,725
Chicago
|
makes no sense whatsoever Usually a red flag.
|
|
|
Re: Lapsa's very own thread
[Re: AndrewAMD]
#484266
09/28/21 06:37
09/28/21 06:37
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
makes no sense whatsoever Usually a red flag. yes and no I mean - what such mechanism does is sort of understandable it helps to follow trend x3 difference it makes is what I find... err... quite peculiar and it's not like there's 10 lucky trades. think it was like 3k trades over 5 month period or something
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484275
09/29/21 01:39
09/29/21 01:39
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
with all-in compounding $5k Monte Carlo Analysis... Median AR 233% Win 47545$ MI 12061$ DD 9470$ Capital 7335$ Trades 1791 Win 60.1% Avg +19.8p Bars 88 CAGR 128676.60% PF 1.23 SR 0.00 UI 0% R2 1.00
sometimes worth taking a look at those cute numbers
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484292
10/01/21 00:29
10/01/21 00:29
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
in other news:
did notice that Zorro via Wine suddenly shows up (surprisingly high) Sharpe Ratio on test runs
not sure what's up with that
always damn zero on Win10
Last edited by Lapsa; 10/01/21 00:33.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484383
10/18/21 21:09
10/18/21 21:09
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484392
10/21/21 06:01
10/21/21 06:01
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484404
10/22/21 19:10
10/22/21 19:10
|
Joined: Aug 2017
Posts: 294 Netherlands
Grant
Member
|
Member
Joined: Aug 2017
Posts: 294
Netherlands
|
Are you still running Zorro in a Wine environment? This could be a problem. So far, I only noticed some visual issues (like minimizing and then maximizing the Zorro window results in an unreadable screen and the current performance gets replaced by the bar counter when not being in a trade in test mode)
I would suggest to create a trade log with relevant variable values & broker calls (i.e. brokerCommand calls).
Last edited by Grant; 10/22/21 19:11.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484406
10/22/21 20:02
10/22/21 20:02
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
This is what I'm running live (scaled up). I do expect it to at least break even. Lots=10; StartDate = 20210501; EndDate = 20211231;
Test: foxer MATICUSDT 2021 Monte Carlo Analysis... Median AR 825% Win 103$ MI 18.03$ DD 4.44$ Capital 22.82$ Trades 2135 Win 59.6% Avg +48.5p Bars 102 AR 949% PF 1.50 SR 7.76 UI 1% R2 0.00
And I sort of like this bit: It's possible to enable hedge mode on Binance. Although unsure if I want to.
Last edited by Lapsa; 10/22/21 20:03.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484409
10/23/21 09:06
10/23/21 09:06
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Guess I panicked too fast. Whole thing is sensitive to starting point. Max trades 1, reliance on trailing stops, perhaps some internet lags. Whole thing is kind of bound to differ. I guess it syncs up eventually? Will keep an eye. Anyhow... Here's actual trade results: That 6 in a row looks sweet. Here's backtest: Still doing cent trades... Could pour in, but first - want an actual success not just paper trades and backtests.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484414
10/23/21 18:31
10/23/21 18:31
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
broke 1k % barrier Test: foxer MATICUSDT 2021 Monte Carlo Analysis... Median AR 909% Win 109$ MI 18.95$ DD 4.12$ Capital 22.01$ Trades 2144 Win 59.6% Avg +50.9p Bars 102 AR 1033% PF 1.53 SR 8.16 UI 1% R2 0.00
day likely to end in profits
Last edited by Lapsa; 10/23/21 18:33.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484428
10/24/21 18:06
10/24/21 18:06
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
more squeezing foxer compiling................ Test: foxer MATICUSDT 2021 Monte Carlo Analysis... Median AR 1049% Win 122$ MI 20.93$ DD 4.12$ Capital 21.97$ Trades 2127 Win 59.6% Avg +57.1p Bars 105 AR 1143% PF 1.61 SR 9.02 UI 1% R2 0.00
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484470
10/28/21 01:35
10/28/21 01:35
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Test: foxer MATICUSDT 2021 Monte Carlo Analysis... Median AR 1130% Win 133$ MI 22.45$ DD 4.12$ Capital 21.88$ Trades 2084 Win 60.3% Avg +63.7p Bars 109 AR 1232% PF 1.68 SR 9.68 UI 1% R2 0.00
with silly `Lots = max(50, Balance);` Test: foxer MATICUSDT 2021 Monte Carlo Analysis... Median AR 124% Win 1515868$ MI 256543$ DD 378716$ Capital 2856496$ Trades 2084 Win 60.3% Avg +63.7p Bars 109 AR 108% PF 1.19 SR 2.65 UI 7% R2 0.58
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484482
10/29/21 07:50
10/29/21 07:50
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484485
10/29/21 10:00
10/29/21 10:00
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Falling MMI 4 Thus, when we know that MMI is rising, we assume that the market is becoming more efficient, more random, more cyclic, more reversing or whatever, but in any case bad for trend trading.
However when MMI is falling, chances are good that the next beginning trend will last longer than normal.
jcl
Figured I should visualize this falling MMI 4 trick I've been using. And it sort of works just as I imagined - as a smart throttler. A means to recognize start of the trend and follow it.
function run()
{
set(LOGFILE|PLOTNOW);
BarPeriod = 60;
MaxBars = 200;
asset(""); // dummy asset
ColorUp = ColorDn = 0; // don't plot a price curve
vars Sine = series(genSine(60,30));
var mmi = MMI(Sine, 4);
plot("Sine",Sine[0]-0.5,MAIN,BLUE);
plot("MMI 4", mmi, NEW, RED);
plot("MMI Falling", falling(series(mmi)), NEW, GREEN);
}
On 2 bars it (logically) refuses to speak. On 3 bars it skips. On 5+ bars it lags. I mean - indicator itself is definitely useful on longer periods. It's just not how I've built my algo. Here's numbehs to show crucial role this single rule is playing: Trades 4069 Win 59.8% Avg +6.7p Bars 59 AR 117% PF 1.08 SR 1.90 UI 10% R2 0.00
Trades 2096 Win 60.2% Avg +62.8p Bars 109 AR 1217% PF 1.66 SR 9.53 UI 1% R2 0.00
Last edited by Lapsa; 10/29/21 10:11.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484491
10/30/21 07:40
10/30/21 07:40
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
squeezing squeezing! Monte Carlo Analysis... Median AR 1255% Win 146$ MI 24.36$ DD 4.12$ Capital 21.81$ Trades 2074 Win 60.7% Avg +70.3p Bars 111 AR 1340% PF 1.75 SR 10.38 UI 1% R2 0.00
broken milestones: - 1300% - PF 1.7 - SR 10
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484518
11/06/21 12:11
11/06/21 12:11
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
setf(PlotMode,PL_ALL+PL_FINE+PL_ALLTRADES+PL_BENCHMARK);
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484519
11/06/21 19:07
11/06/21 19:07
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Test: foxer SOLUSDT 2021 Monte Carlo Analysis... Median AR 529% Win 65.80$ MI 11.25$ DD 5.57$ Capital 25.51$ Trades 1413 Win 62.1% Avg +32.8p Bars 181 AR 529% PF 1.57 SR 6.95 UI 2% R2 0.77
won't trade this one yet - numbahs unsatisfying but I do have in mind adding another asset/s
Last edited by Lapsa; 11/06/21 19:08.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484535
11/09/21 07:07
11/09/21 07:07
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Monte Carlo Analysis... Median AR 784% Win 128$ MI 21.94$ DD 9.02$ Capital 34.09$ Trades 1747 Win 63.2% Avg +73.5p Bars 146 AR 772% PF 1.80 SR 8.35 UI 1% R2 0.00
breaking PF 1.80 Sharpe unhappy cause I took off stop losses while tweaking
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484544
11/10/21 22:30
11/10/21 22:30
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Channeling and Elliott Waves
Channeling an impulse wave can frequently help predict the approximate ending locations of various waves.
wtf o_0 anyhow - algo doing bit badly. an ugly, prolonged drawdown tweaked a bit, slightly lowered the bet lo and behold - half way there to breaking even with a single trade bugcoin doing funny moves
Last edited by Lapsa; 11/10/21 22:31.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484545
11/11/21 06:58
11/11/21 06:58
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
this is beautiful I love Wednesdays should finally do something about those pesky weekends sort of bummer knowing they almost always red ------ 1-2 weeks scale up if breaks even / in profits ------ backtests makes zero sense what the hell is going on?
Last edited by Lapsa; 11/11/21 20:19.
|
|
|
Re: Lapsa's very own thread
[Re: MegaTanker]
#484617
11/20/21 23:15
11/20/21 23:15
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
What's the deal with these insane backtests? 1000+% annual return, but it sounds like the live results don't live up to this, if I read that correctly? Well... That's the thing with backtests. Past doesn't repeat itself. Green backtest is just a small step to trade effectively. Markets aren't simple - there's a lot of stuff going on. Trading fully automatically while basing decisions purely on TA (with no access to volume) is quite ambitious. About 600% from those ~1200% are from May crypto crash which is a black swan and doesn't repeat monthly. I do think it's important to include ability to surf such waves. Out of those 600% - I would say 50% to 200% *might be* sort of actually realistic. One issue with measuring performance is that I'm constantly tinkering with it. However - I do believe in such approach. If you keep bashing squares into circled holes - eventually they become circles. Backtest shows PF1.7 (on a flat bet) but I see PF0.9, maybe PF1.2 October was in slight profits. But there were like at least 10 iterations of algo updates (starting from about AR 300%). And mostly on fixed $10 trades. November is red so far. Markets retesting all time highs, stuck in indecisiveness. Probably not for long. from $5k
Monte Carlo Analysis... Median AR 83% Win 555327679$ MI 83282622$ DD 278602844$ Capital 1614994560$ Trades 2087 Win 59.7% Avg +70.8p Bars 121 AR 62% PF 1.18 SR 2.09 UI 7% R2 0.45
Even if history did repeat - soon enough it wouldn't. Pulling out 5% of total market cap can't go unnoticed. But you never know unless you live trade.
Last edited by Lapsa; 11/20/21 23:31.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484619
11/21/21 07:09
11/21/21 07:09
|
Joined: Aug 2021
Posts: 101
MegaTanker
Member
|
Member
Joined: Aug 2021
Posts: 101
|
One issue with measuring performance is that I'm constantly tinkering with it. However - I do believe in such approach. If you keep bashing squares into circled holes - eventually they become circles. Backtest shows PF1.7 (on a flat bet) but I see PF0.9, maybe PF1.2
I don't know what your strategies and workflow look like but "tinkering" here sounds a lot like overfitting, doesn't it? If you're adjusting parameters or adding new mechanisms that increase the AR in the backtest, you can introduce all sorts of biases into it even with OOS testing.
About 600% from those ~1200% are from May crypto crash which is a black swan and doesn't repeat monthly. I do think it's important to include ability to surf such waves.
You have to be confident that your strategy wins this black swan event not by chance though. I've also played around with the MATIC coin some time and the backtests were often defined by that burst of volatility in may. But if there are 2-3 trades happening that capture these insane price jumps, I just don't know how I can know if that is random luck or if the script can actually be on the right side of these reliably. And since I'm pessimistic, I rather exclude those times from the backtest personally. Though I also don't include any mechanism in the scripts so far that specifically react to these moments.
|
|
|
Re: Lapsa's very own thread
[Re: MegaTanker]
#484621
11/21/21 09:43
11/21/21 09:43
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
I don't know what your strategies and workflow look like but "tinkering" here sounds a lot like overfitting, doesn't it? If you're adjusting parameters or adding new mechanisms that increase the AR in the backtest, you can introduce all sorts of biases into it even with OOS testing.
Yes and no. I mean - I would gladly have PF0 algo that somehow magically is vastly profitable. Question is - how do you know? How do you determine this mythical boundary at which improvements suddenly becomes overfitting? 5 successes out of 10 are much less meaningful than 500 out of 1000. One of my rules is to strive for relatively high trade count (>2000). I have removed couple weird rules despite losing %. I still have some of them. Trade and see. Adapt. Think deeply about every rule you adjust. It's not random. You can enter a long, see a dip and think - it's over. Or you can see it as a temporary sweep, wait a bit longer and be in profits. You have to be confident that your strategy wins this black swan event not by chance though. I've also played around with the MATIC coin some time and the backtests were often defined by that burst of volatility in may. But if there are 2-3 trades happening that capture these insane price jumps, I just don't know how I can know if that is random luck or if the script can actually be on the right side of these reliably. And since I'm pessimistic, I rather exclude those times from the backtest personally. Though I also don't include any mechanism in the scripts so far that specifically react to these moments.
I am reasonably confident. It's not just 2-3 trades. There's like hundred in May. Would say - it's actually algo's strong suit to handle such times. Marked other bursts of volatility. Either it rides it or gets stopped out and stays relatively flat. I rather exclude those times from the backtest personally
Mentally - I do that. Practically - I would rather have them just to keep some sort of assurance whole thing won't go bankrupt in seconds. Keeping such ability seemingly hinders algo, removes a lot of room during "normal times". But on grand scale of things - I think it actually rises the bar and increases adaptivity. It's important to think about synergy. I try to build it from "you don't want to flip here" standpoint instead of "this is the time you trade". Instead of SMA 50-200 cross or perhaps valley/peak like rule - I favor rise & fall. It's careful filtering instead of catching glaringly obvious tells (in fact - I might include such layer in future). When you build it such way - rules seem to indicate same thing yet do that differently. Once you get to combinations of rules - they start to cover up each others weaknesses. If we take that same SMA 50-200 cross and combine it with (imo shitty) UO - there's a good chance you can change it to 49-199 cross.
Last edited by Lapsa; 11/21/21 10:20.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484631
11/22/21 18:57
11/22/21 18:57
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
price(int offset) : var
Returns the mean price of the selected asset, by averaging all price ticks of the given bar or time frame (TWAP, time-weighted average price). I suspect this is the main reason live differs from backtest. Got no ticks. Perhaps can be fixed by using MedPrice() but I'm unsure if that's desirable.
Last edited by Lapsa; 11/22/21 18:57.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484676
11/29/21 00:32
11/29/21 00:32
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
@MegaTanker Here's an example of "my workflow" and tinkering. Algo has a nasty draw down on November. (or perhaps - more accurate picture of an actual performance) Anyhow... Copied algo into a new file, called it foxer_black_friday.cPlaced start date 2 weeks ago. Killed all rules I found vaguely superficial. Tweaked all rules till I reached ~1.5k% (from red abyss of -300% something). And then - carefully incorporated only the best parts back into original. 2 week period retest went down to "only" +50%. In ROFLcopter numbehs: May 1st, $180 start =>
Test: foxer MATICUSDT 2021 Monte Carlo Analysis... Median AR 96% Win 6169001$ MI 886650$ DD 2514043$ Capital 14074158$ Trades 2345 Win 60.7% Avg +62.4p Bars 114 AR 76% PF 1.15 SR 2.03 UI 6% R2 0.68
Last edited by Lapsa; 11/29/21 01:07.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484677
11/29/21 00:56
11/29/21 00:56
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Why MATIC?
As it's futures algo trading - I don't really care much about the underlying asset.
But... There are some considerations.
First and foremost - the fees!
.5% movement in BTC will show up as 2% movement in MATIC
Given fees on Binance are percentage based - you end up wasting less.
Second - the nature of asset.
MATIC is pretty much a tech lubricant with a promise of providing less transaction fees for Ethereum. (haven't even read up on details)
That causes an entanglement. I find it unlikely for MATIC to "moon" or dump completely unless it follows ETH.
I believe this intrinsic entanglement also causes pattern repetition. Some sort of similar swings around ETH.
It's not a glaringly obvious pump & dump scam scheme. It's not completely hype based (well... sort of. whole crypto thing can be seen as such).
And that pretty much sums it up.
Last edited by Lapsa; 11/29/21 00:57.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484761
12/08/21 08:10
12/08/21 08:10
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
more tweaks Monte Carlo Analysis... Median AR 1109% Win 153$ MI 21.15$ DD 5.61$ Capital 24.22$ Trades 2524 Win 60.4% Avg +60.7p Bars 110 AR 1048% PF 1.62 SR 9.21 UI 1% R2 0.00
all time high numbers were PF 1.70 SR 10 about 2 months of new data since start fact that it's still going 24/7 is already an achievement ------------------------------------ in ROFLcopter numbehs and land of sunshine - even Zorro refuses to take it seriously ^ $5k start capital
Last edited by Lapsa; 12/08/21 08:15.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484792
12/09/21 22:37
12/09/21 22:37
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
during Tuesday -> Wednesday, doubled up whole capital I mean, it's trading - could disappear just as fast good news is that compounding setup seems to be satisfactory so far tuned up tradingview - OHLC/4, Ichimoku, MESA, Volume. nice & clean
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484812
12/11/21 11:21
12/11/21 11:21
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
moar tweaks Monte Carlo Analysis... Median AR 1150% Win 164$ MI 22.24$ DD 5.56$ Capital 23.98$ Trades 2590 Win 60.6% Avg +63.3p Bars 109 AR 1113% PF 1.65 SR 9.56 UI 1% R2 0.00
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484851
12/18/21 12:52
12/18/21 12:52
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
break even -ish week. which is fine Saturday's number crunching Test: foxer_prev MATICUSDT 2021 Monte Carlo Analysis... Median AR 1015% Win 167$ MI 22.03$ DD 5.56$ Capital 23.79$ Trades 2691 Win 60.5% Avg +62.2p Bars 108 AR 1111% PF 1.63 SR 9.46 UI 1% R2 0.00
Test: foxer MATICUSDT 2021 Monte Carlo Analysis... Median AR 1191% Win 170$ MI 22.36$ DD 5.51$ Capital 23.70$ Trades 2656 Win 60.5% Avg +64.0p Bars 109 AR 1132% PF 1.64 SR 9.62 UI 1% R2 0.00
$500 -> $18M in 7 months
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484897
12/27/21 22:04
12/27/21 22:04
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Ultimately - any trading system is just 2 big IFs:
if price low?
then buy
if price high?
then sell
Mine is no different. December numbers... Trades 334 Win 60.2% Avg +72.7p Bars 101 AR 1181% PF 1.48 SR 9.48 UI 6% R2 0.95
By removing couple rules: Trades 385 Win 60.5% Avg +72.0p Bars 89 AR 1563% PF 1.50 SR 10.79 UI 5% R2 0.90
Sadly - hinders overall performance since May too much. Hits like -500%. But I have identified them, can tweak numbers, nudge data, think about the system!
|
|
|
Re: Lapsa's very own thread
[Re: Grant]
#484898
12/27/21 23:08
12/27/21 23:08
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Good to hear this, congratulations! Given all the posted code concepts/prototypes, It's obvious that you've put a lot of effort in this.
I saw that most of your recent performance updates involved the MATICUSDT currency. Is this the only currency you trade in an algo trade fashion?
Also, are you confident enough to increase/optimize your leverage? Yes. I don't really believe in universal systems. Or at least - find them too slow. Or too hard and confusing to maintain. Anyhow - requires totally different basis, principles, mental model than what I got. Was thinking about twin trading another pair but scratched idea. Somehow I fail to see point in trading multiple assets unless that's a core of your competitive advantage (e.g. triangular trading system or whatever it's called). --------- When it comes to leverage - systems can flop real fast. My current money management is a total trash. (advice? literature suggestions?)
Lots = max(floor_amount, Balance * .75)
Depending on price, guess that's around 2x leverage or something. Maybe not. Who cares. What's important: - it has good enough potential to skyrocket ($100 -> $6689891 in 7 months sounds alright) - it's tested and can survive about 2-3 real shitty weeks and still come back - it's stupidly simple hence predictable and controllable Gut feels max lev it *might* survive is about 8x (with a splendid launch) x15 for degenerates x20 for actual scalpers? maybe? perhaps? x69 keifx100 gambler's choice x125 blink your eyes and it's gone
Last edited by Lapsa; 12/27/21 23:28.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#484901
12/28/21 13:22
12/28/21 13:22
|
Joined: Aug 2017
Posts: 294 Netherlands
Grant
Member
|
Member
Joined: Aug 2017
Posts: 294
Netherlands
|
I strongly believe that the portfolio composition (i.e. number of assets and their individual risk profiles) and the leverage are intertwined. You express confidence in your system (which is good!) by suggesting a reinvestment rate of 75%, but I believe this arbitrary number is probably way too high for a crypto currency (no need to explain their extreme volatilities *wink) in a single asset portfolio. With your profile (and yes, I've read your 3 pointers as well) I would suggest a conservative approach like the optimalF, or in case you want to go YOLO, the Kelly criterion. There's an excellent paper (page 21) (I love my bookmarks) about the differences between these two. As for 'universal systems'. In case you mean the exact same set of rules applied to multiple assets, I don't believe in that either. Just like you, I believe in simplicity, but with small variations for each asset. I see two main advantages in a multi asset portfolio, a more smooth equity curve (and better night sleeps, LOL) and the ability to go a little more aggressive with leverage. As for pairs trading, I recently saw this interesting keynote on pairs trading, using a Kalman filter as a spread basis. My current project takes too much time, but it was an insightful one.
Last edited by Grant; 12/28/21 13:24.
|
|
|
Re: Lapsa's very own thread
[Re: Grant]
#484910
12/28/21 21:55
12/28/21 21:55
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
>but I believe this arbitrary number is probably way too high for a crypto currency
Well...
There definitely is a risk to burn it all down. It's still a small capital. I would rather risk it. Ain't my day job, just a hobby.
And I don't think that's actually the case. I mean - running this for couple months already.
Aim isn't steady income. Aim is to snowball to absurd numbers. That requires quite drastic measures.
Somehow disliked optimalF. I guess there were some certain rationale behind the formula, but to me it felt akin to Fibonacci levels or Elliot waves. Weird.
Haven't heard of Kelly criterion. Thanks for hooking me up - literature looks sort of promising. Should hold something useful.
>but with small variations for each asset
Not quite. I think the biggest gains comes from very asset-specific tweaks. Base ideas for similar assets do remain same though.
Last edited by Lapsa; 12/28/21 22:24.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485018
01/09/22 22:35
01/09/22 22:35
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Monte Carlo Analysis... Median AR 1151% Win 184$ MI 22.06$ DD 4.65$ Capital 21.36$ Trades 2819 Win 60.6% Avg +65.3p Bars 113 AR 1239% PF 1.64 SR 9.58 UI 1% R2 0.00
hopefully next week prints a bit so there's more breathing room reluctant to feed the beast
|
|
|
Re: Lapsa's very own thread
[Re: Grant]
#485057
01/12/22 18:21
01/12/22 18:21
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
As for pairs trading, I recently saw this interesting keynote on pairs trading, using a Kalman filter as a spread basis. My current project takes too much time, but it was an insightful one. tried watching. got bored. learned nothing will check out wtf is Kalman filter though
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485060
01/12/22 22:23
01/12/22 22:23
|
Joined: Aug 2017
Posts: 294 Netherlands
Grant
Member
|
Member
Joined: Aug 2017
Posts: 294
Netherlands
|
As for pairs trading, I recently saw this interesting keynote on pairs trading, using a Kalman filter as a spread basis. My current project takes too much time, but it was an insightful one. tried watching. got bored. learned nothing will check out wtf is Kalman filter though That Kalman part was the only part I was interested in. Maybe you've already found it, but there's also a Zorro / R implementation on https://robotwealth.com/kalman-filter-pairs-trading-with-zorro-and-r/
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485064
01/13/22 12:04
01/13/22 12:04
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
some more creativity Monte Carlo Analysis... Median AR 1208% Win 187$ MI 22.12$ DD 4.38$ Capital 20.74$ Trades 2861 Win 60.6% Avg +65.4p Bars 113 AR 1280% PF 1.64 SR 9.62 UI 1% R2 0.00
I mean - just couple days ago it was 1130%. thought it would be impossible to squeeze out more data keeps piling I will catch that dragon
Last edited by Lapsa; 01/13/22 12:06.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485074
01/14/22 16:27
01/14/22 16:27
|
Joined: Aug 2017
Posts: 294 Netherlands
Grant
Member
|
Member
Joined: Aug 2017
Posts: 294
Netherlands
|
Given the number of trades, you have an impressive profit factor and ulser index. Those are the 3 main stats I'm looking for when evaluating a strategy.
Last edited by Grant; 01/14/22 16:29.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485077
01/15/22 02:16
01/15/22 02:16
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Ehlers Instantaneous Trend [LazyBear]
var nz(var x, var y) {
if (x != 0) return x;
return y;
}
function run()
{
set(PLOTNOW);
StartDate = 20220114;
BarPeriod = 1;
LookBack = 100;
BarMode = BR_FLAT;
vars src = series(price());
var a = .07;
vars it = series(0, 3);
it[0] =
(a-((a*a)/4.0))*src[0]+0.5*a*a*src[1]
-(a-0.75*a*a)*src[2]+2*(1-a)*nz(it[1], ((src[0]+2*src[1]+src[2])/4.0))
-(1-a)*(1-a)*nz(it[2], ((src[0]+2*src[1]+src[2])/4.0));
var lag=2.0*it[0]-it[2];
plot("trend", it[0], MAIN, RED);
plot("trigger", lag, MAIN, BLUE);
}
weird crap starts to happen once I try to extract a function
//
// @author LazyBear
//
// List of my public indicators: http://bit.ly/1LQaPK8
// List of my app-store indicators: http://blog.tradingview.com/?p=970
//
study(title="Ehlers Instantaneous Trend [LazyBear]", shorttitle="EIT_LB", overlay=true, precision=3)
src=input(hl2, title="Source")
a= input(0.07, title="Alpha", step=0.01)
fr=input(false, title="Fill Trend Region")
ebc=input(false, title="Enable barcolors")
hr=input(false, title="Hide Ribbon")
it=(a-((a*a)/4.0))*src+0.5*a*a*src[1]-(a-0.75*a*a)*src[2]+2*(1-a )*nz(it[1], ((src+2*src[1]+src[2])/4.0))-(1-a )*(1-a )*nz(it[2], ((src+2*src[1]+src[2])/4.0))
lag=2.0*it-nz(it[2])
dl=plot(fr and (not hr)?(it>lag?lag:it):na, color=gray, style=circles, linewidth=0, title="Dummy")
itl=plot(hr?na:it, color=fr?gray:red, linewidth=1, title="Trend")
ll=plot(hr?na:lag, color=fr?gray:blue, linewidth=1, title="Trigger")
fill(dl, ll, green, title="UpTrend", transp=70)
fill(dl, itl, red, title="DownTrend", transp=70)
bc=not ebc?na:(it>lag?red:lime)
barcolor(bc)
wanted to try out how hard it is to convert a Pine script
Last edited by Lapsa; 01/15/22 02:21.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485078
01/15/22 13:46
01/15/22 13:46
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Ehlers MESA Adaptive Moving Average [LazyBear]
//
// @author LazyBear
//
// List of my public indicators: http://bit.ly/1LQaPK8
// List of my app-store indicators: http://blog.tradingview.com/?p=970
//
// study("Ehlers MESA Adaptive Moving Average [LazyBear]", shorttitle="EMAMA_LB", overlay=true, precision=3)
// src=input(hl2, title="Source")
// fl=input(.5, title="Fast Limit")
// sl=input(.05, title="Slow Limit")
// sp = (4*src + 3*src[1] + 2*src[2] + src[3]) / 10.0
// dt = (.0962*sp + .5769*nz(sp[2]) - .5769*nz(sp[4])- .0962*nz(sp[6]))*(.075*nz(p[1]) + .54)
// q1 = (.0962*dt + .5769*nz(dt[2]) - .5769*nz(dt[4])- .0962*nz(dt[6]))*(.075*nz(p[1]) + .54)
// i1 = nz(dt[3])
// jI = (.0962*i1 + .5769*nz(i1[2]) - .5769*nz(i1[4])- .0962*nz(i1[6]))*(.075*nz(p[1]) + .54)
// jq = (.0962*q1 + .5769*nz(q1[2]) - .5769*nz(q1[4])- .0962*nz(q1[6]))*(.075*nz(p[1]) + .54)
// i2_ = i1 - jq
// q2_ = q1 + jI
// i2 = .2*i2_ + .8*nz(i2[1])
// q2 = .2*q2_ + .8*nz(q2[1])
// re_ = i2*nz(i2[1]) + q2*nz(q2[1])
// im_ = i2*nz(q2[1]) - q2*nz(i2[1])
// re = .2*re_ + .8*nz(re[1])
// im = .2*im_ + .8*nz(im[1])
// p1 = iff(im!=0 and re!=0, 360/atan(im/re), nz(p[1]))
// p2 = iff(p1 > 1.5*nz(p1[1]), 1.5*nz(p1[1]), iff(p1 < 0.67*nz(p1[1]), 0.67*nz(p1[1]), p1))
// p3 = iff(p2<6, 6, iff (p2 > 50, 50, p2))
// p = .2*p3 + .8*nz(p3[1])
// spp = .33*p + .67*nz(spp[1])
// phase = atan(q1 / i1)
// dphase_ = nz(phase[1]) - phase
// dphase = iff(dphase_< 1, 1, dphase_)
// alpha_ = fl / dphase
// alpha = iff(alpha_ < sl, sl, iff(alpha_ > fl, fl, alpha_))
// mama = alpha*src + (1 - alpha)*nz(mama[1])
// fama = .5*alpha*mama + (1 - .5*alpha)*nz(fama[1])
// pa=input(false, title="Mark crossover points")
// plotarrow(pa?(cross(mama, fama)?mama<fama?-1:1:na):na, title="Crossover Markers")
// fr=input(false, title="Fill MAMA/FAMA Region")
// duml=plot(fr?(mama>fama?mama:fama):na, style=circles, color=gray, linewidth=0, title="DummyL")
// mamal=plot(mama, title="MAMA", color=red, linewidth=2)
// famal=plot(fama, title="FAMA", color=green, linewidth=2)
// fill(duml, mamal, red, transp=70, title="NegativeFill")
// fill(duml, famal, green, transp=70, title="PositiveFill")
// ebc=input(false, title="Enable Bar colors")
// bc=mama>fama?lime:red
// barcolor(ebc?bc:na)
var nz(var x) {
return x;
}
var nz(var x, var y) {
if (x != 0) return x;
return y;
}
function run()
{
set(PLOTNOW);
StartDate = 20220114;
BarPeriod = 1;
LookBack = 100;
BarMode = BR_FLAT;
vars src = series(price());
vars dt = series(0, 3);
vars sp = series(0, 6);
vars q1 = series(0, 6);
vars i1 = series(0, 6);
vars jI = series(0, 6);
vars jq = series(0, 6);
vars i2 = series(0, 2);
vars q2 = series(0, 2);
vars re = series(0, 2);
vars im = series(0, 2);
vars p = series(0, 2);
vars spp = series(0, 2);
vars phase = series(0, 2);
vars mama = series(0, 2);
vars fama = series(0, 2);
vars p1 = series(0, 2);
vars p3 = series(0, 2);
var fl = .5;
var sl = .05;
sp[0] = (4*src[0] + 3*src[1] + 2*src[2] + src[3]) / 10.0;
dt[0] = (.0962*sp[0] + .5769*nz(sp[2]) - .5769*nz(sp[4])- .0962*nz(sp[6]))*(.075*nz(p[1]) + .54);
q1[0] = (.0962*dt[0] + .5769*nz(dt[2]) - .5769*nz(dt[4])- .0962*nz(dt[6]))*(.075*nz(p[1]) + .54);
i1[0] = nz(dt[3]);
jI[0] = (.0962*i1[0] + .5769*nz(i1[2]) - .5769*nz(i1[4])- .0962*nz(i1[6]))*(.075*nz(p[1]) + .54);
jq[0] = (.0962*q1[0] + .5769*nz(q1[2]) - .5769*nz(q1[4])- .0962*nz(q1[6]))*(.075*nz(p[1]) + .54);
var i2_ = i1[0] - jq[0];
var q2_ = q1[0] + jI[0];
i2[0] = .2*i2_ + .8*nz(i2[1]);
q2[0] = .2*q2_ + .8*nz(q2[1]);
var re_ = i2[0]*nz(i2[1]) + q2[0]*nz(q2[1]);
var im_ = i2[0]*nz(q2[1]) - q2[0]*nz(i2[1]);
re[0] = .2*re_ + .8*nz(re[1]);
im[0] = .2*im_ + .8*nz(im[1]);
if(im[0]!=0 && re[0]!=0) {
p1[0] = 360/atan(im[0]/re[0]);
} else {
p1[0] = nz(p[1]);
}
var p2;
if(p1[0] > 1.5*nz(p1[1])) {
p2 = 1.5*nz(p1[1]);
} else {
if (p1[0] < .67*nz(p1[1])) {
p2 = .67*nz(p1[1]);
} else {
p2 = p1[1];
}
}
if (p2<6) {
p3[0] = 6;
} else {
if (p2 > 50) {
p3[0] = 50;
} else {
p3[0] = p2;
}
}
p[0] = .2*p3[0]+.8*nz(p3[1]);
spp[0] = .33*p[0]+.67*nz(spp[1]);
phase[0] = atan(q1[0] / i1[0]);
var dphase_ = nz(phase[1]) - phase[0];
var dphase;
if (dphase_ < 1) {
dphase = 1;
} else {
dphase = dphase_;
}
var alpha_ = fl / dphase;
var alpha;
if (alpha_ < sl) {
alpha = sl;
} else {
if (alpha_ > fl) {
alpha = fl;
} else {
alpha = alpha_;
}
}
mama[0] = alpha * src[0] + (1 - alpha)*nz(mama[1]);
fama[0] = .5*alpha*mama[0]+(1-.5*alpha)*nz(fama[1]);
plot("mama", mama, NEW, RED);
plot("fama", fama, END, BLUE);
MAMA(src, fl, .5);
plot("z mama", rMAMA, NEW, RED);
plot("z fama", rFAMA, END, BLUE);
}
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485079
01/15/22 15:00
01/15/22 15:00
|
Joined: Aug 2017
Posts: 294 Netherlands
Grant
Member
|
Member
Joined: Aug 2017
Posts: 294
Netherlands
|
actually, I think Ulser Index (and R2) might be borked
Sharpe Ratio definitely was
after Zorro's update - suddenly started working I've made a template in Google Sheets to calculate/compare certain performance stats, based on 'testtrades.csv'. By doing so I can calculate any metric. This comes in handy now that I realize that 3 out of 5 profitable models have a slightly negative performance on the short side, about 7% performance drop for my multi asset strategy. From what I remember from the Wine bug forum, was that JCL discussed the SR differences between Zorro in a Linux/Wine vs a Windows environment. It seems that either JCL and/or the Wine devs resolved this issue. This might had effect on Zorro under Windows as well.
Last edited by Grant; 01/15/22 15:01.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485083
01/16/22 00:25
01/16/22 00:25
|
Joined: Aug 2017
Posts: 294 Netherlands
Grant
Member
|
Member
Joined: Aug 2017
Posts: 294
Netherlands
|
@Grant
I like Sharpe Ratio. occasionally I do favor higher SR and trade count despite of lower AR With fixed lot sizes, a 'low' AR shouldn't be a concern. Once your profit to risk (PF, SR... pick your own flavor) is high, you can boost the AR anyway with more aggressive position sizes. week in mild profits
and by "mild" I mean like +20% increase in capital (which sounds superb if we ignore earlier losses)
part of me is itching again, wanting to scale up
I mean, can afford it and it definitely makes everyday more exciting What is holding you from not doing so? You should be good to go once you ran some successful back tests with more leverage.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485086
01/16/22 15:47
01/16/22 15:47
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
hey! do You want to run Laguerre in Bollinger Bands Oscillator? well... NOW YOU CAN!
// percentage of a variable within a band
var percent(var a,var l,var h) {
if(l == h) return 50.;
return 100.*(a-l)/(h-l);
}
// Bollinger Bands Oscillator
var BBOscDeluxe3000(var* Data,int Period,var NbDev)
{
var basis = Laguerre(Data, .5); // random alpha, no ideas
var dev = StdDev(Data, Period);
var upper = basis + dev*NbDev;
var lower = basis - dev*NbDev;
return percent(Data[0],lower,upper);
}
for only 9.99$ per month or something ain't saying you should emm... anyhow... just flexing skillz feels good to slice it up whichever way I want to
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485094
01/19/22 22:07
01/19/22 22:07
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Trade foxer MATICUSDT (TICKS), Zorro 2.440
Bar period 1 min (avg 1 min) Trade period 2022-01-17..2022-01-19 Spread 2.0 pips (roll 0.00/0.00) Commission -0.10 Contracts per lot 1.0
Gross win/loss 222$-116$, +1821.3p Average profit 18320$/year, 1527$/month, 70.46$/day Max drawdown -43.38$ 41.2% (MAE -57.51$ 54.6%) Max down time 4 hours from Jan 2022 Max open margin 748$ Max open risk 1.17$ Trade volume 27686$ (4812174$/year) Transaction costs -1.41$ spr, -0.32$ slp, 0$ rol, -27.71$ com Capital required 878$
Number of trades 22 (3824/year, 74/week, 15/day) Percent winning 68.2% Max win/loss 30.12$ / -26.45$ Avg trade profit 4.79$ 82.8p (+255.5p / -287.3p) Avg trade slippage -0.0145$ -0.3p (+4.7p / -10.8p) Avg trade bars 129 (+120 / -147) Max trade bars 565 (9 hours) Max open trades 1 Max loss streak 2
Annual return 2087% Profit factor 1.91 (PRR 1.03) Scholz tax 28 EUR
Portfolio analysis OptF ProF Win/Loss Result
MATICUSDT .1000 1.91 15/7 +105 MATICUSDT:L .1000 0.70 6/5 -31 MATICUSDT:S .1000 10.74 9/2 +136
writing it down before it evaporates
Last edited by Lapsa; 01/19/22 22:16.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485107
01/23/22 12:38
01/23/22 12:38
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
bunch of changes Monte Carlo Analysis... Median AR 1147% Win 185$ MI 21.11$ DD 4.31$ Capital 20.42$ Trades 2965 Win 60.7% Avg +62.4p Bars 112 AR 1240% PF 1.60 SR 9.23 UI 1% R2 0.00
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485108
01/23/22 13:26
01/23/22 13:26
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
and some more Monte Carlo Analysis... Median AR 1153% Win 186$ MI 21.20$ DD 4.31$ Capital 20.42$ Trades 2961 Win 60.7% Avg +62.8p Bars 113 AR 1245% PF 1.60 SR 9.26 UI 1% R2 0.00
now start printing some dough you piece of shit
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485112
01/24/22 13:16
01/24/22 13:16
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
all those fib retracements eating dust
inflation through the roof, great war prospects in Europe
now we just need usdt & usdc collapse
WYCKOFFF STRUCTURE!!1111ELEVEN
Last edited by Lapsa; 01/24/22 13:34.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485114
01/24/22 14:17
01/24/22 14:17
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
percents go down, I push them back Monte Carlo Analysis... Median AR 1137% Win 184$ MI 20.90$ DD 4.31$ Capital 20.40$ Trades 3010 Win 60.5% Avg +61.3p Bars 111 AR 1230% PF 1.59 SR 9.14 UI 1% R2 0.00
print some money already...
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485115
01/24/22 14:36
01/24/22 14:36
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Separately, it is worth taking note of the Chart Pattern Elliott Wave indicator. This indicator compares the price movement with the most common Elliott Wave theory models — impulse and zigzag, and if it finds a match, it displays the best of them on the chart.
tradingview adding new indicators ironically - Chart Pattern Elliot Wave indicator fails to draw anything
Last edited by Lapsa; 01/24/22 14:36.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485122
01/25/22 07:23
01/25/22 07:23
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Monte Carlo Analysis... Median AR 1175% Win 189$ MI 21.31$ DD 4.31$ Capital 20.39$ Trades 2998 Win 60.4% Avg +62.9p Bars 112 AR 1255% PF 1.60 SR 9.32 UI 1% R2 0.00
laptop gets about 1 second delay per day bit ludicrous should automate time sync QLSMA banned, ALMA in, some decycler love for longs, trix stuff spliced per side, some additional lag here and there and with all the updates - January doesn't look half bad retrospectively... -_-
Last edited by Lapsa; 01/25/22 07:39.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485126
01/25/22 21:47
01/25/22 21:47
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
10 / 14 calls clock out of sync by a second again hacks here and theresync per week -> per 7 minutes let's see how it behaves
Last edited by Lapsa; 01/25/22 22:01.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485127
01/25/22 23:42
01/25/22 23:42
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485168
01/31/22 10:56
01/31/22 10:56
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
numbehs go down, I push them back Monte Carlo Analysis... Median AR 1205% Win 196$ MI 21.66$ DD 4.31$ Capital 20.29$ Trades 3035 Win 60.4% Avg +64.6p Bars 113 AR 1281% PF 1.62 SR 9.52 UI 1% R2 0.00
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485188
02/02/22 01:33
02/02/22 01:33
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
UI and R2 are not broken works fine when I plug in compounding on Balance*.25 it's UI 2% and R2 .8 even looks reasonably sane but that's not quite what I'm looking for I want that snowball Monte Carlo Analysis... Median AR 1227% Win 200$ MI 21.96$ DD 4.31$ Capital 20.26$ Trades 3009 Win 60.3% Avg +66.4p Bars 114 AR 1300% PF 1.63 SR 9.68 UI 1% R2 0.00
pushed even further 9 months of data
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485193
02/02/22 11:40
02/02/22 11:40
|
Joined: Aug 2017
Posts: 294 Netherlands
Grant
Member
|
Member
Joined: Aug 2017
Posts: 294
Netherlands
|
I believe that 25% is a fair rate, which is prob similar to an Optimal F output.
Last edited by Grant; 02/02/22 14:19.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485196
02/02/22 15:48
02/02/22 15:48
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
@Grant yeah, got similar thinking. which is why I played around those values
but that's late game. I want that snowball
----------------
looks like markets gonna struggle down further
bunch of fake optimism without an actual rebound
US debt records, Russian drama, SPY falling again
but at least that's a movement!
enough of that 1% channel sideways bullshit
Last edited by Lapsa; 02/02/22 15:56.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485212
02/05/22 00:34
02/05/22 00:34
|
Joined: Aug 2017
Posts: 294 Netherlands
Grant
Member
|
Member
Joined: Aug 2017
Posts: 294
Netherlands
|
I try to understand your thought process, but I don't.
Why would you develop a system, knowing on beforehand that it will clearly over-fit on your in-sample data? Knowing how your system behaves on out-of-sample data should be key before going live.
Last edited by Grant; 02/05/22 00:36.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485214
02/05/22 05:31
02/05/22 05:31
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
With `EndDate = 20220202;` Monte Carlo Analysis... Median AR 1244% Win 204$ MI 22.29$ DD 4.31$ Capital 20.25$ Trades 3015 Win 60.5% Avg +67.5p Bars 114 AR 1321% PF 1.65 SR 9.85 UI 1% R2 0.00
Without `EndDate = 20220202;` Monte Carlo Analysis... Median AR 1081% Win 202$ MI 21.89$ DD 5.57$ Capital 22.71$ Trades 3030 Win 60.4% Avg +66.5p Bars 115 AR 1157% PF 1.64 SR 9.70 UI 1% R2 0.00
With `StartDate = 20220201` Loss -2.51$ MI -18.11$ DD 2.71$ Capital 19.83$ Trades 43 Win 46.5% Avg -58.4p Bars 109 AR -1096% PF 0.44 SR -16.88 UI 100% R2 0.00
Last edited by Lapsa; 02/05/22 05:35.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485215
02/05/22 06:42
02/05/22 06:42
|
Joined: Feb 2018
Posts: 25
1ND1G0
Newbie
|
Newbie
Joined: Feb 2018
Posts: 25
|
Yep, I'm with Grant and don't really understand what your approach is here. Are you looking for feedback by posting here, or are you just using the forum as a place to dump your notes? I think most of the rest of us just use a document on our local machines for some of the observations you are making. But each to their own. To clarify - are you live with any of these strategies or do you have a method you are following that is taking you closer to going live with these? It sometimes seems like you are generating metrics just for the sake of generating them, however big numbers are meaningless (at least to most readers here I would suspect) if they are not robust. Have a read of this (if you haven't done so already): https://financial-hacker.com/build-better-strategies-part-3-the-development-process/ and see if this can help focus the mind.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485219
02/05/22 08:10
02/05/22 08:10
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
but I suppose I generally look to see how similar my backtest performance was when compared to forward testing or live trading
and what do you think I do? Are you seeing annualised returns of 1000%+ during live trading in line with some of the recent results you are posting here?
are you from the past? it's the worst crash since March 2020 either way equity curve goes - high linearity is the least likeable attribute of it yes, they do align. but only because my expectations are sane
Last edited by Lapsa; 02/05/22 08:21.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485224
02/05/22 09:39
02/05/22 09:39
|
Joined: Aug 2017
Posts: 294 Netherlands
Grant
Member
|
Member
Joined: Aug 2017
Posts: 294
Netherlands
|
because you don't consider that my in-sample data is all the meaningful data there is
my out-of-sample data is tomorrow's failure
what else you want me to test it on?
different asset? generated white noise? Mozart's 40th symphony?
I will answer that by explaining what I did (without implying to be mr know it all!). I've picked February & March 2020 as my in-sample period (1M data). Why? Because February had a relative low volatility, but March was sky high. So this short period contained at lot of valuable information. Then I ran a ton of backtests from February 2020 till May 2021, just to see how my models (I use ML, hence 'models') behave in- and out-of-sample. By doing so, you see exactly how easy it is to over-fit a model. In- and out-of-sample Out-of-sample
Last edited by Grant; 02/05/22 12:02.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485234
02/06/22 11:00
02/06/22 11:00
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
@Grant
I'm missing your point
it feels like you are stating obvious
---------
also - there is a bit of difference when working with machine learning
the idea being - when you over fit ML model, you can't go back and cherry pick out the good parts out of trained model cause it's gibberish
at the very least - not as easy
---------
about mr know it all
well... excuse my tone - I deliberately try to be dense, direct and open
I think that's just the fastest way to knowledge
you have made me think about things that would otherwise fly by unnoticed, so thanks
Last edited by Lapsa; 02/06/22 11:16.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485235
02/06/22 12:49
02/06/22 12:49
|
Joined: Aug 2017
Posts: 294 Netherlands
Grant
Member
|
Member
Joined: Aug 2017
Posts: 294
Netherlands
|
I appreciate that 'tone' sir, so no problem! I find the different approaches on this forum and financial-hacker refreshing to read.
Yes, there's nothing magical about my approach in general, but why would you not out-of-sample test your strategy first on recent historical data, and once it behaves stable, test it on a demo account? By skipping the first part, the uncertainty is even higher and so will be your failure rate, so you're wasting more time in your development process.
As for ML, I'm well aware of the bias-variance tradeoff. I apply techniques like cross-validation and regularisation to control this issue as much as possible, but granted, it's tough, esp with financial market data.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485241
02/07/22 06:22
02/07/22 06:22
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
most problematic period of time conflicting rules identified curve looks reasonably nice if we throw them out
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485242
02/07/22 09:05
02/07/22 09:05
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
numbehs go down, I push them back Monte Carlo Analysis... Median AR 1185% Win 203$ MI 21.91$ DD 4.42$ Capital 20.41$ Trades 3030 Win 60.4% Avg +67.1p Bars 115 AR 1288% PF 1.64 SR 9.52 UI 1% R2 0.00
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485256
02/09/22 17:12
02/09/22 17:12
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
numbehs go up themselves Monte Carlo Analysis... Median AR 1206% Win 210$ MI 22.47$ DD 4.42$ Capital 20.38$ Trades 3065 Win 60.7% Avg +68.6p Bars 115 AR 1324% PF 1.66 SR 9.77 UI 1% R2 0.00
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485258
02/09/22 19:41
02/09/22 19:41
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
woah... marked that channel right when it started at 20:00 resistance at high volume short wall built ~15min ago support at 1h Tenkan
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485266
02/11/22 11:48
02/11/22 11:48
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
PF 1.7 has been breached! Monte Carlo Analysis... Median AR 1227% Win 220$ MI 23.42$ DD 4.77$ Capital 21.03$ Trades 2969 Win 60.7% Avg +74.2p Bars 119 AR 1336% PF 1.71 SR 10.20 UI 1% R2 0.00
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485281
02/16/22 14:11
02/16/22 14:11
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Don't skip series calls with if statements
sad panda makes sense though
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485349
02/28/22 12:46
02/28/22 12:46
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
Monte Carlo Analysis... Median AR 1415% Win 244$ MI 24.48$ DD 4.09$ Capital 19.47$ Trades 3020 Win 60.1% Avg +80.8p Bars 124 AR 1509% PF 1.78 SR 10.85 UI 1% R2 0.03
$100 start roflnumbehs Monte Carlo Analysis... Median AR 113% Win 495459134$ MI 49692053$ DD 112745680$ Capital 661451776$ Trades 3020 Win 60.1% Avg +80.8p Bars 124 AR 90% PF 1.27 SR 2.96 UI 4% R2 0.00
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485403
03/07/22 21:54
03/07/22 21:54
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
cause it makes sense
and thanks for the kind words....
Last edited by Lapsa; 03/07/22 21:55.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485405
03/07/22 22:15
03/07/22 22:15
|
Joined: Aug 2017
Posts: 294 Netherlands
Grant
Member
|
Member
Joined: Aug 2017
Posts: 294
Netherlands
|
But that's in-sample (right?), which makes this return completely irrelevant. Why not reserve some history for out-of-sample testing? This will speed up your dev process.
Last edited by Grant; 03/07/22 23:37.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485409
03/08/22 06:31
03/08/22 06:31
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
What do you mean by in-sample?
That's the whole history there is. MATIC is around for couple years. I'm just ignoring the very initial stage when it had no traction at all.
What's the point of keeping out-of-sample history if I'm gonna test it anyway? Doesn't that sort of make it in-sample too?
I don't get your point.
----
> But that's in-sample (right?)
I didn't fine tune it for a single week and then extrapolated expected returns. I fine tuned it for the (!) whole meaningful history I got. And those are the numbers that come up.
Last edited by Lapsa; 03/08/22 07:14.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485410
03/08/22 13:37
03/08/22 13:37
|
Joined: Aug 2017
Posts: 294 Netherlands
Grant
Member
|
Member
Joined: Aug 2017
Posts: 294
Netherlands
|
Let's compare strategy development cycles in a nut shell..
Yours: take the full data set (in-sample) for tuning > skip out-of-sample testing > test it right away on live market data > weeks go on and now you realize that it performs poorly (most cases) or you have an unicorn.
The traditional way: take 75-90% from your data for tuning > test it out-of-sample on the rest of your data set > you realize almost right away that it performs poorly (most cases) or you have an unicorn > once you have that unicorn, you run it on live market data for a final test ride (better safe than sorry).
Advantages of the traditional method: you save much time and you can compare out-of-sample results from multiple strategies / tune-settings (very important).
Your strategy has much potential when I look at the in-sample results, but your tuning method leads to over-fitting. That's the main weakness that you need to fix.
Last edited by Grant; 03/08/22 15:08.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485416
03/08/22 18:47
03/08/22 18:47
|
Joined: Aug 2017
Posts: 294 Netherlands
Grant
Member
|
Member
Joined: Aug 2017
Posts: 294
Netherlands
|
I can appreciate your honesty. Setting up successful algo trading isn't like just baking a cake There's no golden standard for robustness/over-fitting (both are -IMO- pretty much the same), so I can only speak for myself. I look for decent OOS statistics, enough trades (say 50+), combined with a decent PF (say 1.25+). More precise would be to look at the performance offsets between your in- and out-of-sample stats. To read it from a different perspective, check this interesting blog article https://quantlane.com/blog/avoid-overfitting-trading-strategies/Believe me, even with 10 years of data with 1000+ trades you can have over-fitting, so a large in-sample set is not a guarantee for robustness. This largely depends on the complexity of your approach, the more complex, the higher the likelihood of over-fitting.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485418
03/08/22 22:24
03/08/22 22:24
|
Joined: Aug 2017
Posts: 294 Netherlands
Grant
Member
|
Member
Joined: Aug 2017
Posts: 294
Netherlands
|
sadly - I find that blog article empty. nicely written, good theory overview, near zero practical value
It provides basic guidelines. Don't expect effective 'recipes' in this secretive area. > enough trades (say 50+)
that's like couple days
to my mind - tells nothing
That's just a number to give an indication, just like reserving 10-25% from your data set for OOS testing. > not a guarantee for robustness
I don't believe there is any
True, but I provide you some guidelines to increase the likelihood. Up to you what do with that, it's your broker account. > This largely depends on the complexity of your approach, the more complex, the higher the likelihood of over-fitting.
already mentioned - think it's much more important when working with machine learning
> Believe me, even with 10 years of data with 1000+ trades you can have over-fitting
I know it's there. just don't think it's that easy to pick it out by delaying tests on some particular data
Yes, this is esp true with ML, but you can basically over-fit any method. I don't know about the complexity of your approach, but those in-sample stats are way too optimistic.
|
|
|
Re: Lapsa's very own thread
[Re: Grant]
#485419
03/09/22 06:02
03/09/22 06:02
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
but those in-sample stats are way too optimistic.
well... those are just numbers my expectations are slightly lower - I expect it to be profitable and that's all
Last edited by Lapsa; 03/09/22 09:29.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485427
03/09/22 13:13
03/09/22 13:13
|
Joined: Aug 2017
Posts: 294 Netherlands
Grant
Member
|
Member
Joined: Aug 2017
Posts: 294
Netherlands
|
[quote=Grant] my expectations are slightly lower - I expect it to be profitable and that's all expectations <-> reality When your actual returns were only slightly lower, then we wouldn't had this conversation. Sorry, but you need to face the reality, which is that your strategy is over-fitting big time.
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485428
03/09/22 13:21
03/09/22 13:21
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485484
03/17/22 11:46
03/17/22 11:46
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485486
03/17/22 12:34
03/17/22 12:34
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
same data, same configuration, same code new version >300 millions of imaginary dollahs gone Why do I get a different backtest result? Because of updated price histories, updated asset lists, or changes listed below. Find out by comparing both logs. has to be changes listed below I mean - perhaps it is more accurate and what not but surely does reinforce feeling how stupid and pointless whole thing is
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485487
03/17/22 13:27
03/17/22 13:27
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
[18455: Sat 21-05-01 02:16] 0.30 +0.18 2/0 (0.834370) [MATICUSDT::L36084] Reverse 10@0.833370: +0.17 at 02:16:00 [MATICUSDT::S45585] Short 10@0.833369 Risk 0 t at 02:16:00
[18456: Sat 21-05-01 02:17] 0.27 -0.0131 2/1 (0.833850)
[18455: Sat 21-05-01 02:16] 0.30 +0.18 2/0 (0.834370) [MATICUSDT::L36084] Reverse 10@0.834370: +0.18 at 02:16:00 [MATICUSDT::S45585] Short 10@0.834370 Risk 0 t at 02:16:00
[18456: Sat 21-05-01 02:17] 0.29 -0.0031 2/1 (0.833850)
well... the algo seems to be working same so that's the good news with `Slippage = 0` - results are same and the mystery is solved probably some cheese got moved with the introduction of `Penalty` parameter in fact - 2.44 version indeed looks bit more suspicious. ~ price falls from 100 @ minute1 to 50 @ minute2, yet reversal in between happens at price 25. surely realistic and possible yet unknown how Zorro comes up with that anyhow - should read that help file a bit more
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485610
03/30/22 14:50
03/30/22 14:50
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
my friend bought a hunting rifle, I bought a Zorro license I like MFI at least for a quick glance on how volume affects the price
function MFI(var Period, var High, var Low, var Close, var Volume) {
vars vol = series(Volume);
vars hlc = series((High + Low + Close) / 3);
var pos=.0;
var neg=.0;
var i = 0;
for(i=0;i<Period;i++) {
if (hlc[i] > hlc[i+1]) pos = pos + vol[i];
if (hlc[i] < hlc[i+1]) neg = neg + vol[i];
}
var mfr = pos / neg;
var mfi = 0;
if (1+mfr != 0) mfi = 100 - 100 / (1 + mfr);
return mfi;
}
|
|
|
Re: Lapsa's very own thread
[Re: Lapsa]
#485627
04/02/22 20:55
04/02/22 20:55
|
Joined: Aug 2021
Posts: 237
Lapsa
OP
Member
|
OP
Member
Joined: Aug 2021
Posts: 237
|
green week (ain't over yet...) ~15% capital gains Monte Carlo Analysis... Median AR 1445% Win 257$ MI 23.18$ DD 3.91$ Capital 18.76$ Trades 3216 Win 60.5% Avg +79.8p Bars 128 AR 1483% PF 1.81 SR 10.73 UI 0% R2 0.15
some more crap:
function CMF(var Period, var High, var Low, var Close, var Volume) {
var ad = ((2*Close-Low-High)/(High-Low))*Volume;
return Sum(series(ad), Period) / Sum(series(Volume), Period)*100;
}
function VPT(var Volume, vars Close) {
vars vpt = series(0, 2);
vpt[0] = vpt[1] + Volume * ((Close[0] - Close[1])/Close[1]);
return vpt[0];
}
function EOM(var Length, vars High, vars Low, var Volume) {
var div = 10000000000; // improvised :D
var eom = SMA(
series(
div * (
(High[0]+Low[0])/2 - (High[1]+Low[1])/2
) * (High[0] - Low[0]) / Volume
), Length
);
return eom*1000; // also improvised
}
aka Chaikin's money flow, volume price trend (or something) and ease of movement
|
|
|
|