The Cold Blood Index

Posted By: boatman

The Cold Blood Index - 10/29/15 09:32

I'm having a go at implementing jcl's Cold Blood Index from his Financial Hacker website. Its all pretty clear, other than storing the balance curve as a double array in a file to be called in the Cold Blood Index Script. Here is what I've tried:

Code:
//globals
var Daily;
int Day = 0;
...
//in the run function
// store daily results in an equity curve
string FileName = "Log\\SpreadCombosDaily1.txt";
static int LastDay = 0;
if(is(LOOKBACK))
  LastDay = Day = 0;
else if(LastDay != day()) {
  Daily = Equity;
  LastDay = day();
  file_append(FileName, &Daily);
}	

printf("\nDaily:%10.5f\n", Daily);

...



When I run this script, the file to store the balance curve is created, but nothing is written to it. I'm also unable to open it until I close the instance of Zorro that I used to create it.

The print function indicates that the correct values are being evaluated, so I think I have isolated my problem to the file_append function.

What am I doing wrong? What's the best way to write this data to a file to be called in a different script?
Posted By: jcl

Re: The Cold Blood Index - 10/29/15 15:30

The size is missing:
file_append(FileName, &Daily, sizeof(var));

If there is no size, file_append assumes that a string is appended, and if the string is empty, nothing is appended.
Posted By: boatman

Re: The Cold Blood Index - 10/29/15 21:49

Head slap! Of course the size needs to be specified. Thanks for pointing that out.

The size argument to the file_append function doesn't appear in the manual - can it be added please?
Posted By: pcz

Re: The Cold Blood Index - 02/23/17 13:39

Just a quick question, hope it's not too stupid:

The variables TradeDays, DrawDownDays and CurveLength contain number of days. Is it (in general) number of calendar days, number of business (i.e. trading) days or number of days when there's a change in equity?
© 2024 lite-C Forums