Rank: Newbie
Groups: Registered, Registered Users Joined: 6/6/2006(UTC) Posts: 4 Location: Isle of Man
|
Does anyone know of an easy way to get the original entry price of a trade for use with the system testing "sell to close" and "buy to cover" order rules ?
Put another way. It seems there is no easy reference to the entry price of trades executed when writing system testing using Metastock formula language.
For example it is not possible to write an exit formula with reference to the entry price of the trade.......... unless you use a series of convoluted, ifs ors and value whens to calculate back to the original entry price.
I have had a go using simulation functions but they seem to grind to a halt when I backtest several hundred bars of data.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 7/25/2005(UTC) Posts: 1,042
Was thanked: 57 time(s) in 54 post(s)
|
Peter
Another alternative is to use the PREV function and create a latch that "remembers" the entry bar and price. For this approach you might need to code both Buy and Sell as indicator formulas and call these formulas with Fml() in the appropriate windows. Or, you might just call the Buy formula for the Sell window, or place the Buy formula directly in the Sell window (as well as in the Buy window).
The fact is that there's no easy way to accurately track the entry price, and PREV or Simulation are the only options available. Without one of these functions it's impossible to know if the Buy signal being referenced for price is the original signal or a secondary one. Your convoluted series of If's OR's and ValueWhen's just won't do the job properly.
Using PREV functions in a system test will slow things down too, but rarely as much as Simulation. If you're not familiar with creating and using a PREV-based latch then this might be a useful exercise to work through. Past issues of MSTT have discussed both simple and PREV latches and I can send you these articles if you write to me at rlarsen@man.quik.co.nz .
Roy
MetaStock Tips & Tools
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
Roy,
As you know I am not one for mechanical trading, but, couldn't Mark's GV.dll come into play here? Store the entry price as a variable from the Buy side of the Enhanced System Tester and then read that variable from the Sell side of the EST?
Just a thought?
wabbit :D
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 7/25/2005(UTC) Posts: 1,042
Was thanked: 57 time(s) in 54 post(s)
|
Hi Wabbit
A simple latch, such as the Forum DLL "Latch" function, could "remember" the entry point if Buy and Sell were independant formulas. However, the reason for remembering the Buy price is usually so that a Sell can be based on it. I don't know of any way other than by using PREV or Simulation to remember Buy parameters on which the Sell depends.
The GV dll could certainly have a use in passing data from the Buy to Sell windows, but I don't see it helping where remembering the entry price is necessary, because the Sell depends on that aspect of the Buy (I'm assuming that's why Peter needs to remember the Buy price).
A GV value is subect to the same limitations as ValueWhen() when there's a possibility of secondary signals. PREV and Simulation are the only functions that can lock in the first entry signal/price (with appropriate coding) and not change values when a second or third entry signal is given prior to the exit, and at the same time make the Buy price (or whatever) available for determining a Sell.
For independant Buy and Sell signals a simple latch can be used to remember almost any entry-related value, but a PREV latch or the appropriate Simulation function is essential when the exit has to reference the entry price.
Roy
MetaStock Tips & Tools
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
Comprehensive reposnse as always Roy. Thanks. I might look at this problem for some specialised coding at some time in the future.
Cheers
wabbit :D
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 6/6/2006(UTC) Posts: 4 Location: Isle of Man
|
thanks for all your input.
Its not the answer I was hoping for. Programming a latch is what I was wanting to avoid, it is possible, but becomes extremely involved if you get multiple entry triggers after a buy signal is generated and where you have more than one exit option based around that buy price and where you want multiple trades.
I will post on the product wishlist to have the entry price of trades available for use in the system tester.
|
|
|
|
Rank: Member
Groups: Registered, Registered Users Joined: 3/19/2012(UTC) Posts: 13
|
Had to resurrect this old dead thread to make a point. Isn't it funny that 7 years later, there is still no easy way to do this! Many trades or stops are based around the bar of entry, whether it be the OHLC. This is all end of day data that SHOULD be easily referenced in Metastock eg. EntryBarOpen, EntryBarHigh, etc.
We shouldn't have to try to program convoluted latches to overcome shortcomings of the software. Now that MS is not owned by Reuters, perhaps the attention will come around to what is best for the paying clients as opposed to what was best for Reuter's institutional clients.
Please MS programmers, build these simple values in...it can't be that hard.
|
|
|
|
Rank: Newbie
Groups: Joined: 8/20/2014(UTC) Posts: 2
|
Warmuth327 wrote:Had to resurrect this old dead thread to make a point. Isn't it funny that 7 years later, there is still no easy way to do this! Many trades or stops are based around the bar of entry, whether it be the OHLC. This is all end of day data that SHOULD be easily referenced in Metastock eg. EntryBarOpen, EntryBarHigh, etc.
We shouldn't have to try to program convoluted latches to overcome shortcomings of the software. Now that MS is not owned by Reuters, perhaps the attention will come around to what is best for the paying clients as opposed to what was best for Reuter's institutional clients.
Please MS programmers, build these simple values in...it can't be that hard.
Hello to all and Warmuth327 in special.
This is my first post in this community. I am an experienced programmer with over 30 years in the programming area, but I'm newbie in MetaStock. I really thought it would be easier, and I feel frustrated to have purchased the MS13 EOD and the lack of information available. I'm trying for weeks to write the setups that use the System Tester, but with great difficulty, especially for the problem mentioned in this post. My setups are based on features of candlestick entry and the entry price. It would be very interesting that MS had functions as EntryBarOpen, EntryBarHigh. Exactly what I need! I'm currently using the formula below with no success, however I can not locate the values of entry candle, since after the entry performed by System Tester, other input signals appear before the sale is made.
EntryBarHigh: ValueWhen = (1, fml ("@ EntryFormula"), H);
Can someone please tell me how to find the entry candlestick? Cheers !
|
|
|
|
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.