View Full Version : Accessing TimeStamp of a Tick
02-21-2007, 11:02 PM
After issuing an order, I want to wait a set amount of time then cancel any infilled entry orders. I'm currently using
Is there a way to access TickTime, something like:
If I use:
OrderTime=DateTime.Now; won't that mess up backtesting?
02-22-2007, 12:52 AM
- Datetime.Now will mess up backtesting
- Time will be in the future for time based series (e.g. end of the minute for 1 minute series)
- Time is the timestamp of the current tick on Vol and Tick series. However: with latest beta OnBarUpdate is not (!) triggered right away as a new tick comes in but later (triggered asynchronously). This will change with next beta.
-> if you are dependent on that feature, then you should wait for next beta,
02-22-2007, 01:59 AM
I am using OrderTime=Time now for Vol Charts, and it works as expected (I think). I was thinking ahead to use the same logic on Time charts. To simulate STOPLIMIT with negative offset, and Cancel after 2.5 minutes.
This code is for a Vol chart. Will the same Idea work for Minute charts, or does the EnterLongLimit only get processed at barClose?
Can I also make it work this way for a Minute Chart?
//Determine Entry points on a once per bar basis
// Process Entry Orders on a Tick by Tick basis
if ( High >=OP )
// Simulated STOPLIMIT, negative offset
EnterLongLimit(Op-TickSize, . . . StrategyId);
OrderTime=Time ; // Assume place a Limit Order at 1:01:10
if (Position.MarketPosition != MarketPosition.Flat
&& Time>OrderTime.AddMinutes(2.5)) // At 1:03:40
OP=0; // Stops submitting the EnterLongLimit, > CANCEL
02-22-2007, 02:04 AM
Not sure. Please be aware that OrderTime is a time in the future for minute bars, which is different than for Vol/Tick series where it's the time of the last tick.
02-22-2007, 02:12 AM
Right, that is why I wanted to access the TickTime on the Tick that triggers the Order.
If I could Set OrderTime to the time of the triggering tick, then I think this code will work for Vol, Tick, and Minute charts
02-22-2007, 02:22 AM
I guess you are stretching the concept a bit too far, meaning your backtesting part will behave diffrently than the realtime part of the strategy.
Here is why:
- backtested orders are placed after close of the bar -> OrderTime will be the timestamp of the bar on close
- on realtime: OrderTime will be the actual tick timestamp (Vol/Tick series) or the timestamp of the bar on close (in the future for e.g. minute series)
-> your backtest result will not be reproducible realtime. I suggest rather going by "bars to wait" until next action is taken, instead of absolute "time to wait"
02-22-2007, 02:39 AM
Thanks for the detailed explanation. I can live with Backtest being different than real time (it always is anyway, even with best intentions).
I take it that Access to TickTime is not available, and not likely to become available. I'll adjust my thinking.
thanks for your response.