NexusFi: Find Your Edge


Home Menu

 





TradeStation Back-testing/Intra-bar Order Generation/Slippage


Discussion in TradeStation

Updated
    1. trending_up 4,079 views
    2. thumb_up 11 thanks given
    3. group 2 followers
    1. forum 13 posts
    2. attach_file 0 attachments




 
Search this Thread

TradeStation Back-testing/Intra-bar Order Generation/Slippage

  #1 (permalink)
highlyimprobable
ridgewood, NJ
 
Posts: 13 since Aug 2019
Thanks Given: 8
Thanks Received: 6

Some of my questions here is a continuation of my previous post here:

I am trying to automate a strategy on TS using its EasyLanguage. Previously, I used intrabarordergeneration (IOG) and with a 5-minute backtesting, the results looked great but as mtzimmer1 suggested in the post above, I switched the resolution to 1 tick over a month, and the results were pretty disappointing. (This is because I am using 5-minute intervals and my positions last anywhere from 5 min to 2 hours with an average of 50 minutes). I don't know if I am going to use IOG in the near future, and I understand that if I turn on IOG, the orders for entry/exit are placed at the next tick if the entry/exit conditions are satisfied. Something that I don't really understand from the description of IOG on the EasyLanguage page is the following:
If I have a moving average of the past 5 periods (5-minute intervals) and IOG is turned on, then how is it calculating the moving average? It is definitely not of the past 5 ticks, so is it taking each tick and then going back 5, 10, 15, 25 minutes and taking the average? If I am saying Close[1] is that the previous tick or the Close of the previous 5-minute bar?

Now, for my next question. So, I've turned IOG off except for my Stop Losses and Profit Targets. Every entry and exit that I have defined is executed
This Bar at Close
If IOG is turned off for entry/exit and I am running 5-minute intervals on my strategy, I would expect that back-testing at the 5-minute interval would not be much different than back-testing tick by tick except for slippage in my stop losses. Now, why is this completely wrong? I compare the back-testing and they are completely different. The 5-minute makes decent profit after commission over a few days while the tick by tick does not. Is this all slippage? It doesn't make sense for it to be this different since the backtesting should factor in High/Low for Stop Losses, right?

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NexusFi Journal Challenge - April 2024
Feedback and Announcements
Build trailing stop for micro index(s)
Psychology and Money Management
Are there any eval firms that allow you to sink to your …
Traders Hideout
Better Renko Gaps
The Elite Circle
Online prop firm The Funded Trader (TFT) going under?
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
60 thanks
Funded Trader platforms
37 thanks
NexusFi site changelog and issues/problem reporting
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
The Program
19 thanks
  #2 (permalink)
 
mtzimmer1's Avatar
 mtzimmer1 
Upstate NY
Recovering Method Hopper
 
Experience: Intermediate
Platform: TOS
Broker: TD Ameritrade
Trading: Equities, Treasuries, Gold
Posts: 840 since Dec 2018
Thanks Given: 2,201
Thanks Received: 1,918

I'm not sure exactly why the difference in results is occurring but it usually has to do with how the strategy is coded. (What logic is used)

As far as the other question goes... IOG calculates the current price as the "close" until the bar itself actually closes. Say a five minute bar opens at 100.00. One minute in it has traded up to 100.24 and has satisfied the moving average condition; the order will be filled the moment the condition is met. We do not know what the close will be four minutes from now, and for that reason the tentative "close" is calculated as the last transacted tick.

I hope this answers at least half of your question.

-Zimmer

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #3 (permalink)
highlyimprobable
ridgewood, NJ
 
Posts: 13 since Aug 2019
Thanks Given: 8
Thanks Received: 6



mtzimmer1 View Post
I'm not sure exactly why the difference in results is occurring but it usually has to do with how the strategy is coded. (What logic is used)

As far as the other question goes... IOG calculates the current price as the "close" until the bar itself actually closes. Say a five minute bar opens at 100.00. One minute in it has traded up to 100.24 and has satisfied the moving average condition; the order will be filled the moment the condition is met. We do not know what the close will be four minutes from now, and for that reason the tentative "close" is calculated as the last transacted tick.

I hope this answers at least half of your question.

-Zimmer

Hi again Mr. Zimmer! Ah, so what you are saying is that with IOG on with your example (which my question is completely related to but I phrased terribly), when the moving average condition is satisfied, say at exactly 10:26:00 and for simplicity a simple moving average, the simple moving average calculation is (Price(10:26) + Price(10:21) + Price(10:16) + Price(10:11) + Price(10:06))/5, right?

I will check my strategy code again to see what the difference is, but you don't think slippage is the problem? I checked the first page of the trades list and I think the trades (time and position) were all the same in the 5-minute back-testing and the tick by tick except for the losses/profits.

Reply With Quote
  #4 (permalink)
 
mtzimmer1's Avatar
 mtzimmer1 
Upstate NY
Recovering Method Hopper
 
Experience: Intermediate
Platform: TOS
Broker: TD Ameritrade
Trading: Equities, Treasuries, Gold
Posts: 840 since Dec 2018
Thanks Given: 2,201
Thanks Received: 1,918


