PDA

View Full Version : Simultaneous breech of Initial Stop and Exit Trigger


jacche
5th May 2004, 01:46 PM
Hi David,

Help, I don;t know if its a bug in my code or just the way the system works. I noticed whenever an exit trigger and initial stop is breeched simultaneously (on the same day) TS records it as a "Stopped Out" trade with the initial stop price as exit price [rather than using my exit trigger and exit price which i was expecting]. Is there a way to indicate my preference (the exit trigger over initial stop) to TS so that my result more accurately reflects what i need ?

I recall reading somewhere previously that TS treats this in a certain way but am unable to find that note in the forum. I am using version 3.0.0 Build 654. Your advise much apprec.

Many thanks in advance
Jack

p/s my exit code and initial stop:

ShortExitTrigger := H > Ref(HHV(H,6),-1);
ShortExitPrice :=
If(Ref(HHV(H,6),-1)+0.01<O,O,Ref(HHV(H,6),-1)+0.01);
ShortExitPrice := If(ShortExitPrice>H,H,ShortExitPrice);

ShortInitialStop := Ref(HHV(H,3),-1);

ExtFml("TradeSim.Initialize");
ExtFml("TradeSim.SetStartRecordDate",1,1,1998);
ExtFml("TradeSim.SetStopRecordDate",31,3,2004);
ExtFml("TradeSim.EnableDelayOfEntryByOneBar");
ExtFml("TradeSim.EnableProtectiveStop",0);
ExtFml("TradeSim.SetExitPriceToInitialStop");
ExtFml("TradeSim.SetStopGapPriceToOpen");

ExtFml("TradeSim.RecordTrades",
......

David Samborsky
6th May 2004, 10:58 AM
The stop always has priority for obvious reasons because in many cases you may want to exit immediately rather than wait for the end of day exit trigger.

There are many ways you can control the price at which a trade exits due to a breach of the stop.

If you are using the latest TradeSim.dll V4.2.2 then you have the following additional control mechanism.

* The SetStopGapPriceToOpen function no longer has any effect. If Protective Stops are enabled and the InitialSop is breached then stops are handled according to the following pseudo code (long side example)


If UseClosePriceAsThreshold then

ExitPrice=Close

else

if Open < InitialStop then

ExitPrice = Open

else

if ExitAtStop then

ExitPrice = InitialStop

else

ExitPrice = UserExitPrice

jacche
6th May 2004, 09:34 PM
David,

Thanks for the quick response. While 4.2.2 will be something i consider eventually, my current scenario is one where the exit trigger happens before the initial stop is breeched hence i would like the system to reflect this rather than the initial stop taking precedence (when both coincide).

How can I effect that in the current version if that is possible ?

many thanks
jack

David Samborsky
7th May 2004, 12:53 AM
By definition the exit trigger is only valid at the end of the day so always occurs after the initial stop which for the long side is triggered when the low of the day is breached by the InitialStop.

Also note that by default even if both are triggered on the same bar the trades will exit at the price specified by the ExitPrice parameter, so as far as the simulation is concerned both exits are identical except that one is tagged with "Protective Stop" whilst the other is tagged with "Normal Exit".

jacche
9th May 2004, 03:33 AM
THanks David for the response. I have closely verified my data again and it is as I indicated earlier.

I am not sure I fully understand your statement. While you say that Tradesim treats initial stop and exit trigger as similar if they coincide but from my data it appears that it always uses the initial stop's price (which i don;t want it to do) rather than the exit price (of trigger as you mentioned). Using the initial stop's price will always reflect a greater "loss" than if it had taken the trailing stop;s price.

Any advise or perhaps I need to use the newer version ?

thanks and rgds
jack

sectorbets
9th May 2004, 12:00 PM
Just for the record, I have religously upgraded to all beta versions and new DLL versions without a hitch, and strongly recommend that you do the same--there is no reason to hold back, and david graciously offers all upgrades no charge.

sectorbets
9th May 2004, 12:00 PM
Just for the record, I have religously upgraded to all beta versions and new DLL versions without a hitch, and strongly recommend that you do the same--there is no reason to hold back, and david graciously offers all upgrades no charge.

David Samborsky
10th May 2004, 01:16 AM
If you want the stop to exit at a price specified by the ExitPrice parameter then you should remove the following lines:-

ExtFml("TradeSim.SetExitPriceToInitialStop");
ExtFml("TradeSim.SetStopGapPriceToOpen");

jacche
10th May 2004, 04:46 AM
okey doke.

thanks sectorbets and david for your suggestions. will look at the upgrade - just naturally cautious in not doing an upgrade in the middle of testing.

many thanks again.
jack

David Samborsky
10th May 2004, 12:12 PM
As well as enhancements the upgrades usually contain bugfixes that are found by ourselves or reported by other users.

It would be advisable to view the readme file for an up to date revision list
http://www.compuvision.com.au/TradeSimReadme.htm