Question regarding transaction costs

Posted By: simonkrebs

Question regarding transaction costs - 04/15/21 08:34

Hi,

I'm testing the following script and I've encountered a problem: the transaction costs (787 trades / $16758 total costs = $21 per trade) in the performance report (especially rollover costs -> $12155) seem way too high to me. Especially compared to the costs that are shown to me in the Z12 (4807 trades / $8864 total costs = $1.9 per trade) script.

Here is the source code of the script:

Code
function tradeCounterTrend()
{
	TimeFrame = frameSync(4);
	vars Prices = series(price());
	vars Cycles = series(BandPass(Prices,30,2));
	vars Signals = series(FisherN(Cycles,500));
	var Threshold = optimize(1,0.8,1.2,0.1);

	LifeTime = 4*optimize(100,50,150,10);
	Trail = Stop = optimize(10,4,20,2)*ATR(100);
	MaxLong = MaxShort = -1;
	
	var Regime = FractalDimension(Prices,100);
	var RegimeThreshold = optimize(1.5,1.3,1.7,0.1);
	if(Regime > RegimeThreshold)
	{
		if(crossUnder(Signals,-Threshold))
			enterLong(); 
		else if(crossOver(Signals,Threshold))
			enterShort();
	} 
}

function tradeTrend()
{
	TimeFrame = 1;
	vars Prices = series(price());
	vars Trends = series(Laguerre(Prices,optimize(0.05,0.02,0.15,0.01)));
	
	Stop = optimize(10,4,20,2)*ATR(100);
	Trail = 0;
	LifeTime = 0;
	MaxLong = MaxShort = -1;
	
	var MMI_Period = optimize(300,100,400,100);
	vars MMI_Raws = series(MMI(Prices,MMI_Period));
	vars MMI_Avgs = series(SMA(MMI_Raws,MMI_Period));
	
	if(falling(MMI_Avgs)) {
		if(valley(Trends))
			enterLong();
		else if(peak(Trends))
			enterShort();
	}
}

function run()
{
	set(PARAMETERS+FACTORS+LOGFILE+TESTNOW+PLOTNOW);
	StartDate = 2010; // further back due to WFO
	EndDate = Now;   // fixed simulation period
	BarPeriod = 60;	// 1 hour bars
	LookBack = 4*500;	// needed for FisherN()
	Capital = 10000;
	if(Train) Detrend = TRADES;
	
	assetList("AssetsGP-org");

	NumWFOCycles = 10; // activate WFO
	NumCores = -1;		// multicore training (Zorro S only)
	ReTrainDays = 147;
	if(ReTrain) {
		UpdateDays = -1;	// update price data from the server 
		SelectWFO = -1;	// select the last cycle for re-optimization
		reset(FACTORS);
	}
	
// portfolio loop
	for(listed_assets) {
	while(algo(loop("TRND","CNTR"))) {
		
		asset(Asset);
// method 1: invest 1% of the balance in any trade
		//Margin = 0.01 * (Capital + ProfitClosed);	

// method 2: invest 50% of Optimal-F		
		//Margin = 0.5 * OptimalF * (Capital + ProfitClosed);

// method 3: invest the square root of the component profit
		Margin = 0.5 * OptimalF * Capital * sqrt(1 + ProfitClosed/Capital);

		if(Algo == "TRND") 
			tradeTrend();
		else if(Algo == "CNTR") 
			tradeCounterTrend();
	}	
	}	
}

Here is my asset list:
Code
Name,Price,Spread,RollLong,RollShort,PIP,PIPCost,MarginCost,Leverage,LotAmount,Commission,Symbol
AUD/USD,0.72503,0.00003,0.0241,-0.0581,0.0001,0.1,-1,0,1000,0.8,AUD/USD
EUR/CHF,1.1304,0.00011,0.0694,-0.1845,0.0001,0.101,-1,0,1000,0.8,EUR/CHF
EUR/USD,1.1702,0.00003,-1.1774,0.4444,0.0001,0.1,-1,0,1000,0.8,EUR/USD
GBP/USD,1.3189,0.00009,-0.7095,0.2335,0.0001,0.1,-1,0,1000,0.8,GBP/USD
USD/CAD,1.2951,0.00008,0.1074,-0.2356,0.0001,0.076,-1,0,1000,0.8,USD/CAD
USD/CHF,0.96595,0.00009,0.6245,-0.9765,0.0001,0.101,-1,0,1000,0.8,USD/CHF
USD/JPY,112.37,0.005,0.3485,-0.924,0.01,0.09,-1,0,1000,0.8,USD/JPY
XAG/USD,14.18,0.008,-0.003,0.00138,0.01,0.5,-1,0,50,0.8,XAG/USD
XAU/USD,1202.74,0.05,-0.0121,0.00275,0.01,0.01,-1,0,1,0.8,XAU/USD
GER30,12181.07,1.27,-0.32,-0.08,0.01,0.011702,-1,0,1,0.8,GER30
NAS100,7498.5,1.6,-0.54,0.06,0.01,0.01,-1,0,1,0.8,NAS100
SPX500,2905.3,0.4,-0.59,0.06,0.01,0.01,-1,0,1,0.8,US500
UK100,7294.1,2,-0.6,0.32,0.01,0.013188,-1,0,1,0.8,UK100
US30,26283.3,2.5,-1.46,0.12,0.01,0.01,-1,0,1,0.8,US30


