I want my orders being placed on first tick (open) of new bar.
my bars are timebased 1 min.
in order to capture the open tick, i ask for
if barstatus(1) = 0 then
Buy ("Long") 1 contracts this bar at close;
begin
but i never get barstatus=0. always 1 or 3.
furthe, when enable bar magnifier with intraday 1 min for 10 min bars,
orders later executed than placed.
this is from script log:
Short 1.437200 #= 313.00 18.01.2010 05:11:00
and executed at 05:20
question:
a) why never getting barstatus=0
b) what is the reason for the execution delay
thank you
intrabar order generation: never get barstatus(1) = 0
- TJ
- Posts: 7745
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2224 times
my notes:
Try not to use "Buy this bar at close";
this is a legacy syntax... carried over from the old daily chart days.
This syntax is ONLY good for backtesting,
it is for concept proving only, not usable for live trading.
Whatever you have developed, you have to replace this sytax with something else,
so might as well start with something you don't have to change later.
reference:
EasyLanguage Essentials Programmers Guide
Strategy Order Syntax.... pg 80
Try not to use "Buy this bar at close";
this is a legacy syntax... carried over from the old daily chart days.
This syntax is ONLY good for backtesting,
it is for concept proving only, not usable for live trading.
Whatever you have developed, you have to replace this sytax with something else,
so might as well start with something you don't have to change later.
reference:
EasyLanguage Essentials Programmers Guide
Strategy Order Syntax.... pg 80
- TJ
- Posts: 7745
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2224 times
hello TJ,
i am doing backtest and want orders placed on IB account.
I do not want to user inbuild OrderAutomat of MC,
i use my own dll placing orders.
basically, if i send
Buy ("Long") NbrShares contracts this bar at close;
i want this order being filled in backtest and for real trading
i will place below a line
PlaceOnIB("Buy",close,...)
of course there will be a slippage. But this slippages is put
on Strategy setup.
I need something very simple:
I want to place an order at close (current price) on first tick for each
bar. My data are intraday minute bars. Thus i need to enable
intrabarOrderGeneration. My understanding is, that first (simulated)
tick for bar should be the same as open of historical 1 min bar.
thank you for comments
i am doing backtest and want orders placed on IB account.
I do not want to user inbuild OrderAutomat of MC,
i use my own dll placing orders.
basically, if i send
Buy ("Long") NbrShares contracts this bar at close;
i want this order being filled in backtest and for real trading
i will place below a line
PlaceOnIB("Buy",close,...)
of course there will be a slippage. But this slippages is put
on Strategy setup.
I need something very simple:
I want to place an order at close (current price) on first tick for each
bar. My data are intraday minute bars. Thus i need to enable
intrabarOrderGeneration. My understanding is, that first (simulated)
tick for bar should be the same as open of historical 1 min bar.
thank you for comments
- TJ
- Posts: 7745
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2224 times
1. I think barstatus is only valid on live data. (I am not sure, someone can confirm).
2. when you say: "Buy ("Long") 1 contracts this bar at close; "
do you mean you want to buy at the closing price of that bar?
I don't know of a way to do that.
Nobody knows which tick will be the closing tick until it happens.
when the "close" happened... you are effectively buying Next Bar at Open.
2. when you say: "Buy ("Long") 1 contracts this bar at close; "
do you mean you want to buy at the closing price of that bar?
I don't know of a way to do that.
Nobody knows which tick will be the closing tick until it happens.
when the "close" happened... you are effectively buying Next Bar at Open.
this bar at close means for me the current simulated tick of the bar.
so at the current simulated (intrabar generated tick ) price.
MC uses 2 methods to break down a time based bar into ticks
as far as i know:
for down candles it assumes:
1 tick open
2 tick high
3 tick low
4 tick close
for uo candles it assumes:
1 tick open
2 tick low
3 tick high
4 tick close
i simply whish the backtest system count order as placed and filled
exactly when my script says: Buy...at the current close
i can not see the problem here
so at the current simulated (intrabar generated tick ) price.
MC uses 2 methods to break down a time based bar into ticks
as far as i know:
for down candles it assumes:
1 tick open
2 tick high
3 tick low
4 tick close
for uo candles it assumes:
1 tick open
2 tick low
3 tick high
4 tick close
i simply whish the backtest system count order as placed and filled
exactly when my script says: Buy...at the current close
i can not see the problem here
- TJ
- Posts: 7745
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2224 times
- TJ
- Posts: 7745
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2224 times
- Bruce DeVault
- Posts: 438
- Joined: 19 Jan 2010
- Location: Washington DC
- Been thanked: 2 times
- Contact:
A desire to know the price of the open of the bar, then place an order and be filled at the open of the bar, without waiting for anything further to happen, is understandable from a "wouldn't it be great if" perspective, but misguided. You need to design trading systems that do not require time travel or knowledge of the future in order to function, and you can't get a fill in zero time in real-life even if the back-testing engine were simplistic enough to allow you to do this in back-testing. No solid back-testing platforms permit this kind of thing, for obvious reasons - it would lead to test results that don't hold up in real life.
You can, however, place orders "at the open of each bar" - you just need to place them at the close of the previous one rather than waiting for the new bar to already be opened, then try to travel back in time and place an order to be in effect then. For instance, in a trading system that isn't IOG, simply say "buy next bar at market". In an IOG system, check BarStatus(1) = 2 to know that it is the closing tick of the bar then say "buy next bar at market".
You can, however, place orders "at the open of each bar" - you just need to place them at the close of the previous one rather than waiting for the new bar to already be opened, then try to travel back in time and place an order to be in effect then. For instance, in a trading system that isn't IOG, simply say "buy next bar at market". In an IOG system, check BarStatus(1) = 2 to know that it is the closing tick of the bar then say "buy next bar at market".