"this bar close" order type for Tradestation

936 views
Skip to first unread message

Jatin Patel

unread,
Jul 3, 2014, 11:19:50 AM7/3/14
to adaptrad...@googlegroups.com
Hi Mike,

Under the "Order types" tab, can you consider adding "this bar close" entry and "this bar close" exit for Tradestation?

When using advanced bar types like Kagi, it makes huge difference between the following two statements for example:

Buy next bar market;
Buy this bar close;

Sell next bar market;
Sell this bar close;

Although the statements appear to do the same, in real life it makes a huge difference due to the way these advanced bar types are constructed.

Thanks,
Jatin

Michael R. Bryant

unread,
Jul 3, 2014, 3:11:33 PM7/3/14
to adaptrad...@googlegroups.com

“On-close” orders have not been part of Builder because in the past TS has not supported them properly. It used to be that you needed to stay away from entering on the close in real time because TS executes the strategy code on the close of the bar and would delay the execution of the strategy by one bar if you had an “enter on close” order. They no longer do that, so, at least in back-testing, it works now. However, you still need to be careful because, in real-time, the bar will already be closed by the time the “on close” order is placed. For daily bars, this may mean your order is not filled until the next day’s open. Just for the record, the only “advanced” bar type currently supported in Builder is range bars.

 

Mike Bryant

Lawrence Lewis

unread,
Jul 3, 2014, 4:12:59 PM7/3/14
to adaptrad...@googlegroups.com
"Just for the record, the only “advanced” bar type currently supported in Builder is range bars"

Exactly what does Builder do differently for Range bars versus the time-based bars.


--
You received this message because you are subscribed to the Google Groups "Adaptrade Builder" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adaptrade-buil...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael R. Bryant

unread,
Jul 3, 2014, 6:50:06 PM7/3/14
to adaptrad...@googlegroups.com

It primarily means two things: no “exit on session close” order type; and no DayOpen, DayHigh, DayLow or DayClose indicators.

 

Mike Bryant

Lawrence Lewis

unread,
Jul 3, 2014, 7:22:27 PM7/3/14
to adaptrad...@googlegroups.com
So, IMHO, the only realistic way to use range bars or Renko bars, is to have the tick that causes the range to be exceeded to be the close of the bar. Then, a market order would take place at the next tick, which would be the open of the next bar.

Unfortunately, this would mean that every range bar would actually be a bit larger (or even more than "a bit") than the specified range. I'm willing to accept that because I think it's the only realistic thing you can do. You can't place an order at the exact time a condition occurs...only a short time later.

Now, for backtesting, you actually would have another choice: You could assume that (for a buy order) you could get the ask price that existed at the time of the tick that exceeded the range. And, you could assume that that ask price is just the bid plus the delta you specified to Builder. But even if Builder were to do this, as far as I know, there is no way to generate TradeStation or NinjaTrader code that would do the same thing.

So, for me, what I am going to do is create my own "realistic" range bars (using code outside Builder) that includes the tick that exceeded the specified range as the close of the bar, and uses the next historically occurring tick as the open of the next range bar.

Interestingly, I have done a bit of simulation using range bars, and using a range bar with an Exponential Moving Average is very similar to using time based bars with adaptive moving averages.


--

mandelmus

unread,
Jul 4, 2014, 5:46:24 AM7/4/14
to adaptrad...@googlegroups.com
A while back, I experimented with Building using Kase bars and the results were incredible.  When I tried to run the strategies live in Tradestation, everything broke down quickly.  I did not realize how complicated it is to even backtest on "Advanced Chart Types" (Kagi, Point & Figure, Renko, and Line Break charts).  Here is a quote from the Tradestation forum ...

Live trading results may not match back-tested results as Advanced Bar Types are artificially constructed from historical data in a manner which does not always follow market prices in the same sequence as may occur in real-time. For example, if you copy an Advanced Bar chart with a strategy trading on it in real-time to create another chart, you may notice the strategy entries/exits do not match the original chart. This is because the strategy was trading in real-time on the original chart, but trades on historical bars ( which may be different than the real-time bars ) on the copied chart. The high and low prices observed for an in-progress Advanced Bar when real-time ticks are arriving can be very different than the high and low prices for a historical bar. This is because Advanced Bar Types are based on prices ( filter prices ), and usually end up truncating the actual price range.

It would take Tradestation working with Mike over several months to get all these problems resolved.  So, in the meantime, I'll work with the more common bar types.   I posted some of my experience with Kase bars and Builder, but I can't find the  posts now.


On Thursday, July 3, 2014 6:22:27 PM UTC-5, Larry wrote:
Interestingly, I have done a bit of simulation using range bars, and using a range bar with an Exponential Moving Average is very similar to using time based bars with adaptive moving averages.

Ya, that kind of makes sense -- good observation.

Jatin Patel

unread,
Jul 4, 2014, 1:59:20 PM7/4/14
to adaptrad...@googlegroups.com
If in back test the order "this bar close" works, then we can change the generated code to replace "this bar close" with "next bar market".

Then in real time, an order would fill near the close of the previous bar. Wouldn't that work as if the order was actually executed as "this bar close"?
Reply all
Reply to author
Forward
0 new messages