Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 1,382 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Keeping it simple #409476
10/18/12 05:03
10/18/12 05:03
Joined: Oct 2012
Posts: 75
H
hughbriss Offline OP
Junior Member
hughbriss  Offline OP
Junior Member
H

Joined: Oct 2012
Posts: 75
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.

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

Code:
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

Re: Keeping it simple [Re: hughbriss] #409478
10/18/12 06:53
10/18/12 06:53
Joined: Sep 2012
Posts: 99
T
TankWolf Offline
Junior Member
TankWolf  Offline
Junior Member
T

Joined: Sep 2012
Posts: 99
Im really enjoying Zorro also. I went to university for a few years and was doing software engineering writing mostly in Java but I never finished and this is the first coding Ive done since then really. What I love is that the program and language is super easy to understand and learn because of all the inbuilt functions already.

In regards to your second question Ive yet to really program any super profittable strategies on my own yet, Ive mostly played around with scripts that were posted like the7 and Hucks Trend Catching System but I have been playing a round with a few of my own ideas without much luck mostly with lower time frame strategies. Personally Im finding that making stategies that preform well with walk forward optimizations seem to do best on the daily timeframe with moving averages whether they be an EMA/SMA or LowPass, quite a few variations of the7 and Hucks system Ive got to return over 200% annually but what Id really like to design are some 1 and 5 minute scalping strategies that hopefully can get over a 1000% return annually. Thats my goal anyway. tongue

Re: Keeping it simple [Re: TankWolf] #409485
10/18/12 08:43
10/18/12 08:43
Joined: Oct 2012
Posts: 75
H
hughbriss Offline OP
Junior Member
hughbriss  Offline OP
Junior Member
H

Joined: Oct 2012
Posts: 75
Yes, I think that the lanuguage is relatively easy to understand. It will take me some time to get up to speed but I will get there.

Have you actually run any systems live to test how robust the program is?

In my experience as a manual trader I find that trend following systems on daily charts works best but in theory it must be possible to create an automated system on lower timeframes that does make substantial money. Whether that will be easy to find in practise or not I don't know. I suppose all you can do is test and optimise.

Here's an idea for you but I don't know if it would be easy to code...

Every day at 8am gmt for London open and 1pm gmt for NY open you take the closing price of the previous 5 min candle. I have used '25 levels' before as s/r. The round number levels at each 25 pips often act as s/r.

If the price is halfway between two 25 levels then you wait for a 5 min candle to close either above the upper 25 level or below the lower 25 level. Your target is 20 pips, right by the next 25 level. Your stop is 15 pips.

If the price is within 10 pips of a 25 level on the close then you use the nearest 2 25 levels for your entries. One entry per session. If you get a good push you will hit your target no problem.

I can see all sorts of problems with this including daylight saving times and broker server times. I've looked through manually and it seems it might be profitable.

Just an idea.

Re: Keeping it simple [Re: hughbriss] #409486
10/18/12 08:50
10/18/12 08:50
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Zorro takes care of daylight saving in the years 2000-2019. You can use the timeOffset function for checking whether the current bar contains 8am GMT.

http://zorro-trader.com/manual/en/month.htm

By the way, your code above is already pretty short, but can be made a little shorter when you substitute

ClosePrice[0] instead of curr
Closeprice[1] instead of prev

You can refer to the elements of a series with [0], [1], [2], .. suffixes.

Re: Keeping it simple [Re: jcl] #409489
10/18/12 09:30
10/18/12 09:30
Joined: Oct 2012
Posts: 75
H
hughbriss Offline OP
Junior Member
hughbriss  Offline OP
Junior Member
H

Joined: Oct 2012
Posts: 75
Great. I'll look into the time thing when I get a bit more advanced.

I see what you mean about the code. I don't need to specify the closeprice as variables and then print them I can just put them straight into the printf expressions. Thanks.

By the way, that is the sort of code I needed as a starter. It works with actual prices and does something to them but is not so advanced that it's hard to understand for a new coder. I'm enjoying myself anyway so that's a start.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1