highlyimprobable View Post
when the moving average condition is satisfied, say at exactly 10:26:00 and for simplicity a simple moving average, the simple moving average calculation is (Price(10:26) + Price(10:21) + Price(10:16) + Price(10:11) + Price(10:06))/5, right?

Almost.

It is actually (Price(10:25) + Price(10:20) + Price(10:15) + Price(10:10) + Price(10:06))/5

It maintains the previous closes that have already been completed but uses last tick for the "close" of the currently un-closed bar.

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #5 (permalink)
highlyimprobable
ridgewood, NJ
 
Posts: 13 since Aug 2019
Thanks Given: 8
Thanks Received: 6


mtzimmer1 View Post
Almost.

It is actually (Price(10:25) + Price(10:20) + Price(10:15) + Price(10:10) + Price(10:06))/5

It maintains the previous closes that have already been completed but uses last tick for the "close" of the currently un-closed bar.

Do you mean

(Price(10:25) + Price(10:20) + Price(10:15) + Price(10:10) + Price(10:26))/5

instead because 10:25 to 10:30 is the un-closed 5-minute bar?

So, it actually gives more emphasis to more recent prices.

Reply With Quote
Thanked by:
  #6 (permalink)
 
mtzimmer1's Avatar
 mtzimmer1 
Upstate NY
Recovering Method Hopper
 
Experience: Intermediate
Platform: TOS
Broker: TD Ameritrade
Trading: Equities, Treasuries, Gold
Posts: 840 since Dec 2018
Thanks Given: 2,201
Thanks Received: 1,918


highlyimprobable View Post
Do you mean



(Price(10:25) + Price(10:20) + Price(10:15) + Price(10:10) + Price(10:26))/5



instead because 10:25 to 10:30 is the un-closed 5-minute bar?



So, it actually gives more emphasis to more recent prices.



Sorry for the error! Yes that is correct 10:26!

Emphasis should be equal to all five data points. Sum all five, and divide by five. Equal weighting!

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #7 (permalink)
highlyimprobable
ridgewood, NJ
 
Posts: 13 since Aug 2019
Thanks Given: 8
Thanks Received: 6


mtzimmer1 View Post
Sorry for the error! Yes that is correct 10:26!

Emphasis should be equal to all five data points. Sum all five, and divide by five. Equal weighting!

Yes, I understand the weighting is equal, but I meant more along the lines of the following reasoning. With IOG on, the SMA is taking an average of values that are closer to the current time than with IOG off, where we have an average is spaced evenly by 5 minutes.

Thanks for all your help!

Reply With Quote
  #8 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,647 since Jul 2012
Thanks Given: 1,890
Thanks Received: 7,338

You can easily see what is going on with IBOG by using a print statement:

var:bl(" ");
print(date,bl,time,bl,close,bl,close[1],bl,close[2],bl,close[3],bl,close[4],bl,close[5]);

My experience with IBOG is limited, as years ago I found it did not backtest the way I though it should, and results were so puzzling at times I thought I'd lose my mind.

My hair stopped falling out (OK, more slowly fell out) once I gave up on IBOG...

Follow me on Twitter Reply With Quote
  #9 (permalink)
highlyimprobable
ridgewood, NJ
 
Posts: 13 since Aug 2019
Thanks Given: 8
Thanks Received: 6


kevinkdog View Post
You can easily see what is going on with IBOG by using a print statement:

var:bl(" ");
print(date,bl,time,bl,close,bl,close[1],bl,close[2],bl,close[3],bl,close[4],bl,close[5]);

My experience with IBOG is limited, as years ago I found it did not backtest the way I though it should, and results were so puzzling at times I thought I'd lose my mind.

My hair stopped falling out (OK, more slowly fell out) once I gave up on IBOG...

Ahahaha, I think I am about to close the chapter that is IBOG. It seems like there is a huge potential with IBOG, but understanding the intricacies of it might not be worth it. Do you have any ideas as to why the back-testing for 5-minute is significantly different from the tick by tick when IBOG is only turned on for stop losses and profit targets?

Yes, you are completely right about the Print function (I am so used to having the Print results next to my code when I execute it that I completely ignore it when I'm on TS).

Reply With Quote
  #10 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,647 since Jul 2012
Thanks Given: 1,890
Thanks Received: 7,338



highlyimprobable View Post
Ahahaha, I think I am about to close the chapter that is IBOG. It seems like there is a huge potential with IBOG, but understanding the intricacies of it might not be worth it. Do you have any ideas as to why the back-testing for 5-minute is significantly different from the tick by tick when IBOG is only turned on for stop losses and profit targets?

Yes, you are completely right about the Print function (I am so used to having the Print results next to my code when I execute it that I completely ignore it when I'm on TS).

I could guess at what might be going on, but to really know I'd have to see the code in cases like this. (I'm not asking to see it, to be clear.)

The huge potential you see with IBOG is likely just tricks being played on the backtest engine. IN other words, not real.

Follow me on Twitter Reply With Quote




Last Updated on September 3, 2019


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts