Australian (ASX) Stock Market Forum

Amibroker code backtesting & optimizing

nielsend

Dash
Joined
11 October 2007
Posts
66
Reactions
0
Can someone please provide me with the code to backtest and optimize the ‘Inverse Fisher Transform’ function’s as detailed on the Amibroker site (members area). The code is based on the article “The Inverse Fisher Transform” By John Ehlers. I’m not a coder, so any assistance with setting up AB for backtesting / optimizing would be greatly appreciated.
 
Re: Amibroker code backtesting

A basic setup for buy n sell. Checked with bar replay and entry/exits line up true. Would like second opinion after test and maybe a suggested improvement apart from optimising the ranges.

P.S. don't tell anyone. :D

Code:
Capital = Param("Start Capital", 100000, 10000, 100000, 2000);
SetOption("InitialEquity", Capital); 

ATRPeriod = Param("ATR Period", 10, 5, 25, 1);  
ATRMultiple = Param("ATR Multiple", 2.5, 1, 5, 0.5);
ATRAmount = ATRMultiple * MA(ATR(1), ATRPeriod);

Risk1 = Param("Dollar Risk", 1000, 100, 5000, 100); 
PosSize = (Risk1/ATRAmount)* BuyPrice;
PosDollarLimit = Param("Position Size Limit", 10000, 1000, 20000, 500);
PositionSize = IIf(PosSize < PosDollarLimit, PosSize, PosDollarLimit);
PositionScore = ROC(C,1) * -1;   

SetTradeDelays(1,1,1,1);

Turnover = MA(C * V, 50) > 100000 & C > 0.50;

Per = Param("DEMA Periods", 200, 0, 300, 10);
DemaLine = DEMA(C, Per);
UpperBand = DEMA(C, Per) + 2* StdErr(C, 50);
LowerBand = DEMA(C, Per) - 2* StdErr(C, 50);

Buy = (Ref(C < LowerBand, -1) & Cross(C, LowerBand))  & (UpperBand > Ref(UpperBand, -1) & LowerBand > Ref(LowerBand, -1)) 
& TurnOver; /* Previous bar Low is less than Lower band, current bar crosses and closes above Lower band,
Upper band is greater than previous value AND Lower band is greater than previous value. */

Sell = Cross(UpperBand, C); // Sell when price crosses and closes below Upper Band

ApplyStop(0, 2, 3* ATR(22), 2, True); // Initial Stop Loss at 3 times Average True Range


Plot(DemaLine, "", colorWhite, styleLine, styleThick);
Plot(UpperBand, "", colorBlack, styleLine);
Plot(LowerBand, "", colorYellow, styleLine);
 
Re: Amibroker code backtesting

A basic setup for buy n sell.
BLD has met the criteria on the 3rd July so I will do a test trade with a buy on the next day open 4th July at $5.45.

Position size is 1800 shares for cost of $9810 + $20 brokerage = $9830.

Stop Loss at $5.08 for a maximum loss of 1800 * 0.37 + brokerage ($20) = $686

Stop loss below recent low of $5.10.
 
Re: Amibroker code backtesting

BLD has met the criteria on the 3rd July so I will do a test trade with a buy on the next day open 4th July at $5.45.

Position size is 1800 shares for cost of $9810 + $20 brokerage = $9830.

Stop Loss at $5.08 for a maximum loss of 1800 * 0.37 + brokerage ($20) = $686

Stop loss below recent low of $5.10.
I notice the low for BLD was $5.05 which would be a stop out. A stop out before lifting to a high of $5.81 today. I cannot be upset because no hard earned went into the company but those dirty tricks are ever present. $5.20 could easily have been the support for this up trender but no, there had to be a spite down.
 
Top