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.