- Joined
- 14 June 2007
- Posts
- 1,130
- Reactions
- 3
Good one. Bet you learnt something more valuable than reading your next book?
If a system fails badly consider flipping it - long when short. It may be a winner. Like a couple suggested
(short=buy and cover=sell)
You might want to check your logic. I coded it for MS (had to make a few tweaks in translation ) and backtested it in Tradesim on the ASX50. Well over half the trades, and all of them on the Long side, enter and exit on the same day.eg Long NAB 12/5/08 - Close NAB 12/5/08.
very interesting thread leaves a lot to think about
should any trading system be adjusted to take the current trend into account
as mentioned above a flip around would have resulted in quite a profit
should any trading system be adjusted to take the current trend into account
"What have I done wrong?"
very interesting thread leaves a lot to think about
should any trading system be adjusted to take the current trend into account
as mentioned above a flip around would have resulted in quite a profit
What have I done wrong
Sell = LLV(spread,15) AND V>1.5*Y AND C>mid AND HHV(C,90);
Convert to something like
Sell = spread <= LLV(spread, 15) AND ... AND C >= HHV(C,90);
(Dont know if you want comparisons relative to prev. day. For example:
C > Ref(HHV(C,90), -1)
But, they might get to out at the beginning of the trend, rather that riding the trend. Depends on what you are trying to do.)
Tim
/*Variables*/
/***********/
y=MA(Volume,10); /*Formula for Average Volume*/
spread= H-L; /*Size of the spread*/
mid = L + spread/2; /*The midpoint of a bar*/
/*Going Long*/
/************/
[B]/*Buy Condition: Three consecutive up-thrust days with successively increasing volume*/[/B]
Buy = Ref(C,-2)<Ref(C,-1) AND Ref(C,-1)<C AND Ref(C,-2)<C AND Ref(V,-2)<Ref(V,-1) AND Ref(V,-1)<V AND Ref(V,-2)<V;
/*Sell Condition #1: Three days where the close is sideways (+/- 5% of each other) and volume is successively decling but larger than average for the first two days*/
/*Sell = (Ref(C,-2)<1.025*Ref(C,-1) AND Ref(C,-2)>0.975*Ref(C,-1)) AND (Ref(C,-2)<1.025*C AND Ref(C,-2)>0.975*C) AND (Ref(C,-1)<1.025*C AND Ref(C,-1)>0.975*C);*/
[B]/*Sell Condition #2: Sell on the bar with the smallest spread for the past 15 days, above average volume and a close towards the high with the bar in an uptrend.*/[/B]
Sell = spread<=LLV(spread,15) AND V>Y AND C>mid AND C>=HHV(C,5);
/*Going Short*/
/*Short = Ref(C,-2)>Ref(C,-1) AND Ref(C,-1)>C AND Ref(C,-2)>C AND Ref(V,-2)<Ref(V,-1) AND Ref(V,-1)<V AND Ref(V,-2)<V;
Cover = ApplyStop(stopTypeTrailing, stopModePercent, 2,0) ;*/
Some more reading needed.
I think you'll also find that your entries and exits are also on the same day as they are triggered. unless you have a way of exiting intraday(And how do you know the final bar type untill close?) you should have both set at buy or sell delay of 1 bar as most EOD systems signal at the close of the day. This can dramatically alter the result of a system.
Another observation is that none of your sell signals conform to the condition
'Highest close in the last 90 days".
Flipping entry to exit and V versa is poor logic.
/*Variables*/
/***********/
W= Param("Number of bars to compare low (for Covering)", 5, 0, 100); /*The number of previous bars today's close will be compared to*/
X= Param("Number of bars to compare high (for Selling)", 5, 0, 100); /*The number of previous bars today's close will be compared to*/
Y=MA(Volume,10); /*Formula for Average Volume*/
Z= Param("Number of bars to compare size of spread", 15, 0, 100); /*The number of previous bars today's spread will be compared to*/
spread= H-L; /*Size of the spread*/
mid = L + spread/2; /*The midpoint of a bar*/
/*Going Long*/
/************/
/*Buy Condition: Three consecutive up-thrust days with successively increasing volume*/
Buy = Ref(C,-2)<Ref(C,-1) AND Ref(C,-1)<C AND Ref(C,-2)<C AND Ref(V,-2)<Ref(V,-1) AND Ref(V,-1)<V AND Ref(V,-2)<V;
/*Sell Condition #1: Three days where the close is sideways (+/- 5% of each other) and volume is successively decling but larger than average for the first two days*/
/*Sell = (Ref(C,-2)<1.025*Ref(C,-1) AND Ref(C,-2)>0.975*Ref(C,-1)) AND (Ref(C,-2)<1.025*C AND Ref(C,-2)>0.975*C) AND (Ref(C,-1)<1.025*C AND Ref(C,-1)>0.975*C);*/
/*Sell Condition #2: Sell on the bar with the smallest spread for the past 15 days, above average volume and a close towards the high with the bar in an uptrend.*/
Sell = spread<=LLV(spread,Z) AND V>Y AND C>mid AND C>=HHV(C,X);
/*Going Short*/
/*************/
/*Short Condition: Three consecutive down-thrust days with successively increasing volume*/
Short = Ref(C,-2)>Ref(C,-1) AND Ref(C,-1)>C AND Ref(C,-2)>C AND Ref(V,-2)<Ref(V,-1) AND Ref(V,-1)<V AND Ref(V,-2)<V;
/*Cover Condition: Cover on bar with lowest close for X period, above average volume, small spread and with a close towards the low*/
Cover = spread<=LLV(spread, Z) AND V>Y AND C<mid AND C<=HHV(C,X);
/*Variables*/
/***********/
T= SetOption("InitialEquity", 7500); /*Your starting capital*/
U= Param("What % of your capital are you willing to risk?", 1, 0, 100); /*The % of capital that is going to be risked per trade*/
W= Param("Number of bars to compare lowest close (for Covering)", 5, 0, 100); /*The number of previous bars today's close will be compared to*/
X= Param("Number of bars to compare highest close (for Selling)", 5, 0, 100); /*The number of previous bars today's close will be compared to*/
Y= MA(Volume,10); /*Formula for Average Volume*/
Z= Param("Number of bars to compare size of spread", 15, 0, 100); /*The number of previous bars today's spread will be compared to*/
risk= (U/100)*T; /*The $ value that is going to be risked per trade*/
spread= H-L; /*Size of the spread*/
mid= L + spread/2; /*The midpoint of a bar*/
/*Going Long*/
/************/
/*Buy Condition: Three consecutive up-thrust days with successively increasing volume*/
Buy = Ref(C,-2)<Ref(C,-1) AND Ref(C,-1)<C AND Ref(C,-2)<C AND Ref(V,-2)<Ref(V,-1) AND Ref(V,-1)<V AND Ref(V,-2)<V;
/*Sell Condition #1: Three days where the close is sideways (+/- 5% of each other) and volume is successively decling but larger than average for the first two days*/
/*Sell = (Ref(C,-2)<1.025*Ref(C,-1) AND Ref(C,-2)>0.975*Ref(C,-1)) AND (Ref(C,-2)<1.025*C AND Ref(C,-2)>0.975*C) AND (Ref(C,-1)<1.025*C AND Ref(C,-1)>0.975*C);*/
/*Sell Condition #2: Sell on the bar with the smallest spread for the past 15 days, above average volume and a close towards the high with the bar in an uptrend.*/
Sell = spread<=LLV(spread,Z) AND V>Y AND C>mid AND C>=HHV(C,X);
/*Going Short*/
/*************/
/*Short Condition: Three consecutive down-thrust days with successively increasing volume*/
Short = Ref(C,-2)>Ref(C,-1) AND Ref(C,-1)>C AND Ref(C,-2)>C AND Ref(V,-2)<Ref(V,-1) AND Ref(V,-1)<V AND Ref(V,-2)<V;
/*Cover Condition: Cover on bar with lowest close for X period, above average volume, small spread and with a close towards the low*/
Cover = spread<=LLV(spread, Z) AND V>Y AND C<mid AND C<=LLV(C,X);
/*Timing the Trades*/
/*******************/
SetTradeDelays(1,1,1,1);
BuyPrice = Open;
SellPrice = Open;
ShortPrice = Open;
CoverPrice = Open;
/*Stop Losses & Position Size*/
/*****************************/
ApplyStop(0,2,Ref(C,-1),1); /*Apply a static stop loss at yesterday's close. If triggered, exit intraday*/
ApplyStop(2,2,Ref(mid,-1),1); /*Apply a trailing stop at the middle of the previous bar. If triggered, exit intraday*/
PositionSize = risk/(C-Ref(C,-1))*BuyPrice; /*The position size*/
SetOption("MaxOpenPositions", Optimize("MaxOpenPositions", 3, 1, 10, 1)); /*The maximum number of trades open at any one time. Optimizing.*/
Good Luck
Offtopic: Is it true that if i am ages under 21 years i can start an IB account with just 3,000 USD? This is good news!
Do they enforce the 100 trade rule?
Where did you find this information?
Thanks!
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?