Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (RealSerious3D, AndrewAMD, chsmac85, dr_panther, TedMar), 942 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Trading Concepts Scripts [Re: TankWolf] #409136
10/12/12 06:58
10/12/12 06:58
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
You can find the start and end of a week with the dow() function.

On daily bars, monday: dow(0) == 1, and friday: dow(0) == 5.

On hourly bars, monday morning: dow(0) == 1 and hour(0) == 0

Friday evening: dow(0) == 5 and hour(0) == 22

Re: Trading Concepts Scripts [Re: TankWolf] #409153
10/12/12 13:47
10/12/12 13:47
Joined: Oct 2012
Posts: 13
CO
G
gfx Offline
Newbie
gfx  Offline
Newbie
G

Joined: Oct 2012
Posts: 13
CO
Originally Posted By: TankWolf
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?

TankWolf, did you see the example I posted? I prefer my method because it's more robust.

* By testing for dow(0) < dow(1), it works even if there are missing days at the start of the week. Or if one broker has Sunday-Friday bars and another has Monday-Saturday bars. (That may not be a problem with Zorro but it is with MT4.)

* Recording the "high and low so far" like I did doesn't rely on there being a specific number of bars per day, or per week. I don't know about Zorro but many platforms can have gaps if your data feed dropped out.

Re: Trading Concepts Scripts [Re: TankWolf] #413013
12/06/12 10:55
12/06/12 10:55
Joined: Sep 2012
Posts: 99
T
TankWolf Offline
Junior Member
TankWolf  Offline
Junior Member
T

Joined: Sep 2012
Posts: 99
Okies I have a question.

Say Im using a 60 minute bar period and I want to get the daily open and close of a full daily candle how exactly do I achieve this so it mirrors the open and close of the daily bars on FXCM.

Quote:

BarPeriod = 60;
static var DailyOpen = 0, DailyClose = 0;
if(day(0) != day(1)) { // midnight has passed.
DailyOpen = priceOpen(24); //Get open from 24 bars ago?
DailyClose = priceClose(0); //Get close from last bar?
}


Though it doesn't seem to work right, also Sunday is a puzzle to me. Say if I want the first daily candle of the week to be from the Sunday open candle on FXCM to the close of the Monday candle (because technically that is the first full day of the week) how is that done...

Thanks for any feedback.

Re: Trading Concepts Scripts [Re: TankWolf] #413064
12/07/12 11:44
12/07/12 11:44
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Your code is theoretically correct, although better use priceClose(1); to get yesterday's close price.

The problem is that the number of bars is not always equal to the number of hours. There are no bars at the weekend, on holidays, or when the market is closed. For this reason, better use

DailyOpen = priceOpen(timeOffset(UTC,1,0,0));
DailyClose = priceClose(timeOffset(UTC,1,23,59));

Have a look at the source code of the dayOpen / dayClose functions in the indicators.c file for getting the idea.

Re: Trading Concepts Scripts [Re: jcl] #413157
12/09/12 10:32
12/09/12 10:32
Joined: Sep 2012
Posts: 99
T
TankWolf Offline
Junior Member
TankWolf  Offline
Junior Member
T

Joined: Sep 2012
Posts: 99
Thanks for the help I can now get it to work perfectly except for one problem, I can not get Fridays open & close to work no matter what I try...

Quote:

static var DailyOpen = 0, DailyClose = 0;
if(dow(0) > 1 && dow(0) <= 5 && day(0) != day(1)) { // midnight has passed.
DailyOpen = priceOpen(timeOffset(UTC,1,0,0));
DailyClose = priceClose(timeOffset(UTC,1,23,59));
printf("\nDayOpen: %.5f",DailyOpen);
printf("\nDayClose: %.5f",DailyClose);
}
else if(dow(0) == 5 && hour(0) == 0) {
DailyOpen = priceOpen(0);
printf("\nDayOpen: %.5f",DailyOpen);
}
else if(dow(0) == 7 && hour(0) == 23 && minute(0) == 59) {
DailyClose = priceClose(0);
printf("\nDayClose: %.5f",DailyClose);
}


