BarsSince entry |
Post Reply |
Author | |
pipsqueek
Regular Joined: 03 Jan 2005 Location: Australia Posts: 34 |
Post Options
Quote Reply
Topic: BarsSince entry Posted: 04 Jun 2005 at 1:27pm |
Hi Peter How do I get Tradesim to calculate the number of bars since a trade entry was generated? I've had a prowl around the compuvsion TS forum and notice that Jose Silva used this code for Metastock In:=Fml("001 system buy signals"); BarsSince(In) Bullchart's TS won't recognise the formula for "In", but probably has something similar that will work, I hope. I want to be able to calculate the %price change over the first 5 bars since entry, and exit if this % fails to meet my expectations. This is NOT the same thing as the profit stop on the stops tab, which will certainly get me out if the %profit fails to materialise within 5 bars, but also gets me out as soon as the profit% is reached. Not at all what I want! I think I could do this if I could count how many bars since a tradesim entry. Any ideas, Peter?
|
|
failing to plan is planning to fail.
|
|
Peter
BullCharts Staff Joined: 09 Sep 2004 Location: Australia Posts: 241 |
Post Options Quote Reply Posted: 06 Jun 2005 at 10:26am |
This can be (sort of) achieved with EntryTrigger. You need ver 2.5.3 to
have access to EntryTrigger. Unfortunately the BullScript help doesn't
include EntryTrigger. (my oops.. forgot to copy the file in at the time
it was released)
First, a side note on the example you provided. "In" isn't part of tradesim or metastock. The reason "In" works in line two of your example, is because it's defned in line 1. EntryTrigger returns true on days when your entry criteria evaluate to true. So you can use BarsSince(EntryTrigger). There is also an EntryPrice function, which returns your entry price on the last day that EntryTrigger trigger was true - and in your case, you may find this easier. Note: EntryPrice and EntryTrigger can only be used when calculating ExitPrice and ExitTrigger. They're actually pseudo functions that get converted into other BullScript code. To understand them better, try using them, then use the "Generate Script" button on the advanced tab to see how they've been converted. There is one important cavet. EntryTrigger is true on days where your entry criteria are matched. But that isn't necessarily the same as the days you have entered. Eg, if your entry criteria are met, but you are already in a trade (and do not have pyramiding turned on) then EntryTrigger will return true even though a new position is not being opened. Unfortunately this is something which we probably can't change because of the way TradeSim works, which in turn probably can't change because of the way Metastock works. But on the other hand, it would be a limitation of your Metastock example above as well. C'est la vie. Remember: ver 2.5.3 only. |
|
pipsqueek
Regular Joined: 03 Jan 2005 Location: Australia Posts: 34 |
Post Options Quote Reply Posted: 06 Jun 2005 at 10:39am |
Thanks for that Peter, I'll have a fiddle with EntryTrigger and EntryPrice and see how I go. Your comments on their use are duly noted and much appreciated. |
|
failing to plan is planning to fail.
|
|
pipsqueek
Regular Joined: 03 Jan 2005 Location: Australia Posts: 34 |
Post Options Quote Reply Posted: 06 Jun 2005 at 1:34pm |
This is GREAT. Going by the fiddling I've done so far, the BarsSince(EntryTrigger) and EntryPrice is going to do what I want. Many thanks, Peter |
|
failing to plan is planning to fail.
|
|
Post Reply |
Forum Jump | Forum Permissions 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 |