Here is the Performance Report:

Code
WFA Test Test 

Simulated account   AssetsGP-org 
Bar period          1 hour (avg 86 min)
Total processed     98854 bars
Simulation period   2010-05-03..2021-04-14 (66302 bars)
Test period         2014-07-22..2021-04-14 (40685 bars)
Lookback period     2000 bars (17 weeks)
WFO test cycles     9 x 4520 bars (38 weeks)
Training cycles     10 x 25617 bars (220 weeks)
Montecarlo cycles   200
Simulation mode     Realistic (slippage 5.0 sec)
Capital invested    10000$

Gross win/loss      172524$ / -133319$ (+143168p)
Average profit      5825$/year, 485$/month, 22.40$/day
Max drawdown        -17516$ 44.7% (MAE -18534$ 47.3%)
Total down time     59% (TAE 99%)
Max down time       74 weeks from Jan 2019
Max open margin     3602$
Max open risk       9422$
Trade volume        24771238$ (3680543$/year)
[b]Transaction costs   -1857$ spr, -410$ slp, -12155$ rol, -2336$ com[/b]
Capital required    3109$

Number of trades    787 (117/year, 2/week)
Percent winning     46.0%
Max win/loss        8193$ / -1618$
Avg trade profit    49.82$ 181.9p (+1740.4p / -1145.5p)
Avg trade slippage  -0.52$ -1.9p (+16.5p / -17.5p)
Avg trade bars      342 (+424 / -272)
Max trade bars      3189 (27 weeks)
Time in market      663%
Max open trades     11
Max loss streak     11 (uncorrelated 11)

Annual growth rate  26.71%
Profit factor       1.29 (PRR 1.17)
Sharpe ratio        0.70 (Sortino 0.75)
R2 coefficient      0.000
Ulcer index         14.2%
Scholz tax          27041 EUR

For comparison the performance report with Z12 script (same asset list, same time period):
Code
WFA Test Z12  (TICKS)

Simulated account   AssetsGP-org 
Bar period          4 hours (avg 338 min)
Total processed     24044 bars, 184654056 ticks
Simulation period   2010-04-29..2020-12-24 (16561 bars)
Test period         2013-09-26..2020-12-24 (11238 bars)
Lookback period     500 bars (16 weeks)
WFO test cycles     19 x 591 bars (19 weeks)
Training cycles     20 x 5323 bars (178 weeks)
Montecarlo cycles   200
Simulation mode     Realistic ticks (slippage 5.0 sec)

Gross win/loss      108085€ / -74941€ (+1198083p)
Virtual win/loss    115521€ / -82039€
Average profit      4576€/year, 381€/month, 17.60€/day
Max drawdown        -2976€ 9.0% (MAE -3149€ 9.5%)
Total down time     67% (TAE 95%)
Max down time       24 weeks from Oct 2018
Max open margin     1300€
Max open risk       650056€
Trade volume        18149080€ (2505904€/year)
[b]Transaction costs   -1272€ spr, -2.64€ slp, -5650€ rol, -1940€ com[/b]
Capital required    3215€

Number of trades    4807 (664/year, 13/week, 3/day)
Percent winning     51.3%
Max win/loss        926€ / -924€
Avg trade profit    6.89€ 249.2p (+1583.1p / -1158.2p)
Avg trade slippage  -0.0005€ -0.0p (+19.3p / -20.4p)
Avg trade bars      41 (+44 / -38)
Max trade bars      1204 (40 weeks)
Time in market      1792%
Max open trades     41
Max loss streak     21 (uncorrelated 12)

Annual return       142%
Profit factor       1.44 (PRR 1.38)
Sharpe ratio        1.29 (Sortino 1.34)
Kelly criterion     1.16
Annualized StdDev   111.13% 
R2 coefficient      0.920
Ulcer index         3.0%
Scholz tax          8742 EUR
Cycle performance   1.35 1.48 1.48 1.46 

Can anyone see what is causing the high transaction costs in the script?

Greetings and thanks for your help,

Simon
© 2024 lite-C Forums