Originally Posted by
;
All,
I've made some ammendments to Comokes work to now contain the trailing stop, and from what I could see (on Euro Futures for 2005), it appears to be a nice egy since tkimble has been stating. This is tested without money management that can improve it since tkimble has stated.
My backtest confirmed everything he's been saying, and the drawdown seems to match me anyway.
Of course, that really is my data that it's been tested on, and want input from anyone out there to see how they get on together with the code. (e-sig of course), and in different markets.
Tkimble - I hope this helps, I will of course add/change items within this code, and will be happy to. But thanks for your information up to now.
If anyone can find fault in my logic, please shout, nobody is infallable.
Its beneath, I've used tkimbles revised rules for keeping out of a number of those whip:
var nStop=0;
function preMain()
setPriceStudy(true);
setColorPriceBars(true);
setStudyTitle(forum);
setShowTitleParameters(false);
var nStop = 0;
var nLimit = 0;
var nStopDiff = 0.005;
var nLimitDiff = 0.02;
var tickDiff = 0.0005;
function main()
//if in one not , enter a long trade
if(! Strategy.isLong())
if(close() gt; (sma(9, high()) tickDiff) rsi(45) gt; 50 )
Strategy.doLong(Going Long, Strategy.MARKET, Strategy.NEXTBAR, Strategy.DEFAULT);
nLimit = close() (nLimitDiff);
nStop = close(-1) - (nStopDiff);
//if not in one , enter a short trade
if(! Strategy.isShort())
if(close() lt; (sma(9, low()) - tickDiff) rsi(45)lt; 50 )
Strategy.doShort(Going Shortterm, Strategy.MARKET, Strategy.NEXTBAR, Strategy.DEFAULT);
nLimit = close() - (nLimitDiff);
nStop = close(-1) (nStopDiff);
//set the bar colors - green for long, red for short, black for neutral
if (Strategy.isInTrade())
if(Strategy.isLong())
if (close(-2)lt;close(-1))
nStop = (close(-1)-close(-2));
setBarBgColor(Color.teal)
setPriceBarColor(Color.lime);
if (close()lt; nStop)
Strategy.doSell(Close Extended Cease, Strategy.STOP, Strategy.THISBAR, Strategy.ALL, nStop);
if (close() gt; nLimit)
Strategy.doSell(Close Extended Goal, Strategy.LIMIT, Strategy.THISBAR, Strategy.ALL, nLimit);
if(Strategy.isShort())
if (close(-2)gt;close(-1))
nStop -= (close(-2)-close(-1));
setPriceBarColor(Color.red);
setBarBgColor(Color.lightgrey);
if (close()gt; nStop)
Strategy.doCover(Close Short Stop, Strategy.STOP, Strategy.THISBAR, Strategy.ALL, nStop);
if (close() lt; nLimit)
Strategy.doCover(Close Short Goal, Strategy.LIMIT, Strategy.THISBAR, Strategy.ALL, nLimit);
return 0;