Australian (ASX) Stock Market Forum

Amibroker FAQ

No stock on the Australian Stock Exchange trades 500,000 shares per day - that's your problem. Why do you need both of those filters anyway? I'd just use the turnover filter and ditch the volume filter.

Thanks Howard. I plotted it and I can see what the problem is I think.

Alterego you might be right I think. Its the amount I put for volume that is too high. I have been reading different threads trying to learn about liquidity as a filter and I read this at the techtrader forum

cond4=EMA(V*C,21) > 500000; // ensure at least $500k of money flow

I think I misinterpreted it. Is it necessary to have a min volume requirement too or just use the turnover and thats it?
 
Greetings --

Lack of liquidity and the ability to exit a position has been one of the major problems for traders of all account sizes. My recommendation is to invest / trade only those issues where the entire position can be exited any day -- preferably any minute of any day. On the US markets, a daily liquidity of $100,000,000 is a reasonable requirement. That provides over 400 tradables, including nearly 100 ETFs. (I realize that there are only a dozen or so issues listed on the Australian exchange that have anywhere near that trading volume.)

I measure liquidity as the dollar volume rather than the share volume. One of the advantages is that splits are automatically taken into account. The width of the bid - ask spread is closely correlated with liquidity. US stocks and ETFs typically have prices from $20 to $100. Those with the highest liquidity have spreads of 1 or 2 cents any minute of any day.

When problems arise and markets begin to drop, previously uncorrelated portfolios lose the safety and stability as correlations rise toward 1.00 and everything drops together. People sell what they can sell, not necessarily what they want to sell.

Thanks for listening,
Howard
 
Thanks for everyones help with that. I have one last thing that I need help with. Im trying to learn how to write loops and Ive had a go at adding a simple index filter to a formula so that if the general index is below the 200 day ema the lower donchian channel tightens up and I dont initiate any more positions. If someone could have a look at what Ive done and how Ive done it and tell me if Im approaching it correctly I would appreciate it.
I had to write the filter in two parts because I found if I placed it all in one below the Buy conditions I had an initialise problem because I was trying to vary the donchian parameters in the same loop but that had to be positioned before the donchian formula. Hope that makes sense :)
When I switch the filter in Parameters the buy signals seem to switch ok but the lower donchian doesnt move.
I just need to be pointed in the right direction because I must be approaching this the wrong way. Thank you


The formula is

Code:
// Filter Part 1

AORDClose = Foreign("^AORD","C");
AORDUp=AORDClose>EMA(AORDClose,200);
AORDDown=AORDClose<EMA(AORDClose,200);

AORDFilter = ParamToggle("AORD Filter","On|Off",1);
if(AORDFilter == True)

for( i=1;i<BarCount; i++ )

if(AORDUp[i] == True)


Lpds = 75;
else {

Lpds = 30; 
}

else {

Lpds = 75; 
}

//-----------------------------------------------------------------------------------------------------------------------

Hpds=Param("hpds",20 ,6 , 30 ,1 );

Range1=Optimize("range1",55,50,150,1);


bi = BarIndex(); 
myCandle = bi == LastValue(bi) - Lpds; 
Color = IIf( myCandle, colorBlue, colorBlack); 
fillcolor = IIf( C > O , colorWhite, IIf( myCandle, colorBlue, colorLightGrey)); 
SetBarFillColor(fillcolor ); 
Plot(Close, "C", Color, styleCandle); 


DonchianUpper =HHV(Ref(H,-1),Hpds);
DonchianLower = LLV(Ref(L,-1),Lpds);
DonchianMiddle = (DonchianUpper+DonchianLower)/2;


//---------------------------------------------------------------------------------------------------------------------------------
// Filter part 2

AORDClose = Foreign("^AORD","C");
AORDUp=AORDClose>EMA(AORDClose,200);
AORDDown=AORDClose<EMA(AORDClose,200);


Cond1= Close > DonchianUpper AND Close > EMA(  Close , range1 );
Cond2=EMA((Close*Volume),21)>1000000;
Cond3=AORDUP;

AORDFilter = ParamToggle("AORD Filter","No|Yes",1);
if(AORDFilter == True)
for( i=1;i<BarCount; i++ )

