PDA

View Full Version : Double exit


gsandral
16th August 2005, 07:37 AM
Hi Jose or David,

Re: Intra day exits

Could you please consider the following?

1. End of day exits- If either condition is met then exit on the open of the next day - I have delayed bars ExtFml set.

LongExitTrigger:= ExtFml("TradeSim.TrailingStop",Trigger,long, 3*ATR(15),H,C)
OR C<=Ref(ExtFml("TradeSim.TrailingStop",band,long,0,LLV(L,6),C),-1);
LongExitPrice := O;

I’m assuming this code is correct as I have not picked up any errors, but your expert eye my pick up something I am unaware of?

2. The real problem is I wish to convert this code to intra day exits based on the low rather than the close. The tricky bit for me is the code needs to allow for gap downs and where this occurs the exit is the open on the next day.

Any ideas?

Regards Graeme :?

Jose
28th August 2005, 03:59 PM
1. End of day exits- If either condition is met then exit on the open of the next day - I have delayed bars ExtFml set.
Try delaying your exit with a simple Ref(signal,-1) MS function to avoid any possible confusion.

Also plot the exit signals (condition1 & condition2 separately) to see if they are actually doing what you need them to do. Looking at the code, I can see that condition2 would cover 95% or so of the condition1 signals.
&#123; Variables &#125;
ATRpds&#58;=15;
ATRmulti&#58;=3;
LLVpds&#58;=6;

&#123; Exit conditions &#125;
cond1&#58;=ExtFml&#40;"TradeSim.TrailingStop",
Trigger,long,ATRmulti*ATR&#40;ATRpds&#41;,H,C&#41;;
cond2&#58;=C<=Ref&#40;ExtFml&#40;"TradeSim.TrailingStop",
band,long,0,LLV&#40;L,LLVpds&#41;,C&#41;,-1&#41;;

LongExitTrigger&#58;=Ref&#40;cond1 OR cond2,-1&#41;;
LongExitPrice&#58;=O;

&#123; Plot cond 1 & 2 signals in own window &#125;
Ref&#40;cond1*1.5,-1&#41;;Ref&#40;cond2,-1&#41;;
&#123;LongExitTrigger&#125;


2. The real problem is I wish to convert this code to intra day exits based on the low rather than the close. The tricky bit for me is the code needs to allow for gap downs and where this occurs the exit is the open on the next day.
Any ideas?
Intraday exits based on the low of...?
If I understand your dilemma correctly, you will always have to exit your trade on the open of the next day, since the true low of the day cannot be known until the close of that day.


jose '-)

reyes
19th October 2005, 01:49 PM
Hi, Sorry for my ignorance but in the last part of the forumla a "0" is used where volatility would normally be. Is the zero used to pad this location when not used?

Also I am curios about the use of ref with the exit (and again sorry for my fumbling). If I stripped out the second condition altogether and just had the trailing ATR stop there were no valid trades recorded. Once I got rid of the ref I got signals and therefore valid trades. Is there a reason the ref was used?

Thanks in advance

Rob

Jose
20th October 2005, 08:40 PM
The Ref(x,-1) is there because the code uses intraday data not available until the end of day. Taking a signal when it is not yet available is one of the biggest source of backtesting errors.

jose '-)