Signal Reversing Intrabar

Login or Register

Please login or register in order to view and post in the Forum.

8 posts / 0 new
Last post
kjb1891
Last seen: 6 days 17 hours ago
Joined: 04/05/2011 - 00:00
Signal Reversing Intrabar

I have a trading system programmed that looks pretty good in hindsight but has one issue when I watch it live.

I have it set to go long or short based on a simple custom indicator. The problem is that if one signal is triggered during a bar, let's say it's a long in this example, and then a signal to reverse short should be triggered intrabar during that same bar it doesn't show a reversal when it should.

Essentially it seems that once a long or short signal is triggered during a bar that it won't then change the signal intrabar during that same bar.

So, for a hypothetical example, let's say I have a 1 minute chart open and the periodicity I have set for the trading system is also set to 1 minute. I also have the "Intra-bar" box selected for the trading system. And let's say that I have it programmed to go long if the custom indicator is above 50 and go short if it's below 50.

If during the 9:31 bar I initially get a long signal because the custom indicator is above 50, but then during that same 1 minute bar the custom indicator then goes below 50 to trigger a short. Currently if that occurs the signal arrow on the chart stays long and doesn't reverse short even though the custom indicator should trigger it to do so.

But, once the next bar starts at 9:32 it will then show the correct signal to go short if the indicator is still below 50. So the system seems to know on the next bar to reverse but it's doing it after the fact and not during the previous 9:31 bar when the custom indicator originally should've triggered the reversal.

The chart/system seems to stick with only one signal per bar basically and doesn't dynamically change trade position intrabar if there's a reversal.

Am I missing a setting to make it do that correctly?

Thanks for any help,
Kyle

0
TraderMike
Last seen: 4 years 10 months ago
Joined: 03/26/2019 - 08:19
I'm having the same issue

I want to enter and exit on the same bar
Both signals are marked "intraday"
It will enter the trade but will not exit on the same bar even though the exit rule is met
It will wait until the close of the bar to evaluate the exit rule
Is it possible to enter and exit the same bar when both signals are marked intrabar?
Please advise
Thanks

Eddy_F
Last seen: 2 months 1 week ago
Joined: 07/30/2014 - 16:18
Intrabar backtesting basics

Dear Kyle, Dear Mike,
i am sorry but i need to "kill" your hopes : what you are asking is just impossible... And this has nothing to do with IRT -

If you are backtesting a system based on one minute bar (which means your input data is OHLCV data for a given one minute bar), you can t have entry and exit signals on the same intrabar.
It is just plain logic as any backtesting program only has access to OHLCV data for that given bar, but doesn't know, for example, if the high or the low was hit first !!
And the backtesting program cant compute all the possible value of a given indicator that would be using the "latest" LAST value (as in real conditions) because it doesn t have access (by definition of the 1 min bar periodicity) to each individual trade price that took place during that 1 min period..
.. so your indicator might be moving 10 times within a 1 min bar above or below 50, but no backtest program (based on 1 min bar) is able to provide such information -
The only way would be to provide ALL the historical tick data to the software and use a 1 tick data periodicity !! which is basically unfeasible knowing ES has for example 1000000s of tick per day.

You are over estimating the "intra-bar" feature.
For backtesting purpose, the intra-bar box is mainly used for EXIT, ie you consider high and low value of a bar (instead of the close..) to estimate if your fixed stop or target level were hit during the life of that bar - and btw, the result is only valid if one signal is hit during that bar (if both are hit, always consider that the stop was hit first, or you may overestimate your P&L if you stop rule is located after your profit target exit rules)
And if you use it for "live entry", 99% of the time, it is impossible to reproduce such entry signal in your backtest using 1 min data as explained above.. The only exception is when your entry is based on the breakout of a high or low of the bar... and even in this case, you can't simulate (in the backtest) an exit on the same bar as you never know if the low or high happened first..

I know this can be very confusing at first (and I still remember some serious headache i had on that topic when i first really investigated it.. 20 years ago)
but it is worth digging that topic as making sure your backtest result are realistic is a must..
Good luck
Cheers
Eddy

TraderMike
Last seen: 4 years 10 months ago
Joined: 03/26/2019 - 08:19
Intrabar backtesting basics

