Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, degenerate_762, ozgur), 1,311 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Trading Concepts Scripts #408918
10/09/12 12:07
10/09/12 12:07
Joined: Oct 2012
Posts: 4
Cape Town, South Africa
P
PiptheRipper Offline OP
Guest
PiptheRipper  Offline OP
Guest
P

Joined: Oct 2012
Posts: 4
Cape Town, South Africa
First of all, I just want say, Zorro is a great program and thank you for all the effort in the development of it.

The idea of this thread is to hopefully help out traders that is new to writing strategy scripts, like myself to successfully code trading concepts and in the process learn new techniques.

The Zorro manual with the tutorials contains lots of great information, but can be hard to understand for people that is new to this.

I hope the more experienced coders can give a hand and help out the new guys.

Peace.
PiptheRipper

Re: Trading Concepts Scripts [Re: PiptheRipper] #408922
10/09/12 12:24
10/09/12 12:24
Joined: Oct 2012
Posts: 4
Cape Town, South Africa
P
PiptheRipper Offline OP
Guest
PiptheRipper  Offline OP
Guest
P

Joined: Oct 2012
Posts: 4
Cape Town, South Africa
I've been writing basic scripts in Zorro for about a week now, but can't manage to do the following:

Creating a var for the previous week High & Low.
I tried using the HH and LL indicators, but I get an error related to them if I test the script. I hope that someone can post an example script in order to return the previous week high and low, whether using the HH&LL indicator or not.

Creating a var for the previous Day High & Low in a smaller than Daily time frame.
When using a BarPeriod = 1440. I can get yesterdays high and low by writing the following:

var daily_high = priceHigh(1);
var daily_low = priceLow(1);

but if I use a smaller BarPeriod, how is it done?

Once again, I tried using the HH & LL indicator but with no luck.
I've managed to get partial success with using the dayHigh and dayLow function, but the Sunday bar causes Monday to return a value of zero.

Any suggestions would be appreciated.

Thank you.
PiptheRipper

Re: Trading Concepts Scripts [Re: PiptheRipper] #408932
10/09/12 14:02
10/09/12 14:02
Joined: Sep 2012
Posts: 99
T
TankWolf Offline
Junior Member
TankWolf  Offline
Junior Member
T

Joined: Sep 2012
Posts: 99
Hi PipRipper,

I dont think I can help with the first one as Im rather still a newbie myself but in regards to your second question I think it might be done like this:

Quote:

BarPeriod = 60; //60 minute bar period.
TimeFrame = 24; // 24 * 60 minute bars.
var *High = series(priceHigh()); //Creates a series of 24 hour highs.
var *Low = series(priceLow()); //Creates a series of 24 hour lows.
var daily_high = High[1]; //Stores the priceHigh() array from 1 day ago in the variable daily_high.
var daily_low = Low[1]; //Stores the priceLow() array from 1 day ago in the variable daily_low.


I havnt tested this and like I say Im only learning but its a suggestion.

Actually thought about your first question again and if my first code works then this should too.

Quote:

BarPeriod = 1440; //1 day bar periods.
TimeFrame = 5; //5 * 1440 bar periods.
var *High = series(priceHigh()); //Creates a series of 5 day highs.
var *Low = series(priceLow()); //Creates a series of 5 day lows.
var weekly_high = High[1]; //Stores the priceHigh() array from 1 week ago in the variable daily_high.
var weekly_low = Low[1]; //Stores the priceLow() array from 1 week ago in the variable daily_low.



Last edited by TankWolf; 10/09/12 14:16. Reason: Added Code
Re: Trading Concepts Scripts [Re: TankWolf] #408941
10/09/12 14:51
10/09/12 14:51
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
For the daily high/low on intraday bars, you can use the day() functions for calculating them when the day is over:

Code:
BarPeriod = 60; // one-hour-bars
static var DailyHigh = 0, DailyLow = 0;
if(day(0) != day(1)) { // midnight -> day has changed
  DailyHigh = HH(24);
  DailyLow = LL(24);
}



Note the "static". This keeps the high and low between runs. Otherwise they would be set to 0 again at every run.

Re: Trading Concepts Scripts [Re: jcl] #408959
10/09/12 20:18
10/09/12 20:18
Joined: Oct 2012
Posts: 4
Cape Town, South Africa
P
PiptheRipper Offline OP
Guest
PiptheRipper  Offline OP
Guest
P

