I'm trying to add to my script, a circuit breaker that will shut down auto-trading for a set period of time (say 5 minutes) if price moves too quickly. An example of this would be a few weeks ago when Treasury futures spiked about 4 points in the matter of minutes.
What is making it difficult for me to figure out is I am using IOG=True mode. So I can't reference prior closes very well. By that I mean the last 20 closes in a fast moving market could actually have the same exact price. If I was not using IOG mode then I could reference bar closes and actually get the close of a bar.
I am using one minute bars and am trying to define an extreme move when price moves more than 2 ticks in that one minute timeframe. I was going to possibly add another script that is set to IOG=False but that involves global variables and I can't find much on using them. And I would prefer to stay with one script. I was curious if anyone has approached anything like this and if so would be willing to share a suggestion or two.
Thank You -
Tony
Stop trading circuit breaker for fast moving markets
Re: Stop trading circuit breaker for fast moving markets
It won't work. Many future products trade where "close" is the same price. So in the case of IOG=true, close and close[n] could easily be the same. In the case of bond futures you could have 20 "closes" where price never changes. Or you could have 2 "closes" where price moves 2 ticks. So you can't reference close[n] relative to close to accomplish what I want to do.
-
- Posts: 8
- Joined: 03 Jan 2014
- Has thanked: 2 times
- Been thanked: 1 time
Re: Stop trading circuit breaker for fast moving markets
Hey Tony, here's my .02 FWIW.
Again, this is just from my own strategy analysis and observations of "fast" moving markets.
A smaller TF chart is "speed dependent" for all affairs.
CPU, internet, everything,......So I will assume you have a really fast internet and CPU at the very least for processing, etc.
Sometimes you will get "jumped" as in the case of trading CL contracts, that is just the nature of that instrument.
I have implemented volatility rules in some of my systems as a way to monitor the "sea" I find my little strategy boat in.
I also stay out during announcement(s) I know are coming,..keeps it simple.
I wrote a code which is based on a day value so if I check a calendar, and see that Wednesday is a big news day coming up, I input a (3) in the variable to eliminate the day.
A time base rule can also be used in place of that, ie: if time =>12:15 et, the, no trades.
I swing trade so I may be speaking out of turn here, but maybe you could implement something that could be that sort of filter.
I remember seeing my account May 6, 2010 during the flash crash.
At one point it showed my account having $20 Million in it.
I can promise you, I didn't have $20 Million in it.
I have found keeping it simple is a really consistent way of going. There are many moving parts in what we do,...
Cheers,
Steve
It will depend on which instrument you are trading, and the velocity of the unexpected moves.
Again, this is just from my own strategy analysis and observations of "fast" moving markets.
A smaller TF chart is "speed dependent" for all affairs.
CPU, internet, everything,......So I will assume you have a really fast internet and CPU at the very least for processing, etc.
Sometimes you will get "jumped" as in the case of trading CL contracts, that is just the nature of that instrument.
I have implemented volatility rules in some of my systems as a way to monitor the "sea" I find my little strategy boat in.
I also stay out during announcement(s) I know are coming,..keeps it simple.
I wrote a code which is based on a day value so if I check a calendar, and see that Wednesday is a big news day coming up, I input a (3) in the variable to eliminate the day.
A time base rule can also be used in place of that, ie: if time =>12:15 et, the, no trades.
I swing trade so I may be speaking out of turn here, but maybe you could implement something that could be that sort of filter.
I remember seeing my account May 6, 2010 during the flash crash.
At one point it showed my account having $20 Million in it.
I can promise you, I didn't have $20 Million in it.
I have found keeping it simple is a really consistent way of going. There are many moving parts in what we do,...
Cheers,
Steve
It will depend on which instrument you are trading, and the velocity of the unexpected moves.
Re: Stop trading circuit breaker for fast moving markets
Thanks for sharing "TBS"
I follow a similar protocol with turning off auto-trading during "events," FOMC statements, etc. With that said, today was a reminder for anyone trading interest rates to not trade when Bernanke speaks and I just happened to forget he was speaking. But fortunately I had turned the system off just prior.
As soon as he spoke, bond futures sold off fairly hard. I may or may not have been in a trade but would like to have some logic incorporated in case the instrument moves to fast as one way of hopefully staying flat.
I have incorporated a rule to not trade on a gap which in the case of ZB is simply one tick so say 12 to 14. But what I want to do is find a way to not trade when price moves 3 ticks in a one minute bar so 12 to 15 for example. Not just as an alert that something is up and to give me a chance to turn the system off, but also an indication of a strong momentum change.
I could do this using global variables and simply compare bar open and bar close on DataN but I'd prefer not to have multiple scripts working. And I can't find anything on global variables.
I follow a similar protocol with turning off auto-trading during "events," FOMC statements, etc. With that said, today was a reminder for anyone trading interest rates to not trade when Bernanke speaks and I just happened to forget he was speaking. But fortunately I had turned the system off just prior.
As soon as he spoke, bond futures sold off fairly hard. I may or may not have been in a trade but would like to have some logic incorporated in case the instrument moves to fast as one way of hopefully staying flat.
I have incorporated a rule to not trade on a gap which in the case of ZB is simply one tick so say 12 to 14. But what I want to do is find a way to not trade when price moves 3 ticks in a one minute bar so 12 to 15 for example. Not just as an alert that something is up and to give me a chance to turn the system off, but also an indication of a strong momentum change.
I could do this using global variables and simply compare bar open and bar close on DataN but I'd prefer not to have multiple scripts working. And I can't find anything on global variables.
- Smoky
- Posts: 507
- Joined: 03 Dec 2010
- Location: Thailand
- Has thanked: 97 times
- Been thanked: 115 times
Re: Stop trading circuit breaker for fast moving markets
C[1] should work just fine with IOG on.
not work ! with IOG you work on tick/tick mode and [1] reference last tick,
'close 1 bar ago ; ' reference close of last bar
Re: Stop trading circuit breaker for fast moving markets
I may be able to use bar status(n) but I'm not quite sure how. barstatus(1) = 0 is the open of the prior bar even if IOG=True (I believe) and bar status(1) = 2 is the close of the prior bar. So I need to set up a variable for each so I can calculate the difference or do some type of IFF statement. Is my thinking correct here on use of barstatus with IOG=True and if so, how should I do this.
Thank You -
Thank You -
-
- Posts: 8
- Joined: 03 Jan 2014
- Has thanked: 2 times
- Been thanked: 1 time
Re: Stop trading circuit breaker for fast moving markets
Big T,
I am thinking you just figured out your code inadvertently,......write a small script that pertains what your stated desire is.
You stipulated, "but also an indication of a strong momentum change".
You want to "not" trade during a certain event, (from what I am reading),....decide exactly "which" event is the culprit you want removed and filter just that portion, (if I am on the same page here)
Often times, I seem to overthink my problem / solution, when just the simplest of things will give the intended effect.
Think Occam's Razor?
I have my fire extinguisher handy for "flame" events
Good luck
I am thinking you just figured out your code inadvertently,......write a small script that pertains what your stated desire is.
You stipulated, "but also an indication of a strong momentum change".
You want to "not" trade during a certain event, (from what I am reading),....decide exactly "which" event is the culprit you want removed and filter just that portion, (if I am on the same page here)
Often times, I seem to overthink my problem / solution, when just the simplest of things will give the intended effect.
Think Occam's Razor?
I have my fire extinguisher handy for "flame" events
Good luck