Eddy, Thank you very much for taking the time to give that detailed explanation.
I completely understand that a backtest cannot pinpoint with any accuracy without actual tick data.
I didn't specify in my post but what I am experiencing is during live data coming in with new bars forming;
So, I have a 20T Renko Bar chart, it enters intrabar just fine (x amount of tick above a Hull MA) and the exit rule is asking for TR_FILL + 10*TINC.
I have watched before where the BID can go beyond the 10 ticks and the rule does not engage.
When the bar closes and moves on to the next bar, then the rule will engage when the TR_FILL + 10 is met.
So, this is where my confusion is coming from, it's process tick by tick data but not responding.
Is the TSYS indicator geared to view bars as though they are historical? - meaning that they must close first to become history data and then the TSYS reacts?
I really like this platform, I'm just wondering if I can fashion rules around the way the TSYS indicator runs the show
As long as I have a full understanding I can work with it, naturally, if you are going to run a system and turn your back on it, you want 100% predictability and confidence in its performance
Really looking forward to your reply
Thanks
Mike

Eddy_F
Last seen: 2 months 1 week ago
Joined: 07/30/2014 - 16:18
About some backtesting principles...

Hello Mike,
thanks for the details provided in your post - you are asking some good questions and i will try to answer them as simply as possible… First, its a very good idea to stick with IRT : TSYS is a really unique tool and it is fully possible to use it and have live results in line with simulation.

As you mentioned, you want “100% predictability and confidence” in the performance of your trading system. But in order to have live performance “matching” backtesting results, there are few "PRINCIPLES" to be followed – Unfortunately, this a very complex topic because there are no magic and easy recipes (and therefore no real reference resource or books on the topic..) as these principles depends on a lot of factors, the main one being
a) the periodicity of the bar being used for the backtest
b) the way your entry and exits rules are written (ie are you using “intrabar” or end of bar type of signals), the number and exit rules, etc
c) and, of course, the backtesting software you are using

But I can guarantee that, 99% of the time, the issue isn’t coming from the software itself, but from badly designed entry and exit rules syntax which will result in over optimistic backtest results which can’t be matched in live conditions (and you are most likely unfortunately in that situation..)
Moreover, there are always some “exceptions” to these principles depending on each trading system configuration. Anyhow, I will start in his post with the first and most important principle

FIRST PRINCIPLE : in order to guarantee 100% reproducibility of a trading systems in “live conditions”, the trade “duration” should be at least one bar : ie entry on a given bar, exit on one of the following bar. More generally, in case of "intra-bar" signals, it is recommended to have only one possible rule being potentially executed during a given bar.

So the consequence of this first principle is that the syntax of your entry and exit rules (used in your backtest) SHOULD GUARANTEE that it is impossible to enter and exit on the same bar – In that case, live result will be able to match backtest results, assuming that you (and your trading systems) also comply with the other (not yet mentionned) principles..
Indeed, as explained in the previous post, for any trading systems, having entry and exit happening on the same bar is usually a recipe for disaster. It could be acceptable in very few specific cases, but I really recommend to have entry and exit on separate bars… If it is not the case, then your backtesting results won’t be most likely reliable as
1) the backtest software (being limited to the OHLCV data corresponding to the bar periodicity) doesn’t know the exact timing of the “events” within a given bar (ie the times and sales occurring during that bar)
2) Moreover, your backtest rules, for a given bar, are tested in a “sequential” order. So having 2 different rules potentially occurring on the same bar (either an entry and exit rules, or 2 exits rules) will be an issue.
For example, if your stop and a profit target rules may happen on the same bar, then you will never be able to know which one will happen first on that given bar, ie your backtest result won’t be reliable...

