Australian (ASX) Stock Market Forum

Amibroker FAQ

Hi.

Can somebody here please help ?

I am trying to reference the current bar as having it's close within the range of the highest volume bar of the last 10 days.

The best I can come up with is this but doesn't work?

C<HHV(V,10) AND C>LLV(V,10);

Thanks
 
Hi.

Can somebody here please help ?

I am trying to reference the current bar as having it's close within the range of the highest volume bar of the last 10 days.

The best I can come up with is this but doesn't work?

C<HHV(V,10) AND C>LLV(V,10);

Thanks

Try something like this:

X = BarsSince(V==HHV(V,10));

C<Ref(H,-X) AND C>Ref(L,-X);
 
Hi again. It works. Thanks for that. Could you or anybody help with how to label that HHV bar so that I can define it's characteristics eg up bar or wide range bar etc.

Thanks:)

Not exactly sure what you are after but you could identify the bar with color, text or symbols. For example, using color is easily done:

X = BarsSince(V==HHV(V,10));

mybar = C<Ref(H,-X) AND C>Ref(L,-X);

Plot( C, "", IIf( mybar, colorWhite, colorRed ), styleBar );

Text and symbols can be used with PlotText() and PlotShapes(). There are also the low level Gfx functions. All are described in the Users Guide.
 
Hi Gents,

How do I get an exploration to show MFE and MAE plz ?

Cheers!
When you run a back-test in AA, the MAE & MFE columns are visible and shows the favourable % excursion from buy (or short) price and adverse % excursion from buy (or short) price for each trade. In the AA back-test report there is a chart representation of the MAE & MFE.
 
Hi Gents,

How do I get an exploration to show MFE and MAE plz ?

Cheers!


You can do that by using Equity() function.
Actually in Exploration you can output backtests result list in same way as in backtest.
Only difference is that in exploration you can mimic individual backtest only but not portfolio.
Picture http://i.imgur.com/4gfqbIL.png showing example of individual backtest via exploration.
As you can see another difference is that in exploration you may additionally color your columns individually.

Side note:To output additional columns with custom info in standard backtest you may use custom backtest interface (see help file).
Via CBT you may get any info stored to static variables for example or stored via other methods.
Here https://www.youtube.com/watch?v=kOCs0uOHXgs I once made MAE/MFE charts that can be output in chart pane or in backtest report.
 
Hello

StopLevel = Param( "Stop Loss (%)", 0.5, 0.1, 100, 0.1 );
TgtLevel = Param( "Profit target (%)", 0.5, 0.1, 10, 0.1 );


ApplyStop( stopTypeLoss, stopModePercent, StopLevel, True );
ApplyStop( stopTypeProfit, stopModePercent, TgtLevel, True ,1); //stopModePoint //stopModePercent
ApplyStop(stopTypeTrailing, stopModePercent, StopLevel , True, True );

can we put amt = HHV - x% in case of long trail or LLV+x% in case of short trail stop loss in applystop?

means - we will exit in case of buy - if the close price is below x % of HHV after the buy is initiated or x% above of LLV after a short is initiated?

regards and tia
 
See knowledge base article
http://www.amibroker.com/kb/2007/03/24/how-to-plot-a-trailing-stop-in-the-price-chart/

Code:
// http://www.amibroker.com/kb/2007/03/24/how-to-plot-a-trailing-stop-in-the-price-chart/
// Modified to use HHV

StopLevel = 1 - Param( "trailing stop %", 3, 0.1, 10, 0.1 ) / 100;
HHVperiod = 10;

Buy = Cross( MACD(), Signal() );
Sell = 0;
LongtrailARRAY = Null;
Longtrailstop = 0;

myhigh = HHV( H, HHVperiod );

for( i = 1; i < BarCount; i++ ) {
	if( Longtrailstop == 0 AND Buy[ i ] ) { 
		Longtrailstop = myhigh[ i ] * stoplevel;
	}
	else Buy[ i ] = 0; // remove excess buy signals

	if( Longtrailstop > 0 AND Low[ i ] < Longtrailstop ) {
		Sell[ i ] = 1;
		SellPrice[ i ] = Longtrailstop;
		Longtrailstop = 0;
	}
	if( Longtrailstop > 0 ) {   
		Longtrailstop = Max( myhigh[ i ] * stoplevel, Longtrailstop );
		LongtrailARRAY[ i ] = Longtrailstop;
	}
}

PlotShapes( Buy*shapeUpArrow, colorGreen, 0, Low );
PlotShapes( Sell*shapeDownArrow, colorRed, 0, High );

Plot( Close, "Price", colorGrey40, styleBar );
Plot( LongtrailARRAY, "trailing stop level", colorRed );
 
I currently have the following filters in place, following help from the good folk here:

Code:
SetForeign( "XAO" );
FastMALength = Optimize("FMA",50,30,70,2);
SlowMALength = Optimize("SMA",200,180,200,2);

Filter1 =  EMA( C, FastMALength ) > EMA( C, SlowMALength );
RestorePriceArrays();


//This is the additional filter I have introduced to try and filter out low volume stocks
VolA = Volume * C;
MAVol = MA( VolA, 15 );


