Strategy Script Introduction

A script describes the trade rules in a sort of simplified language, called lite-C (a "light" variant of the C programming language). Theoretically, there could be other ways to define a strategy, for instance by setting up a list of indicator filters and thresholds, or by entering formulas in a spreadsheet program. However, those methods would severely limit any strategy to mostly predefined rules and indicators. It is very difficult, if not impossible to define a profitable strategy for today's markets this way. All known successful automated strategies are script based.

The disadvantage of a script is obviously that you have to learn the script language. Most products using strategy scripts require that you dive deeply into programming. No so with Zorro: lite-C is arguably the world's easiest serious programming language. It 'hides' almost all the programming stuff and allows you to concentrate on plain strategy. You can learn the lite-C essentials in about one day.

A simple strategy script in lite-C looks as shown below. This strategy uses two simple moving averages (SMA) with 30 and 100 bars time period, places a stop at 10 pip distance, and buys a long or short position when the faster average crosses over or under the slower average:

function run()
  vars Close = series(priceClose());
  vars SMA100 = series(SMA(Close,100));
  vars SMA30 = series(SMA(Close,30));
  Stop = 10*PIP;

  else if(crossUnder(SMA30,SMA100))

This is a primitive (and not really profitable) trend following strategy. A similar, but more profitable strategy can be found in lesson 4 of the Automated Trading Course. The course is highly recommended for learning lite-C, no matter if you have never programmed before or have already some programming knowledge.

For writing your own systems, it can save you a lot of time when you read this manual fully. Zorro has many script functions that you do not need to program yourself. Often-used code snippets for your own scripts and strategies can be found on the tips & tricks page. If you worked with a different trade platform before, read the conversion page about how to convert your old scripts or EAs to lite-C.

See also:

Strategy Script Course, scripts, tips & tricks, conversion


► latest version online