tracking intraday sequences (time stamps) on daily bars

Discussions about the testing and simulation of mechanical trading systems using historical data and other methods. Trading Blox Customers should post Trading Blox specific questions in the Customer Support forum.
Post Reply
ACM10022082
Contributor
Contributor
Posts: 3
Joined: Fri May 21, 2010 3:35 pm

tracking intraday sequences (time stamps) on daily bars

Post by ACM10022082 » Mon May 23, 2011 11:44 am

Hi Tim,

We have a system that works on daily bars issues same day target and stop loss orders after entered into a position, this has been coded in EntryOrderFilled logic. We identified system might get stopped out at end of day but in reality it will not be hitting Target or Stop Loss, this is happening due to lack of intraday sequences information. Please suggest:

a) Is there any possibility in trading blox to fix this issue using daily bars only ?
b) If (a) is not possible please give details of how to fix this issue using both data series of daily bars and intraday bars.


Thanks,
ACM

sluggo
Roundtable Knight
Roundtable Knight
Posts: 2986
Joined: Fri Jun 11, 2004 2:50 pm

Post by sluggo » Mon May 23, 2011 12:55 pm

I guess you could write out Blox scripting code to handle every conceivable configuration of Open (O), High (H), Low (L), and Close (C) -- making whichever assumptions you wish about the meandering pathway of intraday prices.

The first four bar configurations in your comprehensive catalog, might be the ones shown as A, B, C, D in the attached figure. You may decide that
  • Bar type "A" was probably created by intraday price path #1.

    Bar type "B" was probably created by intraday price path #2.

    Bar type "C" was probably created by intraday price path #1.

    Bar type "D" was probably created by intraday price path #1.
Now it's just a simple matter of filling out your catalog of bar-types, then for each bar-type, choosing a price path you want to assume.

Don't forget to include tall bars (bars where (H minus L) > 20 ticks) and short bars (bars where (H minus L) < 5 ticks) and limit-locked bars and no-movement-whatsoever bars and enormous-gap-from-yesterday bars, in your catalog. You might want to glance at one or two books on candlestick patterns, for other possible ideas.
Attachments
which_happened_first.jpg
which_happened_first.jpg (82.55 KiB) Viewed 5442 times

ACM10022082
Contributor
Contributor
Posts: 3
Joined: Fri May 21, 2010 3:35 pm

Post by ACM10022082 » Mon May 23, 2011 1:32 pm

Hi Sluggo,

Problem here is unable to trace out what actually happened intra-day using just daily bars. Using just daily bar(A) OHLC, we cannot choose #1 vs #2 unless we need additional information of intraday price pattern.

If we pick #1 (trade entered at middle of day but still using b4 actual fill information it might be get stopped out), but in reality #1 could not stopped out as price has not traversed through Stop or Target price after entered into a position.

Please do let me know if misunderstood your explanation.

Thanks,
ACM.

sluggo wrote:I guess you could write out Blox scripting code to handle every conceivable configuration of Open (O), High (H), Low (L), and Close (C) -- making whichever assumptions you wish about the meandering pathway of intraday prices.

The first four bar configurations in your comprehensive catalog, might be the ones shown as A, B, C, D in the attached figure. You may decide that
  • Bar type "A" was probably created by intraday price path #1.

    Bar type "B" was probably created by intraday price path #2.

    Bar type "C" was probably created by intraday price path #1.

    Bar type "D" was probably created by intraday price path #1.
Now it's just a simple matter of filling out your catalog of bar-types, then for each bar-type, choosing a price path you want to assume.

RedRock
Roundtable Knight
Roundtable Knight
Posts: 939
Joined: Fri Jan 30, 2004 3:54 pm
Location: Chicago

Post by RedRock » Mon May 23, 2011 3:10 pm

You would of course, use intraday timeframe data in order to have that information.

I would like a feature request along the lines of clairvoyant parameters. Something like, "if next trade is winner, then do so-n-so"... An extension of these new options may be an intra-bar knowledge of events. Hmmm imagine the possibilities...

Qsquare
Contributing Member
Contributing Member
Posts: 6
Joined: Thu May 19, 2011 8:41 pm

Post by Qsquare » Mon May 23, 2011 3:18 pm

Interesting topic.

I've been wondering if any provider has such a sequential ordering attribute embedded within (it would only take one column). It looks to be the only way to capture such information reliably is to have the higher frequency sampled data. For a long time, I just scrambled the order of high and low, since I assumed they were 50/50, but I've begun to remodel those assumptions. If anyone has any pointers to studies on stylized facts covering this, I'd be glad to see!

thanks.

rabidric
Roundtable Knight
Roundtable Knight
Posts: 243
Joined: Mon Jan 09, 2006 7:45 am

Post by rabidric » Mon May 23, 2011 4:00 pm

don't underestimate the market's ability to touch at/near the high and low multiple times. It happens more often than you would think.

e.g. a 0.5-1 ATR stop if coupled with a re-entry might get whipsawed 2,3 or more times.

this is especially the case on days with major figures where the market can't decide(a turning point for trend maybe?), or where there are multiple figures back to back that conflict.

At a guess i'd say that this kind of behaviour is more prevalent the longer the trading session...(e.g. currencies, and most european markets trade europe and us sessions.)

jankiraly
Roundtable Fellow
Roundtable Fellow
Posts: 52
Joined: Tue Feb 03, 2004 7:23 pm
Location: San Diego

Post by jankiraly » Mon May 23, 2011 4:42 pm

If the ONLY information you have is the daily Open, High, Low, Close then the Shortest Path Heuristic is one of your (very few) options:
  • Choose the piecewise linear price trajectory of shortest total length.

