Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (1 invisible), 672 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 1
Page 3 of 25 1 2 3 4 5 24 25
Re: Lapsa's very own thread [Re: Lapsa] #484089
09/04/21 09:08
09/04/21 09:08
Joined: Aug 2021
Posts: 237
L
Lapsa Offline OP
Member
Lapsa  Offline OP
Member
L

Joined: Aug 2021
Posts: 237
Just a reminder that winning trades is possible.


[Linked Image]

[Linked Image]

I wonder how will it land.

[Linked Image]

Hmm... That's quite a bump ignored.

[Linked Image]

As Ben Finegold would say: "Frankly ridiculous!"

[Linked Image]

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
L
Lapsa Offline OP
Member
Lapsa  Offline OP
Member
L

Joined: Aug 2021
Posts: 237
Day4 - still in profits.

Re: Lapsa's very own thread [Re: Lapsa] #484099
09/07/21 09:39
09/07/21 09:39
Joined: Aug 2021
Posts: 237
L
Lapsa Offline OP
Member
Lapsa  Offline OP
Member
L

Joined: Aug 2021
Posts: 237
Some more green numbers.


[Linked Image]


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
L
Lapsa Offline OP
Member
Lapsa  Offline OP
Member
L

Joined: Aug 2021
Posts: 237
Autocorrelation Periodogram Dominant Cycle

I 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.

Code
#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);
}


[Linked Image]

Quote

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:


Code
	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);
	}


Code

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;
}


[Linked Image]

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] #484110
09/09/21 11:12
09/09/21 11:12
Joined: Aug 2021
Posts: 237
L
Lapsa Offline OP
Member
Lapsa  Offline OP
Member
L

Joined: Aug 2021
Posts: 237
((38 * 45) * 1440) * 90 = 221616000

Lots of looping even for Lite C.

Re: Lapsa's very own thread [Re: Lapsa] #484117
09/09/21 22:45
09/09/21 22:45
Joined: Aug 2021
Posts: 237
L
Lapsa Offline OP
Member
Lapsa  Offline OP
Member
L

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).


[Linked Image]

Quote

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)

[Linked Image]


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] #484118
09/09/21 22:55
09/09/21 22:55
Joined: Aug 2021
Posts: 237
L
Lapsa Offline OP
Member
Lapsa  Offline OP
Member
L

Joined: Aug 2021
Posts: 237
^ 3 Trades, Win 100%, Avg 558.2p, PF 10.00 on 45 BarPeriod

grin

Last edited by Lapsa; 09/09/21 22:56.
Re: Lapsa's very own thread [Re: Lapsa] #484133
09/14/21 11:49
09/14/21 11:49
Joined: Aug 2021
Posts: 237
L
Lapsa Offline OP
Member
Lapsa  Offline OP
Member
L

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:


[Linked Image]


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
L
Lapsa Offline OP
Member
Lapsa  Offline OP
Member
L

Joined: Aug 2021
Posts: 237
hmm... might be up to something

Quote

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


[Linked Image]


----

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
L
Lapsa Offline OP
Member
Lapsa  Offline OP
Member
L

Joined: Aug 2021
Posts: 237
current run


[Linked Image]


boringly good so far

more interested how it behaves when things go wrong

Page 3 of 25 1 2 3 4 5 24 25

Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1