Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, alibaba, Quad), 761 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: adviseLong/Short, WFO and multiple assets [Re: jcl] #462028
09/05/16 05:42
09/05/16 05:42
Joined: Jul 2016
Posts: 64
G
gtell Offline OP
Junior Member
gtell  Offline OP
Junior Member
G

Joined: Jul 2016
Posts: 64
Thanks JCL for your tip, it really seems to work.
However, consider the following code:

Code:
#include <r.h>

var change(int n)
{
	return scale((priceClose(0) - priceClose(n))/priceClose(0),100)/100;
}

var range(int n)
{
	return scale((HH(n) - LL(n))/priceClose(0),100)/100;
}

int prevTrend = 0;
var prevPrice = 0;

function run()
{
	StartDate = 20140601;
	BarPeriod = 60;	// 1 hour
	LookBack = 100;
	PlotBars = -250;
   PlotWidth = 1600;
	PlotHeight1 = 600;
	ColorWin = ColorLoss = 0; 

	WFOPeriod = 252*24; // 1 year
	DataSplit = 90;
	NumCores = -1;  // use all CPU cores but one

	set(RULES);
	Spread = RollLong = RollShort = Commission = Slippage = 0;
	LifeTime = 3;
	if(Train) Hedge = 2;

	vars PriceMed = series((priceHigh()+priceLow())/2);   
   ZigZag(PriceMed, 37*PIP, 16, 0); 	
	var advise = adviseLong(NEURAL+BALANCED, rSign,
		change(1),change(2),change(3),change(4),
		range(1),range(2),range(3),range(4));
	int trend = ifelse(advise>0.5, 1, 0);
	if(trend != prevTrend) {
		prevTrend = trend;
		var prevPrice = (priceClose(0)+priceOpen(0))/2;
		if(!Train) {
			printf("\n%04d%02d%02d %02d:%02d: %.4f", year(), month(), day(), hour(), minute(), prevPrice);
			plotGraph("Pr.ZZ", 0, prevPrice, LINE, RED);
		}
	} 
	
	
	/*
	if(advise > 0) 
		enterShort();
	if(advise < 0) 
	   enterLong();
	*/
	   
  

}



What I want to achieve is to predict the value of ZigZag and plot in the chart a line between each point where the predicted value of ZigZag changes.
What I get with the code above is the following:

[img]
https://postimg.org/image/3o86kblqr/
[/img]

If you notice, the X axis is not correct. The price and the LINE have different axis. If I remove "PlotBars = -250;" then it works. But I want to see the chart better in a smaller time period.
Could you please tell me how to change this script in the way it works?
Thanks.
Cheers.

Re: adviseLong/Short, WFO and multiple assets [Re: gtell] #462034
09/05/16 15:08
09/05/16 15:08
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Apparently the plotGraph elements are not clipped by PlotBars. I'll put this on the fix list - until then, limit the chart with StartDate instead of PlotBars.

Re: adviseLong/Short, WFO and multiple assets [Re: jcl] #462261
09/17/16 16:04
09/17/16 16:04
Joined: Jul 2016
Posts: 64
G
gtell Offline OP
Junior Member
gtell  Offline OP
Junior Member
G

Joined: Jul 2016
Posts: 64
Dear JCL,

the followig description in the manual:

Quote:

INITRUN
Initial run of the simulation before the price data is loaded and before the log file is opened. Can be used to initialize global and static variables. System variables that are not yet known - f.i. variables that depend on the asset and simulation period - are at 0 during the initial run.
FIRSTRUN
First run of the simulation with valid price data and system variables. Normally follows the INITRUN.
FIRSTINITRUN
First initial run of the script, in the case of multiple simulation runs due to training or Cycles. While INITRUN and FIRSTRUN is set at the start of any simulation run, FIRSTINITRUN is only set at the really first run.
EXITRUN
Last run of the simulation. All trades are closed. Can be used to calculate results, aside from the evaluate or objective functions.


are them valid for WFA? When you mention Cycles, are your talking about Optimization or WFA as well?
Thanks.
Cheers

Re: adviseLong/Short, WFO and multiple assets [Re: gtell] #462287
09/19/16 09:46
09/19/16 09:46
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
For WFA, INITRUN and FIRSTINITRUN are the same. They are only different in training and when NumTotalCycles is used.

Page 2 of 2 1 2

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1