PDA

View Full Version : Short Selling Coding Problem


GeeBee
6th May 2005, 08:49 AM
Hi again
Can someone please point me in the right direction with coding a short selling system, I have read through the manual and cant find an example of how to code for it.

I have a system that I have manually tested in Metastock I just need to tell Tradesim what I want?????
The code is

{Trigger} Cross(Ref(Trough(1,CLOSE,5),-1),(C))AND {CloseBelowPreviuosTrough Trigger}
{Gate 1}ATR(14)/C>0.01 AND
{Gate 2}Mov(C,21,S)*Mov(V,21,S)>150000 AND
{Gate 3}C>0.5 AND
{Gate 4 }Mov(C,60,S)<Ref(Mov(C,60,S),-20)-2.5*ATR(60)AND
{Gate 5 } V>1
I just need to be able to code the rest in,my initial stop and trailing stop are a close above the HHV(H,5),-1
I have tried renaming everything from long to short etc but metastock doenst recognise anything.

Once again any assistance is greatly appreciated

GB :?


LongExitPrice := OPEN;

LongEntryTrigger:= ExtFml("TradeSim.TrailingStop",TRIGGER,SHORT,Ref(HHV(H,5),-1),LOW,CLOSE);

LongEntryPrice := OPEN;

LongInitialStop := Ref(HHV(H,5),-1);

ExtFml( "TradeSim.Initialize");
ExtFml( "TradeSim.SetStartRecordDate",DayStart,MthStart,YearStart);
ExtFml( "TradeSim.SetStopRecordDate",DayStop,MthStop,YearStop);
ExtFml( "TradeSim.EnableDelayOfEntryByOneBar");
ExtFml( "TradeSim.EnableDelayOfAllExitsByOneBar");
ExtFml( "TradeSim.EnableProtectiveStop",0);
ExtFml( "TradeSim.UseClosingPriceAsStopThreshold");
ExtFml( "TradeSim.EnableTradePyramiding",Trigger, 0, 200);
ExtFml( "TradeSim.RecordTrades",
"CBPT", SHORT,

LongEntryTrigger,
LongEntryPrice,
LongInitialStop,
LongExitTrigger,
LongExitPrice,
Start );

Jose
6th May 2005, 06:41 PM
With all due respect, your problem continues to have nothing to do with TradeSim, and little to do with MetaStock in any case.

Piling entry condition upon entry condition in a non-visual way, and hoping to come up with reasonable entry signals, is akin to looking for a needle in a haystack in the dark.

My suggestion would be for you to break up and test all your entry conditions separately, using something like this:


&#123; EntryShortTrigger test indicator &#125;

cd1&#58;=Input&#40;"Enable condition 1&#58; &#91;1&#93;Yes, &#91;0&#93;No",0,1,1&#41;;
cd2&#58;=Input&#40;"Enable condition 2&#58; &#91;1&#93;Yes, &#91;0&#93;No",0,1,1&#41;;
cd3&#58;=Input&#40;"Enable condition 3&#58; &#91;1&#93;Yes, &#91;0&#93;No",0,1,1&#41;;
cd4&#58;=Input&#40;"Enable condition 4&#58; &#91;1&#93;Yes, &#91;0&#93;No",0,1,1&#41;;
cd5&#58;=Input&#40;"Enable condition 5&#58; &#91;1&#93;Yes, &#91;0&#93;No",0,1,1&#41;;


&#123;CloseBelowPreviuosTrough Trigger&#125;
Cond1&#58;=Cross&#40;Ref&#40;Trough&#40;1,C,5&#41;,-1&#41;,C&#41;;

&#123;Gate 1&#125;
Cond2&#58;=ATR&#40;14&#41;/C>0.01;

&#123;Gate 2&#125;
Cond3&#58;=Mov&#40;C*V,21,S&#41;>150000;

&#123;Gate 3&#125;
Cond4&#58;=C>0.5;

&#123;Gate 4 &#125;
Cond5&#58;=
Mov&#40;C,60,S&#41;<Ref&#40;Mov&#40;C,60,S&#41;,-20&#41;-2.5*ATR&#40;60&#41;;

EntryShortTrigger&#58;=
If&#40;cd1,Cond1,1&#41; AND
If&#40;cd2,Cond2,1&#41; AND
If&#40;cd3,Cond3,1&#41; AND
If&#40;cd4,Cond4,1&#41; AND
If&#40;cd5,Cond5,1&#41;;

EntryShortTrigger


Using the above MetaStock indicator, I can see that condition 5 is a potentail problem, and in combination with condition 1, it basically filters-out any chance of an entry.

jose '-)

GeeBee
7th May 2005, 09:59 AM
Thank you for your reply
I have taken your advice and tested the system over many stocks and I take your point about condition 5 maybe this could be removed or the period altered, the reason it is there is a check that the main trend is down, the system I am trying to come up with is for shorting. I could also possibly remove the price gate as well as I intend to short with CFDs from stocks in the top 200.

I don’t believe that I am just “piling entry condition upon entry condition” and hoping for a result, there is a point in what I am attempting to do.

There is first of all an entry trigger which is a close below a previous trough (there are several ways of expressing this), there is a turnover gate, in other words I want the share to have liquidity, I want the average turnover over the last 21 days to be above $X per day, and I want some volatility, in this case I want the share price to move more than 1% per day, I could probably add an upper limit to this as well.

I have purchased Tradesim in order to be able to backtest both short and long systems, so far I have only been able to test long positions as I don’t know how to tell Tradesim I want to look for short positions, the following is from a LONG explorer can you please tell me what I need to change for it to look for SHORT positions.

I would like the trailing stop and initial stop to be a close above 5 day high

LongEntryPrice := OPEN;
LongExitTrigger:= ExtFml("TradeSim.TrailingStop",TRIGGER,LONG,3.6*ATR(30),HIGH,CLOSE);
LongExitPrice := OPEN;
LongInitialStop := Ref(LLV(L,5),-1);

Thank You
GB

Jose
7th May 2005, 01:26 PM
For Shorts, try this:


ExtFml&#40;"TradeSim.RecordTrades",
"GeeBee 01 Short",
SHORT,
ShortEntryTrigger,
ShortEntryPrice,
ShortInitialStop,
ShortExitTrigger,
ShortExitPrice,
START&#41;;


jose '-)

sectorbets
8th May 2005, 02:54 PM
Actually, you are making it too complex and may never find a set of entries that work for you going down the path you are on.

Before I started using TradeSim about two years ago, I also had a trading system that was philosphically correct, and did OK in the real world, but when I broke it down to its component parts and backteseted each of them, I ended up eliminating most of the conditions and was left with a very robust system that makes money in all markets. I wouldn't be surprised that you might claim it to be naive and not exciting, but I'd rather make money than try to prove that I am philosophically correct.