Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 642 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Changing "LookBack" produces completely different results? #476337
02/19/19 16:38
02/19/19 16:38
Joined: Jan 2019
Posts: 73
berlin
L
laz Offline OP
Junior Member
laz  Offline OP
Junior Member
L

Joined: Jan 2019
Posts: 73
berlin
Hello everybody, I am currently testing an example from the following link:
https://robotwealth.com/getting-started-neural-networks-algorithmic-trading/

I adjusted the script

Code:
function run() {	

	set(RULES|PEEK|OPENEND|TESTNOW|PLOTNOW|LOGFILE); 
	
	StartDate    = 2014;
	EndDate      = 2016;
	BarPeriod    = 60;
	LookBack     = 100;

	NumWFOCycles = 5;
	DataSplit    = 80;	
	
	if(Train) Hedge = 2;
	
	MaxBars      = slider(2,0,0,100000,"MaxBars","MaxBars");	
	PlotWidth    = slider(3,1500,1500,10000,"PlotWidth","PlotWidth");	
		
	asset("EURUSD");

	Spread = Commission = Slippage = RollLong = RollShort = 0;
	
	vars Close = series(priceClose());	
	var  Sig1  = scale(ATR(10)-ATR(50), 100);
	var  Sig2  = (Close[0]-Close[1])/Close[1];
	var  Sig3  = (Close[0]-Close[5])/Close[5];
	var  Sig4  = (Close[0]-Close[10])/Close[10];
	
	var  ObL   = -1;
	var  ObS   = -1;	
		
	if(priceClose(-5) - priceClose(0) >  20*PIP) ObL = 1;
	if(priceClose(-5) - priceClose(0) < -20*PIP) ObS = 1;
	
	LifeTime = 5;
	
	var l = adviseLong (PERCEPTRON+BALANCED, ObL , Sig1, Sig2, Sig3, Sig4);
	var s = adviseShort(PERCEPTRON+BALANCED, ObS , Sig1, Sig2, Sig3, Sig4);	
	
	if(!Train) {
		
		if(l > 0 and s < 0) reverseLong(1); else 
		if(s > 0 and l < 0) reverseShort(1);
		
	}
	
	ObL = ifelse(ObL>0,ObL,0);
	ObS = ifelse(ObS>0,ObS,0);
	
	l = ifelse(l>0,l,0);
	s = ifelse(s>0,s,0);
	
   plot("ObL", ObL, NEW, GREEN);
	plot("ObS",-ObS, 0, RED);
	
	plot("l", l, NEW, GREEN);
	plot("s",-s, 0, RED);
	
}


and was surprised by the results.


Quote:
WFA Test PerceptronV100 EURUSD

Simulated account AssetsFix
Bar period 1 hour (avg 86 min)
Simulation period 2014-01-08..2016-12-30 (18208 bars)
Test period 2015-07-06..2016-12-30 (9105 bars)
Lookback period 100 bars (4 days)
WFO test cycles 4 x 2276 bars (19 weeks)
Training cycles 5 x 9103 bars (78 weeks)
Montecarlo cycles 200
Simulation mode Realistic (slippage 0.0 sec)
Avg bar 9.0 pips range
Spread 0.0 pips (roll 0.00/0.00)
Contracts per lot 1000.0

Gross win/loss 627$ / -505$ (+1393p)
Average profit 82.24$/year, 6.85$/month, 0.32$/day
Max drawdown -46.39$ 37.9% (MAE -47.85$ 39.1%)
Total down time 88% (TAE 31%)
Max down time 7 weeks from Dec 2015
Max open margin 2.56$
Max open risk 10.24$
Trade volume 575122$ (386798$/year)
Transaction costs 0$ spr, 0$ slp, 0$ rol
Capital required 68.46$

Number of trades 593 (399/year, 8/week, 2/day)
Percent winning 51.3%
Max win/loss 30.52$ / -11.34$
Avg trade profit 0.21$ 2.3p (+23.5p / -19.9p)
Avg trade slippage 0$ 0.0p (+0.0p / -0.0p)
Avg trade bars 5 (+5 / -5)
Max trade bars 7 (7 hours)
Time in market 39%
Max open trades 1
Max loss streak 8 (uncorrelated 9)

Annual return 120%
Profit factor 1.24 (PRR 1.11)
Sharpe ratio 1.44
Kelly criterion 1.73
R2 coefficient 0.864
Ulcer index 12.6%

But if you change "LookBack" from 100 to 200, the result changes drastically:



Quote:
WFA Test PerceptronV100 EURUSD

Simulated account AssetsFix
Bar period 1 hour (avg 86 min)
Simulation period 2014-01-14..2016-12-30 (18108 bars)
Test period 2015-07-08..2016-12-30 (9055 bars)
Lookback period 200 bars (12 days)
WFO test cycles 4 x 2263 bars (19 weeks)
Training cycles 5 x 9053 bars (78 weeks)
Simulation mode Realistic (slippage 0.0 sec)
Avg bar 9.1 pips range
Spread 0.0 pips (roll 0.00/0.00)
Contracts per lot 1000.0

Gross win/loss 551$ / -594$ (-497p)
Average profit -29.43$/year, -2.45$/month, -0.11$/day
Max drawdown -60.19$ -138.1% (MAE -64.42$ -147.8%)
Total down time 99% (TAE 39%)
Max down time 23 weeks from Jan 2016
Max open margin 2.54$
Max open risk 10.17$
Trade volume 759622$ (512850$/year)
Transaction costs 0$ spr, 0$ slp, 0$ rol
Capital required 88.20$

Number of trades 777 (525/year, 11/week, 3/day)
Percent winning 50.1%
Max win/loss 10.58$ / -14.76$
Avg trade profit -0.0561$ -0.6p (+16.1p / -17.4p)
Avg trade slippage 0$ 0.0p (+0.0p / -0.0p)
Avg trade bars 5 (+5 / -5)
Max trade bars 7 (7 hours)
Time in market 46%
Max open trades 1
Max loss streak 7 (uncorrelated 10)

Annual return -33%
Profit factor 0.93 (PRR 0.84)
Sharpe ratio -0.54
Kelly criterion -0.89
R2 coefficient 0.555
Ulcer index 100.0%

The Trades / Signals (Output) of the Perceptron are also very different.
Why is that?

Attached Files
LB-100.txt (72 downloads)
LB-100.png
LB-200.txt (64 downloads)
LB-200.png
Last edited by laz; 02/19/19 17:23.
Re: Changing "LookBack" produces completely different results? [Re: laz] #476339
02/19/19 17:47
02/19/19 17:47
Joined: Sep 2003
Posts: 929
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 929
Random results mean the system is unprofitable. I think its good to test with different lookback, or different start date, for checking if a positive result is really by the algorithm and not just random.

I don't think a perceptron works for trading in this way. It is too simple. Maybe it works if you generated really ingenious signals.

Re: Changing "LookBack" produces completely different results? [Re: Spirit] #476340
02/19/19 18:20
02/19/19 18:20
Joined: Jan 2019
Posts: 73
berlin
L
laz Offline OP
Junior Member
laz  Offline OP
Junior Member
L

Joined: Jan 2019
Posts: 73
berlin
Hi Spirit and thanks for the fast answer. I also think that a perceptron is not necessarily suitable, actually I was testing what kind of goal/target I use and I noticed the strange result after changing LookBack.

So much randomness by this little change?

That scares me a lot, it would be better if that is a bug ... grin crazy

Last edited by laz; 02/19/19 18:22.

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1