//Settings
SetOption("InitialEquity",100000);
SetOption("MaxOpenPositions",20);
SetPositionSize(5,spsPercentOfEquity);
SetTradeDelays(1,1,1,1);
//Rules
HI = HHV(C,250);
LW = LLV(C,250);
DollarTurnover = MA(C*V, 7);
dollarTurnoverOK = dollarTurnover > 500000;
Liquidity = MA(V,7);
LiquidityOK = Liquidity > 500000;
Buy = C >= HI AND LiquidityOK AND dollarTurnoverOK;
Sell = C <= LW;
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Hi,
I'm in the process in re-reading "Unholy Grails" and have purchased Amibroker and trying to learn some code to replicate the systems that Nick has developed and included in his book. I have completed the first example he wrote about, which was the "New Yearly Highs". I'm pretty happy with the results as they are close to what's in the book. I want to include an index filter to this system. That is, the system will only signal buys when the "All Ords" is trading above a 75 day moving average, and sell if the All Ords is trading below the 75 day moving average. From what I have found so far, I will have to use the code "foreign". I would me most grateful if someone could assist.
[b]SetForeign( "XAO", True, True );
Buyfilter = Close > MA( C, 75 );
Sellfilter = Close < MA(C, 75);
RestorePriceArrays( True );[/b]
//Settings
SetOption("InitialEquity",100000);
SetOption("MaxOpenPositions",20);
SetPositionSize(5,spsPercentOfEquity);
SetTradeDelays(1,1,1,1);
//Rules
HI = HHV(C,250);
LW = LLV(C,250);
DollarTurnover = MA(C*V, 7);
dollarTurnoverOK = dollarTurnover > 500000;
Liquidity = MA(V,7);
LiquidityOK = Liquidity > 500000;
Buy = C >= HI AND LiquidityOK AND dollarTurnoverOK [b]and Buyfilter[/b];
Sell = C <= LW [b]or Sellfilter[/b];
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Thanks Captain,
Whats the "RestorePriceArrays(True);" code for?
Thanks in advance.
////////////////// 20% Flipper \\\\\\\\\\\\\\\\\\\
// Settings
SetOption("InitialEquity", 100000); // Initial Equity
SetOption("MaxOpenPositions", 20); // Max. 20 open positions
SetPositionSize(5, spsPercentOfEquity); // Equally weighted 5% of Equity
SetOption("CommissionAmount", 30); // Commission of $30 ($29.95 rounded up)
SetTradeDelays(1,1,1,1); // Trade next bar after signal at open price
SetOption("UsePrevBarEquityForPosSizing", True);
PositionScore = mtRandomA(); // Random Backtest
// Index Filter
SetForeign("XAO"); // Yahoo = ^AORD / Premium Data = XAO)
IndexBuyfilter = C > MA(C, 75);
IndexSellfilter = C < MA(C, 75);
RestorePriceArrays();
// Rules
HighValueLess20 = HHV(H, 50) * 0.80; // Close is 20% lower than 50 bar High
LowValuePlus20 = LLV(L, 50) * 1.20; // Close is 20% higher than 50 bar Low
Turnover = MA(C*V, 7) > 500000; // Dollar Average for 7 bars is greater than 500000
Liquidity = MA(V, 7) > 500000; // Volume Average for 7 bars is greater than 500000
Buy = Cross(C, LowValuePlus20) & Liquidity & Turnover;
Sell = Cross(HighValueLess20, C);
Plot(LowValuePlus20, "LLV", colorBlue,styleLine,styleThick);
Plot(HighValueLess20, "HHV", colorBlack,styleLine,styleThick);
I can't get a good score with the 20% flipper because the Low price is only good for 50 bars and will adjust upwards after 50 bars with a rising new Low. Change the range to 100 bar Low and the same issue. For the life of me I cannot see anything of value in this strategy.
I can't get a good score with the 20% flipper because the Low price is only good for 50 bars and will adjust upwards after 50 bars with a rising new Low. Change the range to 100 bar Low and the same issue. For the life of me I cannot see anything of value in this strategy. :bad:
p.s. In the code "Liquidity" should be simply Volume Average as it is not the stocks liquidity factor.
I can't get a good score with the 20% flipper because the Low price is only good for 50 bars and will adjust upwards after 50 bars with a rising new Low. Change the range to 100 bar Low and the same issue. For the life of me I cannot see anything of value in this strategy. :bad:
A 20% change from high to low isn't a rule. The entry is a rise of 20% from a low. As Habakkuk notes you will still need a 'range' to determine when a low is the low we use as the base. In Amibroker Zig uses future data.You will need to use a ZigZag based indicator that works from High to Low and link this with a binary indicator which signals when a 20% low has been "locked in".
AmiBroker is certainly capable of handling both indicators.
Needs a bull market and implemented near the start of the bull market.On another note, consider this:
all of the "Unholy Grail" systems are very, very simple, extremely, excessively simple and all of them outperform buy and hold not just handsomely, but spectacularly.
How is this possible? Why doesn't everybody just look for 250-day highs and 75-day SMAs?
Nevertheless, I have enjoyed reading "Unholy Grails" and learnt a few things. It was well worth it.
Rnr
Could you point me in the direction of a working example of the two together.
A 20% change from high to low isn't a rule. The entry is a rise of 20% from a low. As Habakkuk notes you will still need a 'range' to determine when a low is the low we use as the base. In Amibroker Zig uses future data.
It's up to you on how you interpret this system from Unholy Grails and I presume that replicating his results would confirm whether your code is the same as Nick's.
The code used in MetaStock can be written for AmiBroker and will produce the same results.
Hello and welcome to Aussie Stock Forums!
To gain full access you must register. Registration is free and takes only a few seconds to complete.
Already a member? Log in here.