View Full Version : Ability to turn a system on and off.
tech/a
11th February 2007, 09:32 AM
David.
Id like to be able to turn a whole portfolio off at a point---selling it all out at that points price---then buy back in at a price the whole portfolio at the price of each stock at that point of time.
Simply turning off a Long System at a defined analysis of a Bear market then crank it up again when analysis defines a return to a bull market.
davidjc01
20th March 2007, 11:56 PM
David,
This is a good idea. For example when it is clear that the market as a whole is in a Bear Phase it would be good to be able to exit all trades on a certain date and then start to re-enter later when the market starts to enter a Bull Phase again. Or alternatively, rather than Exit All on a certain date, just stop Entering from that date onwards until the Bear Phase is over.
At present I do this by checking and unchecking trades between certain dates, but (i) I can't save that file and (ii) I can't Exit All at that date, I can only stop Entering.
Over to you.
Regards, David
Paradox
23rd August 2008, 02:17 AM
Hi Guys
I to just thought about this idea. While testing systems I can get a nice steady equity curve, but I always loose more then I'd like during a bear market. IE, like the one we've been experiencing since early 2008 (I think).
Does anyone know the code required to EG, Only enter trades when a particular index is above it's 200day Moving average.
IE, can you when creating an Explorer tradedatabase refer to a specific stock "XAO" All Ords just like you would filter out overly volatile stocks, etc.
EG, IF "XAO" Close >= 200day "XAO" SMA AND ............
oztrader
24th August 2008, 01:59 AM
Paradox,
If you are using MetaStock then try including the following in your EntryConditions:-
Security("C:\Shares\Au-ASX\X\XAO",C)>Security("C:\Shares\Au-ASX\X\XAO",Mov(C,200,S))
Depending on your data provider you may need to alter this part of the code to locate your XAO data "C:\Shares\Au-ASX\X\XAO".
If you want to shut down a system completely given certain circumstances then I think you would need to include some code in your ExitConditions along the lines that if the close of the XAO < say a 100SMA[close] of the XAO then sell all open positions.
oz
adrian77
25th August 2008, 02:40 AM
oztrader / Paradox,
I have found some problems using this code in the past - if you are trading a stock which does not have a price bar every day then your market filter will not produce a valid result because the security function does not match up the price bars between the stock and the index you are calling with the security function unless both instruments have a price bar every day.
For example, if your stock is put on trading holt for a couple of days / weeks and doesn't trade, then you will find that the code doesn't work properly. Most of the time it is not a problem, but i have found numerous examples in my trade databases when a trade was generated that shouldn't have been or where a trade was not generated that should have been generated.
One way around the problem might be to look at the index chart first using your bull / bear market filter and use the date ranges that your filter keeps you out of the market as part of your entry rules.
I am interested if anyone else has found this problem with the Security() function and what they did to get around it.
Adrian
davidjc01
25th August 2008, 12:11 PM
My solution to this one is a bit labour intensive but it does work.
I manually determine when the Bear Market begins and ends. That is, by looking at a chart of XAO and a 200MA or the like I write down the dates that the bear market starts and ends. These are the dates that I exit everything and not re-enter until the end of the Bear Market.
Then those dates are written into the Tradesim code as part of the Entry and Exit Conditions. For example:
ExitTrigger:=<YourNormalExitTrigger> OR ((Year()=2002) and (Month()=3))
... will exit all positions on the first bar of March 2002.
It works, but as I said, a bit laborious and needs some care to ensure you got it right and that what you have down is grounded in reality.
Alternatively, if you are only concerned about not entering, and are happy to let all open positions stay open through a Bear Market until they hit stop, try this... after the trade database is generated just unselect all trades that are entered during the Bear Market before running a simulation. This also works well but again you have to determine the relevant dates manually.
Hope that helps...
adrian77
26th August 2008, 10:57 AM
That's helpful - thanks. Presumably the same approach would also work for your entry rules to prevent taking any long trades once (say) the All Ords is below its 200 day MA.
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.