if(AORDUp[i] == True)


Buy=Cond1 AND Cond2;
else {

Buy=Cond1 AND Cond2 AND Cond3; 
}

else {

Buy=Cond1 AND Cond2 AND Cond3; 


}

Sell= Close < DonchianLower;



Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);


Plot(DonchianUpper,"DU",colorBlue,styleLine);
Plot(DonchianMiddle,"DM",colorLightGrey,styleLine);
Plot(DonchianLower,"DL",colorRed,styleLine); 
PlotShapes(Buy*shapeUpArrow,colorGreen,0,Low);
PlotShapes(Sell*shapeDownArrow,colorRed,0,High);


//----------------------------------------------------------------------------------------------------------------------------------
//AORD Trend Ribbon 200EMA

_SECTION_BEGIN("trending ribbon");

myClose = Foreign("^AORD","C");
uptrend=myClose>EMA(myClose,200);
downtrend=myClose<EMA(myClose,200);

Plot( 2, /* defines the height of the ribbon in percent of pane width*/"ribbon",
IIf( uptrend, colorGreen, IIf( downtrend, colorRed, colorDarkGrey )), /* choose color */
styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );

_SECTION_END();
 
art, use the 'code' tags to insert code, takes up less space on the thread. Its the # icon.

CanOz
 
I noticed that I had left out the brackets so I put those in

Code:
// Filter Part 1

AORDClose = Foreign("^AORD","C");
AORDUp=AORDClose>EMA(AORDClose,200);
AORDDown=AORDClose<EMA(AORDClose,200);

AORDFilter = ParamToggle("AORD Filter","On|Off",1);
if(AORDFilter == True)

for( i=1;i<BarCount; i++ )

if(AORDUp[i] == True)


Lpds [ i ] = 75;
else {

Lpds [ i ] = 30; 
}

else {

Lpds [ i ] = 75; 
}

//-----------------------------------------------------------------------------------------------------------------------

Hpds=Param("hpds",20 ,6 , 30 ,1 );

Range1=Optimize("range1",55,50,150,1);


bi = BarIndex(); 
myCandle = bi == LastValue(bi) - Lpds; 
Color = IIf( myCandle, colorBlue, colorBlack); 
fillcolor = IIf( C > O , colorWhite, IIf( myCandle, colorBlue, colorLightGrey)); 
SetBarFillColor(fillcolor ); 
Plot(Close, "C", Color, styleCandle); 


DonchianUpper =HHV(Ref(H,-1),Hpds);
DonchianLower = LLV(Ref(L,-1),Lpds);
DonchianMiddle = (DonchianUpper+DonchianLower)/2;


//---------------------------------------------------------------------------------------------------------------------------------
// Filter part 2

AORDClose = Foreign("^AORD","C");
AORDUp=AORDClose>EMA(AORDClose,200);
AORDDown=AORDClose<EMA(AORDClose,200);


Cond1= Close > DonchianUpper AND Close > EMA(  Close , range1 );
Cond2=EMA((Close*Volume),21)>1000000;
Cond3=AORDUP;

AORDFilter = ParamToggle("AORD Filter","No|Yes",1);
if(AORDFilter == True)
for( i=1;i<BarCount; i++ )

if(AORDUp[i] == True)


Buy=Cond1 AND Cond2;
else {

Buy=Cond1 AND Cond2 AND Cond3; 
}

else {

Buy=Cond1 AND Cond2 AND Cond3; 


}

Sell= Close < DonchianLower;



Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);


Plot(DonchianUpper,"DU",colorBlue,styleLine);
Plot(DonchianMiddle,"DM",colorLightGrey,styleLine);
Plot(DonchianLower,"DL",colorRed,styleLine); 
PlotShapes(Buy*shapeUpArrow,colorGreen,0,Low);
PlotShapes(Sell*shapeDownArrow,colorRed,0,High);


//----------------------------------------------------------------------------------------------------------------------------------
//AORD Trend Ribbon 200EMA

_SECTION_BEGIN("trending ribbon");

myClose = Foreign("^AORD","C");
uptrend=myClose>EMA(myClose,200);
downtrend=myClose<EMA(myClose,200);

