Print Page | Close Window

BarsSince entry

Printed From: BullCharts Forum
Category: BullCharts
Forum Name: TradeSim discussion
Forum Discription: For discussions of BullCharts' integration with the TradeSim backtesting product.
URL: http://www.bullcharts.com.au/forum/forum_posts.asp?TID=228
Printed Date: 16 May 2024 at 2:01pm
Software Version: Web Wiz Forums 9.69 - http://www.webwizforums.com


Topic: BarsSince entry
Posted By: pipsqueek
Subject: BarsSince entry
Date 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.



Replies:
Posted By: Peter
Date 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.



Posted By: pipsqueek
Date 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.


Posted By: pipsqueek
Date 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.



Print Page | Close Window

Bulletin Board Software by Web Wiz Forums® version 9.69 - http://www.webwizforums.com
Copyright ©2001-2010 Web Wiz - http://www.webwiz.co.uk