Filter = Filter1 AND MAVol > 350000;

I would like to place a further filter in to filter out individual stocks whose fast EMA is less than their slow EMA. I would appreciate help on how to add a third filter to the above.
 
I currently have the following filters in place, following help from the good folk here:

Code:
SetForeign( "XAO" );
FastMALength = Optimize("FMA",50,30,70,2);
SlowMALength = Optimize("SMA",200,180,200,2);

Filter1 =  EMA( C, FastMALength ) > EMA( C, SlowMALength );
RestorePriceArrays();


//This is the additional filter I have introduced to try and filter out low volume stocks
VolA = Volume * C;
MAVol = MA( VolA, 15 );


Filter = Filter1 AND MAVol > 350000;

I would like to place a further filter in to filter out individual stocks whose fast EMA is less than their slow EMA. I would appreciate help on how to add a third filter to the above.

Not to worry - I have worked this one out with the following mod:

Code:
Filter2 = EMA(C,60) > EMA(C,180);

Filter = Filter1 AND Filter2 AND MAVol > 350000;
 
Hi All,

Sorry for the newbie question. I want to build an array from a list of numbers(.txt file). The list contains the "BarIndex" number for where trade signals occurred. The list is less than 50 items(comma separated), while the array should be of current database length(approx. 10K).

I created the list for another purpose, but wanted to be able to utilize the data in other ways. Simply, I want to learn how to build the array from said list----never done that before (always working in "afl"). Please note that I'll be working from a database that will not be updated.

TIA,
RutheezKey
 
Hi All,

Sorry for the newbie question. I want to build an array from a list of numbers(.txt file). The list contains the "BarIndex" number for where trade signals occurred. The list is less than 50 items(comma separated), while the array should be of current database length(approx. 10K).

I created the list for another purpose, but wanted to be able to utilize the data in other ways. Simply, I want to learn how to build the array from said list----never done that before (always working in "afl"). Please note that I'll be working from a database that will not be updated.

TIA,
RutheezKey

http://www.amibroker.com/kb/2014/09/30/gen-backtest-from-a-file/
Other than that you may also use Osaka plugin.
 
QUESTION

I have been backtesting my Trading strategy and achieving pleasing results before I read a post by Howard Bandy answering a members question - the member wanted to know the formula to execute a BUY the next day after the signals is generated - meaning the BUY is execute at the next day's opening price.

As that's how I plan to trade I added Howard Bandy's code to my strategy.

Once I added the code to my strategy my Backtest results went from a yearly Net Profit of $26,044 to a yearly Net Loss of -$3,534

I wouldn't have thought buying the next day compared to buying the same day the signal is generated would make such a difference to my Backtest results.

Can anyone shed light on how this could be possible?

The Code I added
/////////////////////////////////////////////////
BuyPrice = Open;
SellPrice = Open;
SetTradeDelays(1,1,1,1);
/////////////////////////////////////////////////

skate.
 
QUESTION

I have been backtesting my Trading strategy and achieving pleasing results before I read a post by Howard Bandy answering a members question - the member wanted to know the formula to execute a BUY the next day after the signals is generated - meaning the BUY is execute at the next day's opening price.

As that's how I plan to trade I added Howard Bandy's code to my strategy.

Once I added the code to my strategy my Backtest results went from a yearly Net Profit of $26,044 to a yearly Net Loss of -$3,534

I wouldn't have thought buying the next day compared to buying the same day the signal is generated would make such a difference to my Backtest results.

Can anyone shed light on how this could be possible?

The Code I added
/////////////////////////////////////////////////
BuyPrice = Open;
SellPrice = Open;
SetTradeDelays(1,1,1,1);
/////////////////////////////////////////////////

skate.

In most cases you wont know if the buy signal has been generated until the end of the day, depending on what your buy conditions are. Therefore your code to buy on the same day as the signal is generated is looking into the future.
 
Thanks Trash!

Nice to see TJ posting to the KB these days (almost forgot about them). I did a Google-search but missed the item you provided.

Do you use the Osaka plugin? If so, any warnings before I go there. Having arrays of strings would be nice.
 
In most cases you wont know if the buy signal has been generated until the end of the day, depending on what your buy conditions are. Therefore your code to buy on the same day as the signal is generated is looking into the future.

Hi captain black

I'm not sure I understand your reply, a Buy signal is generated in my strategy when the close is greater than the Upper Donchian Channel Buy= C > DonchianUpper

Trade Delay CODE - Blocked yearly Net Profit $30,465 Trades 205 DD -6.47%
/////////////////////////////////////////////////
//BuyPrice = Open;
//SellPrice = Open;
//SetTradeDelays(1,1,1,1);
/////////////////////////////////////////////////

Same CODE - Not Blocked yearly Net Loss $-11,253 Trades 203 DD -18.57%
/////////////////////////////////////////////////
BuyPrice = Open;
SellPrice = Open;
SetTradeDelays(1,1,1,1);
/////////////////////////////////////////////////

QUESTION
Basic logic is telling me that by delaying ONE day to Buy the security could not make this HUGH difference in the Backtest results - my thinking is I've have placed the SetTradeDelay code in the wrong area of my strategy - is that possible?

skate
 
Top