Hello all,
I have just recently started using Zorro and I am very impressed with it. I am starting more or less from scratch when it comes to coding. I used to be able to program in BASIC and I understand some mt4 coding. Programming for zorro actually seems fairly straightforward but it seems that everyone that writes tutorials has a hard time keeping it simple.
I run a private forum and asked a member to write a tutorial and he came up with the following code.
//these are global variables
var curr, prev;
//function declaration
function checkPrice(var* ,var);
//run function. main program entry point
//this function is invoked by Zorro every minute
function run(){
//EUR/USD 1 minute chart
asset("EUR/USD");
BarPeriod = 1;
TimeFrame = 1;
var* ClosePrice = series(priceClose());
//EMA(10)
var* Trend = series(EMA(ClosePrice,10));
//priceClose() is a builtin Zorro function
//curr variable stores the closing price.
curr = priceClose();
//printf is also builtin function
//this function "prints" the content of the parameter
//to the Zorro console.
printf ("#\nPrevious bar close price:%.5f",prev);
printf ("#\nCurrent bar close price:%.5f",curr);
//invoking the "checkPrice" function
//this is not builtin Zorro function
//its written by the user
//passing the 10EMA defined above as a paramet Trend
//and the current price in the "curr" variable
checkPrice(Trend,curr);
//the curr variable value is being stored in the
//prev variable
prev = curr;
}//end of run function
//user defined checkPrice function
//this fnction takes an "array" containing the 10EMA series which
//you passed from the "run" function above
//the second parameter, "prc", is the closing price also passed from
//"run" function above
// this function compares the close price with the 10EMA value and
//prints the outcome in the Zorro console
function checkPrice(var *trn, var prc){
printf("#\ntrn[0]=%.5f",trn[0]);
if ( prc > trn[0] )
printf("#\nPrice above EMA(10)");
else
printf("#\nPrice below EMA(10)");
}
which does the same as my version here
function run()
{
asset("EUR/USD");
BarPeriod = 1;
TimeFrame = 1;
var* ClosePrice = series(priceClose());
var prev = priceClose(1);
var curr = priceClose();
var* tenma = series(EMA(ClosePrice,10));
printf ("#\nPrevious bar close price:%.5f",prev);
printf ("#\nCurrent bar close price:%.5f",curr);
printf ("#\nTen ema value:%.5f",*tenma);
if (curr>*tenma)
printf("#\nPrice above EMA(10)");
else
printf("#\nPrice below EMA(10)");
}
This is a very basic script that just tells you whether the price on a 1 minute eurusd chart closed above or below the 10 ema.
I'm pleased that I was able to unpick the previous code and simplify it and he did say that he had made it more complicated than it needed to be in order to teach the C coding but am I the only one who prefers the second script?
I'm looking forward to getting up and running with zorro and fxcm. I'd like to hear from anyone who has been running zorro for a while and who can give me any information on profit/loss and what strategies work best, etc.
Edward