intrabar order generation question

Questions about MultiCharts and user contributed studies.
ts2mc
Posts: 122
Joined: 12 Jan 2009
Been thanked: 1 time

intrabar order generation question

Postby ts2mc » 27 Feb 2010

hello,
i have a signal placing orders:

Buy ("b1") MyShares contracts next bar at open limit;

i attached this signal to a 1 min bar chart and
switched intrabar order generation on.

however, my orders are always generated at open of 1 min bar.

any ideas what's going wrong ?

thank you

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Postby TJ » 27 Feb 2010

You did not say what operation you are expecting.


if you want the order to kick in immediately,

then change the line to:

Buy ("b1") MyShares contracts next bar at market;




.

ts2mc
Posts: 122
Joined: 12 Jan 2009
Been thanked: 1 time

Postby ts2mc » 27 Feb 2010

Hello TJ,
thanks for anwer.
i tried your suggestion and found my orders still placed at open
(next bar).

i'd like to have a limit order placed (and as assumed as fill from backtest)
once i initiate it.

say my 1 min bar is open = 5 and close = 20 and min move=1
and my order price is 13, i like this order placed at this bar at 13
and not next bar open.

is this possible at all ?

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Postby TJ » 27 Feb 2010

Hello TJ,
thanks for anwer.
i tried your suggestion and found my orders still placed at open
(next bar).

i'd like to have a limit order placed (and as assumed as fill from backtest)
once i initiate it.

say my 1 min bar is open = 5 and close = 20 and min move=1
and my order price is 13, i like this order placed at this bar at 13
and not next bar open.

is this possible at all ?
in your original post,
How does the open come into play?

Buy ("b1") MyShares contracts next bar at open limit;

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Postby TJ » 27 Feb 2010

Hello TJ,
thanks for anwer.
i tried your suggestion and found my orders still placed at open
(next bar).

i'd like to have a limit order placed (and as assumed as fill from backtest)
once i initiate it.

say my 1 min bar is open = 5 and close = 20 and min move=1
and my order price is 13, i like this order placed at this bar at 13
and not next bar open.

is this possible at all ?

what do you mean by close = 20 ?

do you mean the previous close?
or do you mean the current price?

How role does it play in the formula you are working on?

ts2mc
Posts: 122
Joined: 12 Jan 2009
Been thanked: 1 time

Postby ts2mc » 27 Feb 2010

the open comes into play - as i assume - as any possible
price between current bar open and current bar close.
this is because i thought that intradaybar generation allows
calls the script for each possible price between bar open and bar close.

sample:
the 1 min bar is open=5 and close = 8
then, i think, the script is called 4 times with open=close
open=5
open=6
open=7
open=8

assume at 2nd call for this bar (open=6) my calc. says place
limit, then i like the system to place a limit order at 6 (and assumes its
getting filled)

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Postby TJ » 27 Feb 2010

I think there is a misunderstanding here.

There is only ONE open price per bar.

Close is referred to 2 things:

1. in real time current uncompleted bar, Close is the LAST completed trade price

2. when referring to a completed bar (eg close[1]), Close is the final completed trade price of the bar.

ts2mc
Posts: 122
Joined: 12 Jan 2009
Been thanked: 1 time

Postby ts2mc » 27 Feb 2010

Hello TJ,
ok, i think i understand this now: if intradaybar update enabled, open
of each script call for bar x is fix and the same as the open
for the "historical" (completed) bar.
Where close can be each price within the bar, high and low included.

Whati need, is to enable the script to place a limit order at the current
(real time simulated) close and if possible the backtest system
assumes this orders as filled.
Is this possible ?

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Postby TJ » 27 Feb 2010

Hello TJ,
ok, i think i understand this now: if intradaybar update enabled, open
of each script call for bar x is fix and the same as the open
for the "historical" (completed) bar.
Where close can be each price within the bar, high and low included.

Whati need, is to enable the script to place a limit order at the current
(real time simulated) close and if possible the backtest system
assumes this orders as filled.
Is this possible ?
you don't need the intrabarordergeneration.

all you need is

Buy ("b1") MyShares contracts next bar at open;


"next bar at open" is equivalent to saying:
buy at the closing price of this bar.

.

User avatar
Bruce DeVault
Posts: 438
Joined: 19 Jan 2010
Location: Washington DC
Been thanked: 2 times
Contact:

Postby Bruce DeVault » 28 Feb 2010

The difference between buying "next bar at open" and "this bar at close" is that the former is in general possible, while the latter is in general impossible (although it can be sort of approximated with a bunch of extra code and intrabar order generation - see below).

If you think about it, there's no way to ACTUALLY buy at this bar's close, because by the time you know what the closing price is, the bar is already closed. (Yes, you can approximate it by doing things like looking at the time, counting ticks, etc... but it's always an approximation, and your test results are always suspect. If you're going to do this, it's generally better to simply use a smaller bar such as 1 minute instead of 60 minutes, and buy at the open of the last 1 minute bar in the 60 minutes.) So, while it's convenient in terms of making models that "test well" to do buy "this bar at close", it's generally a bad idea in terms of making systems that are capable of being taken live in a way that's productive, and at the risk of overgeneralizing, often tends to be a wrong turn on the system development path in that it's a way to make things that "test well" but with results that may be suspect.


Return to “MultiCharts”