Plot( 2, /* defines the height of the ribbon in percent of pane width*/"ribbon",
IIf( uptrend, colorGreen, IIf( downtrend, colorRed, colorDarkGrey )), /* choose color */
styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );

_SECTION_END();

Their seems to be a problem when I switch it in parameters. I get an error in this line

Lpds [ i ] = 75;

variable i used without being initialised.

Am I approaching this correctly or is there a better way? I dont want someone to do it for me I just want to be told what Im doing wrong.

Thanks
 
Would anyone be able to inform me as to how I change the x and y axes of the Equity Curve in the Report section in AB?
Thanks,
Troy
 
Can anyone please guide me with this. I tried a different approch and still no good.
Ive run out of ideas.

Code:
// Filter Part 1

AORDClose = Foreign("^AORD","C");
AORDUp=AORDClose>EMA(AORDClose,200);
AORDDown=AORDClose<EMA(AORDClose,200);

AORDFilter = ParamToggle("AORD Filter","On|Off",1);
Lpds=0;

for( i=1;i<BarCount; i++ )

if(AORDFilter == True)

Lpds [ i ] = 75;

else  {

Lpds [ i ] = 30; 
}


if (AORDFilter == False) {

Lpds [ i ] = 75; 
}

//-----------------------------------------------------------------------------------------------------------------------

Hpds=Param("hpds",20 ,6 , 30 ,1 );

Range1=Optimize("range1",55,50,150,1);


bi = BarIndex(); 
myCandle = bi == LastValue(bi) - Lpds; 
Color = IIf( myCandle, colorBlue, colorBlack); 
fillcolor = IIf( C > O , colorWhite, IIf( myCandle, colorBlue, colorLightGrey)); 
SetBarFillColor(fillcolor ); 
Plot(Close, "C", Color, styleCandle); 


DonchianUpper =HHV(Ref(H,-1),Hpds);
DonchianLower = LLV(Ref(L,-1),Lpds);
DonchianMiddle = (DonchianUpper+DonchianLower)/2;


//---------------------------------------------------------------------------------------------------------------------------------
// Filter part 2

AORDClose = Foreign("^AORD","C");
AORDUp=AORDClose>EMA(AORDClose,200);
AORDDown=AORDClose<EMA(AORDClose,200);


Cond1= Close > DonchianUpper AND Close > EMA(  Close , range1 );
Cond2=EMA((Close*Volume),21)>1000000;
Cond3=AORDUP;

AORDFilter = ParamToggle("AORD Filter","No|Yes",1);
if(AORDFilter == True)
for( i=1;i<BarCount; i++ )

if(AORDUp[i] == True)


Buy=Cond1 AND Cond2;
else {

Buy=Cond1 AND Cond2 AND Cond3; 
}

else {

Buy=Cond1 AND Cond2 AND Cond3; 


}

Sell= Close < DonchianLower;



Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);


Plot(DonchianUpper,"DU",colorBlue,styleLine);
Plot(DonchianMiddle,"DM",colorLightGrey,styleLine);
Plot(DonchianLower,"DL",colorRed,styleLine); 
PlotShapes(Buy*shapeUpArrow,colorGreen,0,Low);
PlotShapes(Sell*shapeDownArrow,colorRed,0,High);


//----------------------------------------------------------------------------------------------------------------------------------
//AORD Trend Ribbon 200EMA

_SECTION_BEGIN("trending ribbon");

myClose = Foreign("^AORD","C");
uptrend=myClose>EMA(myClose,200);
downtrend=myClose<EMA(myClose,200);

Plot( 2, /* defines the height of the ribbon in percent of pane width*/"ribbon",
IIf( uptrend, colorGreen, IIf( downtrend, colorRed, colorDarkGrey )), /* choose color */
styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );

_SECTION_END();
 
What do you mean by changing x and y axes?
y -> date axis??

Say I just want to backtest a period of 1990 - 2010. My graph shows from 1920 till 2012 or something ridiculous. And with the equity curve can it be changed to log rather than linear scale?
 
Say I just want to backtest a period of 1990 - 2010. My graph shows from 1920 till 2012 or something ridiculous.

Why don't you simply use 'From-To' option in AA window?

And with the equity curve can it be changed to log rather than linear scale?

