Not all scripts we’re hired to write are trading strategies. Some are for data analysis or event prediction – for instance: Write me a script that calculates the likeliness of a stock market crash tomorrow. Some time ago a client ordered a script for improving the performance of their company. This remarkable script was very different to a trading system. Its algorithm can in fact improve companies, but also your personal performance. How does this work?
Just like the performance of a stock, the performance of a company is measured by numerical indicators. They are named key figures. Key figures play a major role in quality management, such as the ISO 9000 standards. An ISO 9000 key figure is a detail indicator, such as the number of faults in a production line, the number of bugs found in a beta test, the number of new clients acquired per day, the total of positive minus negative online reviews, an so on. Aside from being essential for an ISO 9000 certification, these key figures have two purposes:
- They give detailed insight and expose strengths and weaknesses.
- And they give a strong motivation for reaching a certain goal.
The script below opens a user interface for entering various sorts of key figures. It calculates an overall score that reflects the current performance of a company – or of a person – and displays it in a chart. If you use it not for a company, but for yourself, it helps improving your personal life. And from the short script you can see how to create a relatively complex software with relatively few lines of code.
Hackers like the concept of key figures. They are plain numbers that you can work with. Anyone can define key figures for herself. If you’re a writer, an important key figure is the number of words you’ve written today; if you’re an alcolohic, it’s the number of drinks you had today. Many self-improvement books tell you precisely what you need to do for living a healthier, wealthier, happier life – but they all suffer from the same problem: long-term motivation. If you lack the iron will to keep your daily exercises, reduce smoking, stay away from fast food, and so on – all good resolutions will eventually fall into oblivion. If you had resolutions for 2025, you’ll soon know what I mean.
Failure is less likely when you can observe your progress any day and see its immediately effect on your overall performance score. This score is a direct measure of your success in live. Whether you’re a company or a person, you want to keep this core rising. This feedback produces a strong motivation, every day again.
The above performance chart is plotted by the key figure management script in C for the Zorro platform. The red line is the overall score, derived from all key figures in a way explained below. The blue line is the key figure for which you just entered a new value (in the example it’s the number of large or small features implemented in the last 6 months in the Zorro platform). The X axis is the date in YYMMDD format.
Of course, key figures can be very different. Some may have a daily goal, some not, some shall sum up over time, others (like your bank account value) are just taken as they are. The idea is that your overall score rises when you exceed the daily goals, and goes down otherwise. All key figures and their parameters can be freely defined in a CSV file, which can be edited with a text editor or with Excel. It looks like this:
Name, Decimals, Unit, Offset, Growth, Sum
Appr,1,0.1,0,0,0
Praise,0,10,0,-30,1
Weight,1,-0.1,-250,0.033,0
Duck,1,0.5,0,-0.5,1
Worth,0,1,-6000,0,0
In the first column you can assign a name. The second column is the number of decimals in the display, the third is their unit in the overall score, the fourth is an offset in the score, the fifth is the daily goal, and the last tells if the figures shall sum up over time (1) or not (0).
Example. Suppose you’re a president of a large country and want to pimp up your personal performance. What’s your key figures? First, of course, approval rate. Any tenth percent adds one point to your score. So the first entry is simple:
Name, Decimals, Unit, Offset, Growth, Sum
Appr, 1, 0.1, 0, 0, 0
Next, fame. Key figure is the daily number of praises on Fox News, OneAmerica, and Newsmax. You’ve ordered a White House department to count the praises; of course you’re personally counting them too, just in case. Less than 30 praises per day would be bad and reduce your score, more will improve it. So 30 praises are daily subtracted from your score. Any 10 further praises add one point. This is an accumulative key figure:
Praise, 0, 10, 0, -30, 1
Next, health. Key figure is weight. Your enemies spread rumors that you’re unfit and obese. Your doctors urge you to shed weight. So you want to lose one pound every month, which (you have your mathematicians for calculating difficult things) is about 0.033 per day. Any lost 0.1 pound adds one point to your score. The numbers are negative since you want your weight to go down, not up. The offset is your current weight.
Weight, 1, -0.1, -250, 0.033, 0
Next, literacy. Your enemies spread rumors you’re illiterate. To prove them wrong, you’ve decided to read at least half a page per day in a real book (you’ve chosen Duck for President to begin with). Any further half page adds one point to your score. This is also an accumulative figure.
Duck, 1, 0.5, 0, -0.5, 1
Finally, net worth. You’ve meanwhile learned to better avoid business attempts. Let your net worth grow due to the value increase of your inherited real estate, which is currently at 6 billion. Any million further growth adds one point to your score (numbers given in millions):
Worth, 0, 1, -6000, 0, 0
For improving your personal performance, download the script from the 2025 repository. Copy the files KeyFigures.csv and KeyFigures.c in your Strategy folder. Edit KeyFigures.csv for entering your personal key figures, as in the above example (you can later add or remove key figures and use Excel to add or remove the new columns to the data file). This is the script:
// Pimp Your Performance with Key Figures ////////////////////// string Rules = "Strategy\\KeyFigures.csv"; string Data = "Data\\KeyData.csv"; // key figures history string Format = "0%d.%m.%Y,f1,f,f,f,f,f,f,f,f,f,f,f,f,f,f"; int Records,Fields; var value(int Record,int Field,int Raw) { var Units = dataVar(1,Field,2); var Offset = dataVar(1,Field,3); var Growth = dataVar(1,Field,4); var Value = 0; int i; for(i=0; i<=Record; i++) { if(dataVar(2,i,Field+1) < 0.) continue; // ignore negative entries Value += Growth; if(i == Record || (dataInt(1,Field,5)&1)) // Sum up? Value += dataVar(2,i,Field+1)+Offset; } if(Raw) return Value-Offset; else return Value/Units; } var score(int Record) { int i,Score = 0; for(i=0; i<Fields; i++) Score += value(Record,i,0); panelSet(Record+1,Fields+1,sftoa(Score,0),YELLOW,16,4); return Score; } void click(int Row,int Col) { dataSet(2,Row-1,Col,atof(panelGet(Row,Col))); score(Row-1); if(dataSaveCSV(2,Format,Data)) sound("Click.wav"); int i; for(i=0; i<Records; i++) { var X = ymd(dataVar(2,i,0)) - 20000000; plotBar("Score",i,X,score(i),LINE,RED); plotBar(dataStr(1,Col-1,0),i,NIL,value(i,Col-1,1),AXIS2,BLUE); } if(Records >= 2) plotChart(""); } void main() { int i = 0, j = 0; printf("Today is %s",strdate("%A, %d.%m.%Y",NOW)); ignore(62); PlotLabels = 5; // File 1: Rules Fields = dataParse(1,"ssss,f1,f,f,f,i",Rules); // File 2: Content Records = dataParse(2,Format,Data); int LastDate = dataVar(2,Records-1,0); int Today = wdate(NOW); if(LastDate < Today) { // no file or add new line dataAppendRow(2,16); for(i=1; i<=Fields; i++) if(!(dataInt(1,i-1,5)&1)) dataSet(2,Records,i,dataVar(2,Records-1,i)); Records++; } dataSet(2,Records-1,0,(var)Today); // display in panel panel(Records+1,Fields+2,GREY,-58); panelFix(1,0); print(TO_PANEL,"Key Figures"); for(i=0; i<Fields; i++) panelSet(0,i+1,dataStr(1,i,0),ColorPanel[0],16,1); panelSet(0,i+1,"Score",ColorPanel[0],16,1); panelSet(0,0,"Date",ColorPanel[0],16,1); for(j=0; j<Records; j++) { panelSet(j+1,0,strdate("%d.%m.%y",dataVar(2,j,0)),ColorPanel[0],0,1); score(j); for(i=0; i<Fields; i++) panelSet(j+1,i+1,sftoa(dataVar(2,j,i+1),-dataVar(1,i,1)),ColorPanel[2],0,2); } panelSet(-1,0,"Rules",0,0,0); }
The file locations and the CSV format of the key figures history are defined at the begin. The value function calculates the contribution of a particular key figure to the overall score. The score function updates the overall score. The click function, which is called when you enter a new value, calculates the score of that day, updates the spreadsheet, and prints the chart. The main function imports the data and key figures from their CSV files into datasets, prints the current day and displays a spreadsheet of your key figures and score history, like this:
You will need Zorro S because the spreadsheet function is not available in the free version. Start the script any morning. It will open the spreadsheet, where you can click in any of the white fields and enter a new key figure value for today. You can anytime enter new figures for today or for past days. At any entry, the score is calculated and – if the history spans more than 2 days – a chart is plotted as in the above example.
Normally, personal performance depends on about 5-10 key figures (maximum is 15). For instance, miles you’ve jogged today, steps walked, exercises done, pages read, words written, words learned in a new language, value of your bank account, value of your stock portfolio, burgers eaten, cigarettes smoked, enemies killed, or number of old ladies you helped crossing the street. If you’re a president, consider the script a free present (we hope for generous tax exceptions in exchange). If you’re an ISO 9000 certified company and want to use the script for your quality management, please contact oP group to pay your fee. For personal use, the script is free. Pimp your performance and make the world a better place!
I believe I know that president.
I like your humor 🙂