So I this is the zorro translation I came up with. Took me a little while to realise I had to compare the current price close to the previous highest in the last 100 based on the way the code is set. Learning with each day. The system seems to perform well in trending markets but not post 2008.
Code:
function run()
{
set(TICKS);
StartDate = 2002;
EndDate = 2013;
BarPeriod = 1440;
LookBack = 200;
//edge trading logic
vars rHigh = series(HH(100));
vars rLow = series(LL(100));
vars Price = series(price());
vars PriceClose = series(priceClose());
vars PriceHigh = series(priceHigh());
vars PriceLow = series(priceLow());
// Pending buy order placed at the previous day High.
if(PriceClose[0]>rHigh[1] && NumOpenLong == 0){
exitShort();
Entry = PriceHigh[0];
enterLong();
}
// Pending sell order placed at the previous day High.
else if(PriceClose[0]<rLow[1]& NumOpenShort == 0){
exitLong();
Entry = PriceLow[0];
enterShort();
}
}
Code:
BackTest: PZ_ReversalTrendFollowingEA EUR/USD 2002..2013
Profit 490$ MI 4$ DD 52$ Capital 32$
Trades 11 Win 82% Avg +585.9p Bars 259
AR 136% PF 9.79 SR 0.41 UI 14.5% Error 151%
Another one to file under potential.
Re: My Take on A Mega Script
[Re: ]
#435249 01/04/1419:0501/04/1419:05
I see a bigger problem with that strategy. 11 years -> 11 trades. The strategy as presented looks like it was designed for long term stock investors. Try it on AAPL, GOOG...
Re: My Take on A Mega Script
[Re: ]
#435251 01/04/1420:1501/04/1420:15
@Acidburn. yeah, would really have caught those big moves on Apple and Google. But then again, one could lower the timeframe to 1H or 4H and add in some filters.
Re: My Take on A Mega Script
[Re: ]
#435391 01/07/1410:0001/07/1410:00
Well I am going to have to park Tsey's Analysis of Financial Time Series on the to do list. I went through the first 60 pages and I have a headache already. I will be taken time series this semester in school so might be a good idea to sit through class and work along with the book. I will therefore jump to Urban and Emilio's Trading Systems. Its a 250 page book so I should have some free time to work on more script translations.
Re: My Take on A Mega Script
[Re: ]
#437485 02/18/1411:5802/18/1411:58
I want to write a grid trading system similar to the Z5. I have been exploring trend following systems for awhile and I haven't had much luck with them. With the fundamental play on the EUR/CHF still on, might not be too much of a bad idea to put together a grid system that explores this market inefficiency. Who knows, in the process we might learn a thing or two about programming.
Re: My Take on A Mega Script
[Re: ]
#437759 02/25/1407:1902/25/1407:19
Not really. I tried different variants but they all seem to give way worse results than she keeps posting on her blog. I think she might just be faking the results.
Re: My Take on A Mega Script
[Re: ]
#437866 02/27/1415:2602/27/1415:26
Yesterday I was messing with the srategy you presented at babypips. I replaced the RSI with a highpass filter instead.
Code:
function run()
{
LookBack = 200;
Hedge = 2;
BarPeriod = 240;
StartDate = 20030101;
EndDate = 20140101;
var Threshold = 0.0;
set(PARAMETERS);
var Timecycle = optimize(5,1,10);
var Scaling = optimize(2,1,3);
var *Price = series(price());
var *LP5 = series (LowPass(Price,Timecycle));
var *LP10 = series(LowPass(Price, Timecycle*Scaling));
Trail = optimize(50,25,100)*PIP;
Stop = optimize(4,2,6) *ATR(30);
var hp = optimize(50,25,75);
var *RSI10 = series(HighPass(Price,hp));
static int crossed = 0;
if(crossOver(LP5,LP10))
crossed = 3;
else if (crossUnder(LP5,LP10))
crossed = -3;
if(crossed > 0 && crossOver(RSI10, Threshold))
{
enterLong();
crossed = 0;
}
else if(crossed < 0 && crossUnder(RSI10, Threshold))
{
enterShort();
crossed = 0;
}
else crossed -= sign(crossed);
plot ("LP1", LP5[0], 0, RED);
plot ("LP2", LP10[0], 0, BLUE);
plot ("RSI", RSI10[0], NEW, BLACK);
plot ("Thres", Threshold, 0, RED);
plot ("Thres1", -Threshold, 0, RED);
}
There are pretty many optimized parameters...
Backtest looks decent (I guess) on for example EURUSD and GBPUSD. But I don't know if I like the looks of the equity curves... And I haven't done any WFO yet. Feel free to improve it.
So I managed to put together a grid trading system for the EUR/CHF and it seems to be holding things together. As long as the inefficiency is prevalent in that pair it should continue to make money. Here is the code. I used the grid script that comes with Zorro and made a couple of changes.
Code:
// Grid trader (needs hedging - non-US accounts only)
// find all trades at a grid line
bool findTrade(var Price,var Grid,bool IsShort)
{
for(open_trades)
if((TradeIsShort == IsShort)
and between(TradeEntryLimit,Price-Grid/2,Price+Grid/2))
return true;
return false;
}
int run()
{
set(TICKS); // Test using 1 minute Bars
StartDate = 2012; // Start trading from 2012
BarPeriod = 240; // Trade the 4 Hour chart
Hedge = 2; // allow long & short trades at the same time
EntryTime = ExitTime = 500; // close trades that have been opened for 3 months
asset("EUR/CHF");
var Price;
var Grid = 25*PIP; // set grid siz to 25 pips
var Close = priceClose(); // Use the price close of bars
// place pending trades at 5 grid lines
// above and below the current price
for(Price = 0; Price < Close+5*Grid; Price += Grid)
{
// find the lowest grid line
if(Price < Close-5*Grid) continue;
// place not more than 200 trades
if(NumOpenTotal + NumPendingTotal > 200) break;
// place short trades below the current price
if(Price < Close and !findTrade(Price,Grid,true))
enterShort(1,Price,20*Grid,Grid);
// place long trades above the current price
else if(Price > Close and !findTrade(Price,Grid,false))
enterLong(1,Price,20*Grid,Grid);
}
}