If I just use the original if statement then I get everydays open and close price except Friday like I said above. Now I know because Ive used less than or equal to Friday(5) its not going to work but I was using 6 for Sat too and that didnt seem to make any difference. So I wrote the else if statements to try and get the Friday open and Sunday close a different way. In theory that code to me should work but I can not get data for Friday still... Posting the code for others and if you could help with the Friday problem jcl would be appreciated.

Edit: Using <= 7(Sunday) gives you supposed values for Friday but they are incorrect and dont marry up exactly like the rest of the days just an observation I made.

Last edited by TankWolf; 12/09/12 10:39.
Re: Trading Concepts Scripts [Re: TankWolf] #413192
12/09/12 23:18
12/09/12 23:18
Joined: Sep 2012
Posts: 99
T
TankWolf Offline
Junior Member
TankWolf  Offline
Junior Member
T

Joined: Sep 2012
Posts: 99
All good I figured it out heres the code for others:

Quote:

function run() {
set(TESTNOW);
BarPeriod = 60;

static var DailyOpen = 0, DailyClose = 0;
if(dow(0) > 1 && dow(0) <= 5 && day(0) != day(1)) { // midnight has passed.
DailyOpen = priceOpen(timeOffset(UTC,1,0,0));
DailyClose = priceClose(timeOffset(UTC,1,23,59));
printf("\nDayOpen: %.5f",DailyOpen);
printf("\nDayClose: %.5f",DailyClose);
}
else if(dow(0) == 5 && hour(0) == 1) {
DailyOpen = priceOpen(0);
printf("\nDayOpen: %.5f",DailyOpen);
}
else if(dow(0) == 1 && hour(0) == 0) {
DailyClose = priceClose(0);
printf("\nDayClose: %.5f",DailyClose);
}

Re: Trading Concepts Scripts [Re: TankWolf] #413880
12/19/12 11:08
12/19/12 11:08
Joined: Sep 2012
Posts: 99
T
TankWolf Offline
Junior Member
TankWolf  Offline
Junior Member
T

Joined: Sep 2012
Posts: 99
I actually made a slight error in the above code didnt realise it till yesterday but I couldnt edit my last post so here is the correct version:

Quote:

function run() {
BarPeriod = 60;

if(dow(0) > 1 && dow(0) <= 5 && day(0) != day(1)) {
SkillLong[0] = priceOpen(timeOffset(UTC,1,0,0)); // Get Price From Yesterdays Open After Midnight For Monday-Thursday.
SkillLong[1] = priceClose(timeOffset(UTC,1,23,59)); // Get Price From Yesterdays Close Before Midnight For Monday-Thursday.
printf("\nDayOpen: %.5f",SkillLong[0]);
printf("\nDayClose: %.5f",SkillLong[1]);
}
else if(dow(0) == 1 && hour(0) == 0 && day(0) != day(1)) {
SkillLong[0] = priceOpen(23); // Get Price From Fridays Open After Midnight For Friday.
SkillLong[1] = priceClose(0); // Get Price For Fridays Close On Midnight Of Sunday.
printf("\nFDayOpen: %.5f",SkillLong[0]);
printf("\nFDayClose: %.5f",SkillLong[1]);
}
}

Re: Trading Concepts Scripts [Re: TankWolf] #414986
01/12/13 11:30
01/12/13 11:30
Joined: Jan 2013
Posts: 1
R
richieru Offline
Guest
richieru  Offline
Guest
R

Joined: Jan 2013
Posts: 1
Hi,
Is there a way to call tick volume for an indicator? Cheers.

Re: Trading Concepts Scripts [Re: richieru] #414989
01/12/13 12:35
01/12/13 12:35
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Sure, you can use the tick counter accessible through g->asset->nCounter. It is set to 1 at the first tick of every bar and then counts the ticks in trade mode.

However, the tick volume, unlike the trade volume, is very broker specific and has no predictive value for indicators. That's why we have not put it in an easy-to-use variable.

Page 2 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