Price export

Posted By: gtell

Price export - 09/10/16 13:01

Dear JCL,

comsider the following two distinct strategies which has the objective to export prices to one CSV file:

Code:
function run() {
	
	BarPeriod = 1440;
	LookBack = 0;
	StartDate = 2008;
	EndDate = 2014;	
		
	vars Open = series(priceOpen());
	vars High = series(priceHigh());
	vars Low = series(priceLow());
	vars Close = series(priceClose());
			
				
	char line[200];
	sprintf(line,
		"%1.5f, %1.5f, %1.5f, %1.5f\n",   
		Open[0], High[0], Low[0], Close[0]);		
		
	if(is(INITRUN))
		file_delete("Data\\export_price2.csv");
	else
		file_append("Data\\export_price2.csv",line);
		
}



and

Code:
function run()
{

        BarPeriod = 1440;
	LookBack = 0;
	StartDate = 2008;
	EndDate = 2014;	

	set(RULES);   
	LifeTime = 1;
	Spread = RollLong = RollShort = Commission = Slippage = 0;
	
        vars Open = series(priceOpen());
	vars High = series(priceHigh());
	vars Low = series(priceLow());
	vars Close = series(priceClose());
	
        adviseLong(SIGNALS+BALANCED, Open[0], High[0], Low[0], Close[0]); 
}



apparently the second strategy produces one CSV where the Close prise is ALWAYS lower then the Open price. Which of course does not make sense.
The first startegy looks ok.
Do you see any error in the code above?
Thanks.
Cheers.
Posted By: gtell

Re: Price export - 09/11/16 10:03

I have tried also with:

Code:
adviseLong(SIGNALS+BALANCED, priceOpen(0), priceHigh(0), priceLow(0), priceClose(0));



same results.
Posted By: jack83

Re: Price export - 09/11/16 13:34

what is the difference between export bar and export codes if the .bar contains daily data. It seems export bar works without any issue but export giving wrong data in open and close price for last EOD date. i thinks its bug in code. please check below

export bar code result:
8/9/2016 0:00 579.19757 596.33832 579.19757 593.09955

9/9/2016 0:00 593.04968 593.54791 576.00861 578.5

export result:

9/8/2016 1:00 579.2 596.3 579.2 593.1
9/9/2016 1:00 579.2 596.3 579.2 593.1
Posted By: gtell

Re: Price export - 09/11/16 21:13

It might be a bug or something wrong in the code.
I would prefer if JCL could add his comments.
Thanks.
Posted By: jcl

Re: Price export - 09/12/16 06:30

Your first code is ok, but the second not. adviseLong is not for exporting prices. Also, BALANCE is wrong here and the objective parameter is missing.
© 2024 lite-C Forums