Rank: Member
Groups: Registered, Registered Users Joined: 11/10/2008(UTC) Posts: 22
|
Seems like I have lots of oddball stuff happening... Here's another one:
I have written a model that buys a position at the CLOSE of the market under certain conditions. I have checked the output, and the System Tester is definitely triggering the buys on the right day and at the right price (i.e. at the close that day). So far so good...
When I run a simulation, the System Tester is dutifully examining Stop conditions (which I happen to have set at +8%, -4%) to trigger an early exit from the stock if my final exit conditions are not satisfied before one of the stops (gain or loss) is reached.
Here's the problem: Even though I am buying at the CLOSE, the System Tester is looking at the high and low price of the stock on that day and using them to trigger Stops! That is of course impossible, since I did not purchase the stock until the market closed! So the high and low that day are totally irrelevant.
I had assumed that the System Tester would properly figure out that I had not bought the stock until the close, so it would start looking at the high and low the NEXT day to decide if a Stop condition has been triggered. But it is clearly reacting to data on the day I enter the position, even though it's not until Close.
Any ideas how to prevent this? My profit calculations are way off, because many positions are exiting prematurely with a stop (gain or loss) before I have even bought in!
Thanks.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Unverified Users Joined: 9/13/2004(UTC) Posts: 673 Location: Salt Lake City, UT
|
When testing Daily data, you can get in at the price that is equal to the Closing Price, as your system is doing. However, there is no way to know for certain that the price you get in at is in fact the "last trade" of the day. As such, there is no way to know (with Daily data) that the High or Low price did not occur one tick prior to the last trade. Because of this, Stops are considered on the same day of the trade, even if you get in at the "Close Price".
The only way to avoid this is to not use that actual stops tab, and possibly consider using formulaic stops in the actual Buy Order / Sell Order tabs of the system.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 4/5/2006(UTC) Posts: 129 Location: Norgate Data
|
Justin wrote:When testing Daily data, you can get in at the price that is equal to the Closing Price, as your system is doing. However, there is no way to know for certain that the price you get in at is in fact the "last trade" of the day. Unless you put in a Market-On-Close order to open your position. Some markets don't have this order type, so a limit buy well above the previous price should also get you in on the final order book matching auction too. Best to check with your broker what your options are. |
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Unverified Users Joined: 9/13/2004(UTC) Posts: 673 Location: Salt Lake City, UT
|
That is a good point, though I was speaking more generally about the philosophy behind how the system tester is working. I can respect that some may not like this or would like to have the option to set stops to only work on the bar after the order is executed but unfortunately this is not the case with the stops tab.
If you would like to try and tackle the issue with a formula rather than with the Stops tab but are unsure how to write this, please feel free to email us at formulas @ equis.com with the specifics of your request, or you can see if someone here may be able to assist you with a formulaic stop as part of your Buy / Sell Order.
|
|
|
|
Rank: Member
Groups: Registered, Registered Users Joined: 11/10/2008(UTC) Posts: 22
|
Thanks for the tip. I do need a bit more help though... [:)]
I am fine to use a formula for the Stop, and in fact I have tried it now with some success. What I did was: * Clicked the Order Type in the Sell Order tab onto "Stop" * Entered a formula in "Limit or Stop Price": 1.08*ref(C,-1) (this triggers if the price increases by 8% from the prior close) * Disabled the regular Stops by setting them at 100% in the Stop tab
I ran the simulation, and it is now correctly findng the right Stop price and exiting there. So far so good...
My follow-up question: How do I enter more than one Stop condition (i.e. a Gain and a Loss)? I tried the obvious, by changing the formula in "Limit or Stop Price" to: 1.08*ref(C,-1) OR 0.96*ref(C,-1) But that is not working. I get screwy results back, showing a Stop order frequently Considered at $1 (impossible). So I must be doing something wrong in how I am writing the formula to enable BOTH a Stop Gain and a Stop Loss.
Ideas? Thanks!
|
|
|
|
Rank: Member
Groups: Registered, Registered Users Joined: 11/14/2008(UTC) Posts: 16
|
Hi Chestnut,
did you manage to solve your problem by coding?
I have a similar problem trading in mutual funds: in this market a stop HAS to be executed in the next day but seems that System Tester is not done to consider this case...
Bi[censored]>
|
|
|
|
Rank: Member
Groups: Registered, Registered Users Joined: 11/10/2008(UTC) Posts: 22
|
Hi Bisto -
Sorry for the slow reply; I was gone for the holiday...
Yes, I did get this working! Here is what I did:
In the System Tester under the "Sell Order" tab, I clicked on "Stop" as the Order Type and entered a formula like: 0.95 * ref(C, -1).
This tells it to Stop out if the price falls 5% below the prior day's close. And then I left the values in the "Stops" tab alone (left them at 100%). That solved my problem.
Hope it helps,
Chestnut
|
|
|
|
Rank: Member
Groups: Registered, Registered Users Joined: 11/14/2008(UTC) Posts: 16
|
Thanks for your answer Chestnut,
I tried your suggestion but I am not very happy of this because it seems that writing a formula in the "Limit or stop price" field associated with a
|
|
|
|
Rank: Member
Groups: Registered, Registered Users Joined: 11/14/2008(UTC) Posts: 16
|
Thanks for your answer Chestnut,
I tried your suggestion but I
am not very happy of this because it seems that writing a formula in
the "Limit or stop price" field associated with a Stop order type let me to place an order stopped to a price (defined by this formula) with a timing defined ONLY by the Formula field (the big one) that, of course, ignores that I would like to place the order IF something of bad is happening...
I hope that my english explanation is sufficient...
Maybe my problem is slightly different from yours, I managed to solve it choosing a market order (the only one possible trading mutual funds) wrinting in the Formula field something as the follow
TRADE RULE or STOP CONDITION
like this simple didactic example:
Cross(Mov(C,40,E),Mov(C,12,E)) or C < ref(C, -1)
Am I fully satisfied of this? Almost... now the problem is:
"How I can write a formula using the profit of my actual trade?"
C in a formula is Close but I bet that P isn't Profit :-)
My actual target is to simulate a trailing stop
|
|
|
|
Rank: Member
Groups: Registered, Registered Users Joined: 11/14/2008(UTC) Posts: 16
|
Today I did a (hope) big step in the right direction "discovering" the simulation functions that seem very useful for my target but there is a problem. if I write the following in the "Sell order" formula field:
Cross(Mov(C,40,E),Mov(C,12,E))
OR
ref(Simulation.CurrentPositionProfit,-1) > 100000000
the system tester behaviour seems inconsistent, it's clear that the second condition is never true but the simulation consider as I wrote an AND insted of the OR and it doesn't sell!
If I write:
Cross(Mov(C,40,E),Mov(C,12,E))
OR
Simulation.CurrentPositionProfit > 100000000
everything is OK and the system tester sells when it has
It seems that to use the ref() formula with Simulation.CurrentPositionProfit produces a mess with a strange evaluation even of the OR operator! I found very little about simulation functions both in Formula primer and in ms manual, do you have an idea?
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.