0 registered members (),
1,119
guests, and 0
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
price() clarification
#434441
12/18/13 15:38
12/18/13 15:38
|
Joined: May 2013
Posts: 245
swingtraderkk
OP
Member
|
OP
Member
Joined: May 2013
Posts: 245
|
price() Returns the mean price of a bar, i.e. the average of all ticks the currently selected asset that fall into the bar period. This is normally the preferred price for indicators because it is less susceptible to random fluctuations and makes systems more robust and independent on the data feed. In back testing: 1) on 1 min bars does price() return (high+low+open+close)/4 ? 2) on higher BarPeriods does it average each tick (i.e. each 1 min high low open close) or average a stored mean value of 1 min prices? 3) if it averages stored mean values, does it always use all available 1 min values or does it average say 30 min mean prices when calculating a 60 min mean price? 4) How does it handle higher Barperiods that may span many minutes where there are no 1 min data points at all, e.g. at weekends, or times of low activity where no ticks are received during a 1 min period and there is no HLOC? 5) Does use of TimeFrame change any of the answers above, or does price() return exactly the same values when using Timeframe as the equivalent Barperiod? i.e. does barperiod 60; price() return exactly the same values as barperiod 5; timeframe 12; price()? In live trading, I assume this is much simpler in that zorro runs this averaging for each actual tick received with a timestamp that falls inside the Barperiod / Timeframe in question. i.e. sum of prices of all ticks/no. ticks received
|
|
|
Re: price() clarification
[Re: jcl]
#435109
01/03/14 00:38
01/03/14 00:38
|
Joined: Aug 2013
Posts: 22
pipclown
Newbie
|
Newbie
Joined: Aug 2013
Posts: 22
|
I'll borrow this thread as well for some other questions regarding priceXXX() When backtesting on 1-minute data, I observe some strange behavior where priceOpen() almost always equals priceHigh(). Same for priceClose() == priceLow(). However, when you look at the structs stored in the .bar history file you can clearly see much more different values for open, high, low and close. Its as if priceOpen() and priceHigh() are identical for BarPeriod = 1 when backtesting. Try this script:
int numBars = 0;
int numOpenHighNonMatching = 0;
int numCloseLowNonMatching = 0;
function run() {
StartDate = 20070101;
EndDate = 20070630;
LookBack = 0;
BarPeriod = 1;
asset("EUR/USD");
if (is(INITRUN)) {
numBars = 0;
numOpenHighNonMatching = 0;
numCloseLowNonMatching = 0;
}
numBars++;
if (priceOpen() != priceHigh()) {
numOpenHighNonMatching++;
}
if (priceClose() != priceLow()) {
numCloseLowNonMatching++;
}
if (is(EXITRUN)) {
printf("\nNum bars received: %d\n", numBars - 1);
printf("\nTotal non-matching: %d", numOpenHighNonMatching + numCloseLowNonMatching);
}
}
For me that script outputs,
BackTest: bar_export EUR/USD 2007
Num bars received: 151067
Total non-matching: 43
Looking at the raw .bar files, I would expect non-matching to be much higher, even for BarPeriod = 1. Naturally, turning up BarPeriod to say 60 or higher shows more normal and different values. Do Zorro handle prices at BarPeriod = 1 differently compared to higher periods? I also noticed that bars at the beginning of the year (those last in .bar file) are sometimes skipped for some reason? Maybe I've just misunderstood something, but I've been scratching my head over this one for over 2 hours Thanks!
Last edited by pipclown; 01/03/14 00:38.
|
|
|
Re: price() clarification
[Re: jcl]
#435129
01/03/14 10:13
01/03/14 10:13
|
acidburn
Unregistered
|
acidburn
Unregistered
|
Good detective work pipclown!
May I suggest that this gets investigated deeper, jcl, because this looks like a serious problem to me.
Also I'm now completely confused with all this ticks/bars terminology. So far I thought that Zorro's history files contained only 1 minute OHLC bars. If that's right, then the above script reveals that something is really not OK with the history data.
And I also thought that using the word 'tick' in Zorro is just play of words. The real tick in forex represents a price change. So every time bid and/or ask changes and there is a transaction, the tick records new (bid, ask) values plus the exact time when it happened. That translates to tens of ticks for every 1 min bar nowadays. I just don't see how all those ticks compressed could translate to most of the 1min bars with no wicks (as demonstrated by pipclown).
I might be wrong, and I'll soon run the tests to prove or disprove my theory, but something's very fishy here...
|
|
|
Re: price() clarification
[Re: ]
#435130
01/03/14 10:22
01/03/14 10:22
|
acidburn
Unregistered
|
acidburn
Unregistered
|
OK, to add to my previous post, the only possible reason that most of those 1min bars could have been wickless is because it was 2007. and the market was moving much slower then. Pending further analysis...
|
|
|
|