For the record, the easiest way to comply with this "one bar" minimum trade duration is therefore to “enter” a new position at the close of the bar : this way you can’t exit on the same bar as the first possible tick, to exit the position, will be on the “next” bar. So most people are complying with the first principle (without even knowing that principle) by just entering new position at the Close.
But, if your entry rules is potentially an “Intra-bar” execution (which is your case) and if there are several potential exit rules in competition (which is 99% the case for trading systems), then the exit rules should guarantee (by design) that such an exit can’t occur on the same bar.
To make it short, allowing "intra-bar" live signal execution is mathematically against the nature of a backtest being based on a single set of OHLCV data for a given bar. And there is no easy solution, other than making sure that only one entry or exit rule may occur on any given bar... (which itself isn't easy, especially if you allow both entry and exit to occur intrabar) - It is generally much easier/better to pick a "lower" timeframe, and have (at least) either the entry or exit occuring at the close of the bar...

So I guess you understand now the issue with your system which is based on a 20 tick renko chart. Currently, your profit target rule is “entry point + 10 tick”. Knowing that your entry rules is an “intra bar” one, backtesting such an exit rule on a 20 tick renko bar periodicity make little sense as the resulting trade duration will be either zero or one bar !! I don’t know what is your stop rules, but, by definition, it can’t be well taken into account in the case of a "zero" bar trade duration (therefore most likely artificially boosting your trading system P&L..)

So, knowing the way a 20 tick renko bar is "being built", if your entry is an intra-bar one, in order to guarantee that your exit (stop or profit target) is happening on the next renko bar, then
1) your minimum profit target should be at least 20 tick (ie next bar in the same direction than the entry bar in that case)
2) your minimum stop level should be 60 tick (ie the next bar is a reversal bar..)

Renko bars are a real must for trading, but they create also a lot of additional complexity (ie potential pitfalls) when someone want to run a realistic backtest on that periodicity… So it is even easier, with renko bars, to get “fake” backtest result by not following the first principle…

I hope this post will help
Good luck with your trading system development
Cheers
Eddy

TraderMike
Last seen: 4 years 10 months ago
Joined: 03/26/2019 - 08:19
About some backtesting principles...

Eddy,
You are an awesome dude
I have complete clarity on both the theory behind the behavior of TSYS and the correlation of backtesting and live expectations
IRT is a great product
I will make the necessary adjustments
I wish you a good day and greatly appreciate your input on this matter and I believe a lot of others will benefit from this discussion
This should be a "sticky" in the RTL Systems Development category of this forum
I believe that this will clarify for a lot of other traders that are using IRT for automated trading
Chad has done an unbelievable job with documentation and videos describing all of the aspects of IRT
There was just something I couldn't put together in my mind
Thanks again
All the best
Mike

william-linn
Last seen: 1 week 4 days ago
Joined: 06/03/2011 - 00:00
Trading Rule Indicator

If you are not familiar with the Trading Rule indicator you might want to consider adding a companion Trading Rule to the chart along with your Trading System Indicator. The Trading Rule indicator can be setup to be "enabled" only when you are LONG or SHRT (or both). It will reference an RTL Signal that is looking for your exit condition. When the trading rule sees that you are in a position, it begins testing your exit signal intra-bar, it can re test on every price change for example. If the exit condition fires,  the trading rule can submit a trading order to flatten the position (cancel all working orders and send a buy or sell to close the position out). Trading rules can send a specific trading order, or they can fire a signal action that in turn sends a trading order. Using a signal action means that you have the opportunity to specify a "confirming signal" where you may do some RTL housekeeping and/or check other conditions before exiting the position. For example, your confirming RTL signal can set some V# variable that indicates that it is about to flatten the position. The Trading Rule's RTL signal that looks for the exit condition can include the condition that this V#  does not indicate the flatten has been sent already so that it sends the flatten only once. Further, the trading system can include its own trading rule that checks this V# and takes an appropriate action on the next bar to keep the TSYS Indicator in sync with what the Trading Rule indicator has done.

This is an advanced  technique and there may be pitfalls as you try to get two (or more) independent indicators to cooperate. The Trading Rule indicator does not "know" that there is a Trading System at work in the chart. Both the indicators work independently but they both can reference the same V# variables and RTL tokens like TR_POS to guide their actions. Let me know if you think this may be work for you. Also keep in mind that you can have any number of Trading Rule indicators inside a chart, each one testing some signal depending on your position size. Here is a link for more information on the Trading Rule indicator (https://www.linnsoft.com/techind/trading-rule-indicator).

TraderMike
Last seen: 4 years 10 months ago
Joined: 03/26/2019 - 08:19
Trading Rule Indicator

This is very interesting Mr. Linn
I will definitely look deeper into this functionality -
This is a feature rich platform and no doubt well thought out -
As we have seen, my ability to comprehend how each piece operates by itself or in combination with other pieces takes some doing -
Again, Chad has done an immense amount of work and this platform doesn't follow the same path as others I have worked with -
This has been a eye opening discussion and has really widened my understanding of your product -
Thank you for participating, again, I believe others will benefit from this discussion
With Regards
Miike