I.e. apply the Porfolio Equity AFL on a chart. Open parameters dialog and go to 'Axes&Grid' and click 'Type' to 'Logarithmic'
 

Attachments

  • ASF.gif
    ASF.gif
    63.2 KB · Views: 9
  • ASF2.gif
    ASF2.gif
    4.5 KB · Views: 3
Why don't you simply use 'From-To' option in AA window?



I.e. apply the Porfolio Equity AFL on a chart. Open parameters dialog and go to 'Axes&Grid' and click 'Type' to 'Logarithmic'


The From and To option is what I already do, it just doesn't report that specific timeframe on the equity chart for some reason. Thanks though!
 
Do you mind posting your code and tested symbols and AA settings (bt settings window > save)? What's your AB version number?
 
And with the equity curve can it be changed to log rather than linear scale?

Add the following line to the "Portfolio Equity" AFL of the "Report Charts" folder

Code:
SetChartOptions( 0, chartShowDates | chartLogarithmic );

then in the report the equity chart should be shown in log mode.
 
Hello

Ive been trying to learn how to set up and backtest a few systems and I must have a problem because all of them give very low results. I have attached a afl of techtrader that I have. Ive backtested it on asx all ords from 1/1/2004 to 20/4/2012. I click backtest-portfolio backtest and then I click on report. The report that I get says that the annual return was 2.54%. Could someone please backtest this afl and tell me what the results are. Thank you

Code:
Initial capital 	              100000.00 	
Ending capital 	              128722.76 	
Net Profit 	                        28722.76 	
Net Profit % 	                 28.72 % 	
Exposure % 	                  15.08 % 	
Net Risk Adjusted Return % 	190.50 % 	
Annual Return %    	            2.74 % 	
Risk Adjusted Return %    	   18.18 %

Code:
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 




// techtrader v2 amibroker version
// here we define buy conditions and name each one as a variable
PositionSize = -10; // always invest only 10% of the current Equity
cond1=Cross(H,Ref(HHV(H,10),-1)); // when todays high crosses last highest high over the last 10 periods
cond2=H > EMA(C,40); // todays high is greater than the 40 day Exp MA of closes
cond3=HHVBars(H,70) == 0; // todays high is the highest for 70 periods
cond4=EMA(V*C,21) > 500000; // ensure at least $500k of money flow
cond5=C < 10; // only trading in stocks less than $10
cond6=C > O; // todays close higher than open

// the following line is the trigger if all conditions satisfied
Buy=cond1 AND cond2 AND cond3 AND cond4 AND cond5 AND cond6;

// here we define variables used once in the trade
ApplyStop( stopTypeLoss, stopModePercent, amount=10 );
Sell= Cross(Ref(EMA(L,180),-1),C); // close crosses below yesterdays average of the low

// here we define what gets displayed on the chart
PlotShapes(Buy*shapeUpArrow,colorGreen,0,Low);
PlotShapes(Sell*shapeDownArrow,colorRed,0,High);

Filter = cond1 AND cond2 AND cond3 AND cond4 AND cond5 AND cond6;
 // lists exploration results conforming to our buy criteria
AddColumn(Buy, "buy", 1.0); //
//Filter = Sell; // lists exploration results conforming to our buy criteria
//AddColumn(Sell, "sell", 1.0); //

// This section creates the data that you can plot to see how often TT2 trades
// NOTE:- Using VOLUME array so get correct number when switching to WEEKLY or MONTHLY display
AddToComposite(Buy,"~TTBuys","V");
AddToComposite(Sell,"~TTSells","V");

Buy = ExRem(Buy,Sell) ;
Sell = ExRem(Sell, Buy);
Binary = Flip(Buy , Sell);

_SECTION_BEGIN("EMA 40");
P = ParamField("Price field",-1);
Periods = Param("Periods", 40, 2, 300, 1 );
Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorBlueGrey ), ParamStyle("Style"),styleThick ); 
_SECTION_END();

_SECTION_BEGIN("HHV Long term Entry");
HHVlongtermPeriod=Param("HHV Long termPeriod",70,1,50);
LongPeriodEntry=HHV(H,HHVLongtermPeriod);
Plot (LongperiodEntry," Highest High 70 Days ",colorRed,styleLine);
_SECTION_END();