Joined: Oct 2012
Posts: 4
Cape Town, South Africa
Thank you jcl! I appreciate the help and it works just like I wanted it to.
About the weekly high/low. I can't seem to get that to work. I can get monthly high/lows without a problem, by just changing "day" to "month" in you above script, but changing it to "week" returns a zero value.

@TankWolf

Thank you for your contribution. Your code seems to return the daily low and high, but it's delayed by half a day. It doesn't update at midnight. Nway I'll be using the way jcl suggested, but thanx again and plz keep contributing.

Re: Trading Concepts Scripts [Re: PiptheRipper] #408971
10/09/12 21:50
10/09/12 21:50
Joined: Oct 2012
Posts: 13
CO
G
gfx Offline
Newbie
gfx  Offline
Newbie
G

Joined: Oct 2012
Posts: 13
CO
I'm not set up to test this yet, but how about using

if (dow(0) < dow(1)) { // new week

The tricky bit is figuring out how many bars there are in a week. It varies on some brokers and some weeks, so instead of the HH(n) approach you might want to use something like:

Code:
var WeeklyHigh, WeeklyLow;
var WkHi = -99999, WkLo = 99999;
if (dow(0) < dow(1)) {  // new week
  WeeklyHigh = WkHi;
  WeeklyLow = WkLo;
  WkHi = -99999;
  WkLo = 99999;
}
WkHi = max(WkHi, priceHigh(0));
WkLo = min(WkLo, priceLow(0));


Re: Trading Concepts Scripts [Re: gfx] #408984
10/10/12 01:00
10/10/12 01:00
Joined: Sep 2012
Posts: 99
T
TankWolf Offline
Junior Member
TankWolf  Offline
Junior Member
T

Joined: Sep 2012
Posts: 99
Thanks jcl for clarifying that. I do have one question however, if we use the day(), HH() & LL() functions then I remember you saying somewhere you will not be able to preform oversampling on the script due to any strategy that uses certain opening and closing hours of the exchange.

So I guess what Im trying to get at when we use strategies that look at intraday high/lows will this method generally yeild better backtesting results than using the priceHigh() & priceLow() functions and then oversampling the script?

Re: Trading Concepts Scripts [Re: TankWolf] #409014
10/10/12 12:33
10/10/12 12:33
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
For intraday high/low values you can use oversampling without problems. For strategies however that depend on the behavior of markets at certain times or dates, oversampling won't work because it mixes up the bars. This is a different trade method and I can't say if it yields better or worse results than intraday trading. It depends on the strategy.

Re: Trading Concepts Scripts [Re: gfx] #409021
10/10/12 13:41
10/10/12 13:41
Joined: Oct 2012
Posts: 4
Cape Town, South Africa
P
PiptheRipper Offline OP
Guest
PiptheRipper  Offline OP
Guest
P

Joined: Oct 2012
Posts: 4
Cape Town, South Africa
TankWolf

I tried the script, but could not get it to work.

Thank you.

Re: Trading Concepts Scripts [Re: PiptheRipper] #409134
10/12/12 00:30
10/12/12 00:30
Joined: Sep 2012
Posts: 99
T
TankWolf Offline
Junior Member
TankWolf  Offline
Junior Member
T

Joined: Sep 2012
Posts: 99
Quote:
BarPeriod = 60; // one-hour-bars
static var WeeklyHigh = 0, WeeklyLow = 0;
if(day(0) != day(5)) { // midnight of day 5 -> week has ended?
WeeklyHigh = HH(120); //(24 hours *5 days)
WeeklyLow = LL(120); //(24 hours *5 days)
}


Because there is no week() function is this how we would find the weekly high & low?

Also say if we wanted to get the high and low of a bar during the current day say for example you wanted the high and low of the opening candle of London is this how we would do it?
Quote:

BarPeriod = 60; // One hour bars.
static var LondonOpenLow = 0, LondonOpenHigh = 0;
if(hour(1) == timeOffset(UTC,0,7,0)) //Check to see if last hour was LondonOpen.
LondonOpenLow = priceLow(1); //Get low from last bar?
LondonOpenHigh = priceHigh(1); //Get high from last bar?


OR
Quote:

BarPeriod = 60; // One hour bars.
static var LondonOpenLow = 0, LondonOpenHigh = 0;
if(hour(1) == timeOffset(UTC,0,7,0)) //Check to see if last hour was LondonOpen.
LondonOpenLow = LL(1); //Get LL from 1 bar ago?
LondonOpenHigh = HH(1); //Get HH from 1 bar ago?




Page 1 of 2 1 2

Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1