You can work out the arithmetic yourself; there are only two cases to consider. The conclusions are:
  • If (Open > Close) then the shortest path is Open -> High -> Low -> Close. Assume instrument made its High before making its Low
  • If (Open < Close) then the shortest path is Open -> Low -> High -> Close. Assume instrument made its Low before making its High
"The race is not always to the swift nor the battle to the strong, but that's the way to bet" - Damon Runyon

rabidric
Roundtable Knight
Roundtable Knight
Posts: 243
Joined: Mon Jan 09, 2006 7:45 am

Post by rabidric » Tue May 24, 2011 8:30 am

given the perversity of markets and their tendency to take an indirect route from A to B, I would start with assuming the market will take the LONGEST route! :wink:

i.e. O>C then assume O->L->H->C !!!!

of course this isn't the case with trend days etc. in the end it is probably a 60/40 - 50/50 chance on any given day that your shortest route assumption would hold!

which takes Qsquare back to erm, square one....(sorry couldn't resist 8) )

Anthony Marsland
Roundtable Fellow
Roundtable Fellow
Posts: 83
Joined: Thu Jan 13, 2011 5:33 am
Location: London
Contact:

Interesting...

Post by Anthony Marsland » Tue May 24, 2011 5:54 pm

Could BLOX code/structure identify the necessary symbols from daily data to trade next day (maybe at Rank Block) and then pull the 1,5,15, etc mins data (maybe at Entry Block, before trading day script) just for those instruments, for just that day and trade the entry and exit code on this finer granularity data?

If so this logic will solve the issue without a massive data/memory overhead...

This capability would help me greatly too. Any thoughts Tim?

Tim Arnold
Site Admin
Site Admin
Posts: 8500
Joined: Tue Apr 06, 2004 1:41 pm
Location: Boston, MA
Contact:

Post by Tim Arnold » Tue May 24, 2011 6:01 pm

Some customers trade using the intraday data, but base the signals on daily data. Likewise you could trade daily based on weekly data.

Anthony Marsland
Roundtable Fellow
Roundtable Fellow
Posts: 83
Joined: Thu Jan 13, 2011 5:33 am
Location: London
Contact:

Higher Resolution Data

Post by Anthony Marsland » Wed May 25, 2011 4:26 am

Hi Tim,

Just to be clear... When you say other clients use higher resolution data to create lower resolution bars (minute data creating daily bars) I guess you mean they load all the high resolution data into memory for all the instruments to be tested at before simulation stage. They then have BLOX create a lower resolution bars for use in signal creation..?

Conceptually, with the tools available in BLOX as it stands, could I code a data call of minute data having selected a set of instruments who need this higher resolution from a daily bar ranking?

Tim Arnold
Site Admin
Site Admin
Posts: 8500
Joined: Tue Apr 06, 2004 1:41 pm
Location: Boston, MA
Contact:

Post by Tim Arnold » Wed May 25, 2011 12:08 pm

You could use intraday data alone and have Trading Blox create the daily, weekly, and monthly bars which you could then use to create indicators and signals.

Or you could load two separate data files as two separate instruments appending the daily with a -D. Then use LoadSymbol to load up the daily bar instrument and its corresponding indicators like this:

Code: Select all

dailyInstrument.LoadSymbol( instrument.symbol + "-D" )
IF dailyInstrument.myMovingAverage > 100 THEN
 Broker.EnterLongOnStop( entryBreakoutHigh )
ENDIF
Only the intraday symbol would be in the portfolio and traded, but the daily bar version of the instrument could be loaded as needed.

Anthony Marsland
Roundtable Fellow
Roundtable Fellow
Posts: 83
Joined: Thu Jan 13, 2011 5:33 am
Location: London
Contact:

The reverse of example 2?

Post by Anthony Marsland » Wed May 25, 2011 12:27 pm

Could I load the daily bars from one file, creating indicators, trade set-ups etc and then load the separate intra day file for entry and exit as needed?

So in the case of my reversion to mean research:

Psuedo code:

if c < lowest(c,10) on Daily Data then
load intraday data for instrument
broker.enterlongonlimit(1 ATR lower than close, 2 ATR Stop)
endif

Qsquare
Contributing Member
Contributing Member
Posts: 6
Joined: Thu May 19, 2011 8:41 pm

Post by Qsquare » Thu May 26, 2011 1:13 pm

FWIW, I ran exactly about a years worth of QQQ hourly data and noted the order of daily LH. Out of 240 observations, the results were an astounding
50.4% L,H and 49.5% H,L ordering... talk about efficient.

Nor did the autocorrelation have any significance.
> runs.test(pf)

Runs Test

data: pf
Standard Normal = 1.683, p-value = 0.09237
alternative hypothesis: two.sided

I suppose scrambling order assumption wasn't too bad after all.

Angelo
Roundtable Fellow
Roundtable Fellow
Posts: 90
Joined: Fri Apr 29, 2005 4:31 am
Location: Italy

Post by Angelo » Fri Jun 10, 2011 5:43 am

jankiraly wrote:If the ONLY information you have is the daily Open, High, Low, Close then the Shortest Path Heuristic is one of your (very few) options:
  • Choose the piecewise linear price trajectory of shortest total length.

You can work out the arithmetic yourself; there are only two cases to consider. The conclusions are:
  • If (Open > Close) then the shortest path is Open -> High -> Low -> Close. Assume instrument made its High before making its Low
  • If (Open < Close) then the shortest path is Open -> Low -> High -> Close. Assume instrument made its Low before making its High

Hi ACM,

if these assumptions are enough for your needs, you could have a look a this thread, located in the User's support Forum:

viewtopic.php?t=3487&highlight=

Hope this helps.

Post Reply