_SECTION_BEGIN("HHV Short term Entry");
HHVshorttermPeriod=Param("HHV short term Period",10,1,50);
ShortperiodEntry=HHV(H,HHVshorttermPeriod);
Plot (ShortperiodEntry," Highest High 10 Days ",colorBlue,styleLine);
_SECTION_END();




_SECTION_BEGIN("EMA 180");
P = ParamField("Price field",-1);
Periods = Param("Periods", 180, 2, 300, 1 );
Plot( EMA( L, Periods ), _DEFAULT_NAME(), colorOrange , ParamStyle("Style"),styleThick ); 
_SECTION_END();
 
Hello

Ive been trying to learn how to set up and backtest a few systems and I must have a problem because all of them give very low results. I have attached a afl of techtrader that I have. Ive backtested it on asx all ords from 1/1/2004 to 20/4/2012. I click backtest-portfolio backtest and then I click on report. The report that I get says that the annual return was 2.54%. Could someone please backtest this afl and tell me what the results are. Thank you

G'day,

I'm kinda in the middle of something right now so I haven't checked your code. But I can confirm that your problem isn't with the code. I ran it on the all ords for the dates you posted and got 41.6% CAR.

Your problem must be in the Amibroker settings somewhere. Looking at your stats, your exposure of 15.08% is way too low. Mine is 86.31%. So some setting is restricting the systems ability to move fully into the market.
 
If you want to check any backtester settings just post them here. I suggest checking your max open positions, should be set to 10 in your case.
 
Hello

Ive been trying to learn how to set up and backtest a few systems and I must have a problem because all of them give very low results. I have attached a afl of techtrader that I have. Ive backtested it on asx all ords from 1/1/2004 to 20/4/2012. I click backtest-portfolio backtest and then I click on report. The report that I get says that the annual return was 2.54%. Could someone please backtest this afl and tell me what the results are. Thank you

[/CODE]

I got 14%pa, starting with 50K, exact same dates as you.

As Lone says, best to post up your settings.



Initial capital 50000.00 50000.00
Ending capital 149183.64 149183.64
Net Profit 99183.64 99183.64
Net Profit % 198.37 % 198.37 %
Exposure % 91.22 % 91.22 %
Net Risk Adjusted Return % 217.45 % 217.45 %
Annual Return % 14.06 % 14.06 %
Risk Adjusted Return % 15.42 % 15.42 %

--------------------------------------------------------------------------------

All trades 327 327 (100.00 %)
Avg. Profit/Loss 303.31 303.31
Avg. Profit/Loss % 7.03 % 7.03 %
Avg. Bars Held 81.68 81.68

--------------------------------------------------------------------------------

Winners 91 (27.83 %) 91 (27.83 %)
Total Profit 294122.88 294122.88
Avg. Profit 3232.12 3232.12
Avg. Profit % 48.34 % 48.34 %
Avg. Bars Held 204.10 204.10
Max. Consecutive 9 9
Largest win 49180.98 49180.98
# bars in largest win 620 620

--------------------------------------------------------------------------------

Losers 236 (72.17 %) 236 (72.17 %)
Total Loss -194939.24 -194939.24
Avg. Loss -826.01 -826.01
Avg. Loss % -8.90 % -8.90 %
Avg. Bars Held 34.48 34.48
Max. Consecutive 21 21
Largest loss -4438.81 -4438.81
# bars in largest loss 9 9

--------------------------------------------------------------------------------

Max. trade drawdown -25228.49 -25228.49
Max. trade % drawdown -70.00 % -70.00 %
Max. system drawdown -95503.60 -95503.60
Max. system % drawdown -41.23 % -41.23 %
Recovery Factor 1.04 1.04
CAR/MaxDD 0.34 0.34
RAR/MaxDD 0.37 0.37
Profit Factor 1.51 1.51
Payoff Ratio 3.91 3.91
Standard Error 24034.37 24034.37
Risk-Reward Ratio 0.76 0.76
Ulcer Index 16.97 16.97
Ulcer Performance Index 0.51 0.51
Sharpe Ratio of trades 0.18 0.18
K-Ratio 0.0389 0.0389
 
Top