Australian (ASX) Stock Market Forum

Amibroker FAQ

a = ma(c,10);
b = ma(c,20);
d = cross(a,b) and V*C>500000;
dd = sum(d,20)>0;
Filter = dd;
addcolumn(C*V,"indic. t/o");

Thanks Gringotts but I am looking to add other criteria to the scan based on what price is doing at the moment.

ie moving average cross anywhere within last 20 days and inside bar today.
 
Thanks Gringotts but I am looking to add other criteria to the scan based on what price is doing at the moment.

ie moving average cross anywhere within last 20 days and inside bar today.

a = ma(c,10);
b = ma(c,20);
d = cross(a,b) and V*C>500000;
dd = sum(d,20)>0; // cross anywhere in last 20 days
i = h<ref(h,-1) and l>ref(l,-1); //inside bar today
Filter = dd and i;
addcolumn(C*V,"indic. t/o");
 
a = ma(c,10);
b = ma(c,20);
d = cross(a,b) and V*C>500000;
dd = sum(d,20)>0; // cross anywhere in last 20 days
i = h<ref(h,-1) and l>ref(l,-1); //inside bar today
Filter = dd and i;
addcolumn(C*V,"indic. t/o");

Works great. Thanks Gringotts Bank. Silly me had date range set to most recent bar!:D:banghead::xyxthumbs:xyxthumbs
 
Works great. Thanks Gringotts Bank. Silly me had date range set to most recent bar!:D:banghead::xyxthumbs:xyxthumbs

That's fine.

For what you asked, you do actually want the date range set to the most recent bar. This will still find any MA cross in the last 20 days when you run an EXPLORATION on today's date. [plus an inside bar today - both conditions need to be met].
 
That's fine.

For what you asked, you do actually want the date range set to the most recent bar. This will still find any MA cross in the last 20 days when you run an EXPLORATION on today's date. [plus an inside bar today - both conditions need to be met].

Thank you again for your help Gringotts. :xyxthumbs

I've another question which you may be able to help with. If you can't that's fine too as you've helped me a lot already:

Would you know how I can scan for an up day which has volume greater than any down day's volume within the previous 5 days?

This is a far as I can get but as we can see it matches the current day's volume against all previous volumes no matter whether they were up volume or down volume days

XYZ= C>Ref(C,-1) AND V> Ref(HHV(V,5),-1);



I thought it would be straight forward but I am struggling with how to put the logic into AB to define the volume of updays versus down days.

Thanks again.
 
Thank you again for your help Gringotts. :xyxthumbs

I've another question which you may be able to help with. If you can't that's fine too as you've helped me a lot already:

Would you know how I can scan for an up day which has volume greater than any down day's volume within the previous 5 days?

I thought it would be straight forward but I am struggling with how to put the logic into AB.

Thanks again.

a = roc(c,1)<0;
b = ValueWhen(a,V,1);
bb = HHV(b,5);
Filter = ROC(C,1)>0 AND v>ref(bb,-1);
Addcolumn etc...
 
Hi all

Having a problem with some Ami code I cant seem to fix.

I am working on a simple system of buying the 250 day high and selling the 250 day low. My entry filters are Liquidity average being over 500,000 for the last 7 days and Turnover being higher than $500,000 for the last 7 days.

My problem is I would like to add the Turnover and Liquidity averages to the back test results. In the following cod I have managed to get the columns into the back test results but they have no data in them.

Any help would be much appreciated.

Thanks

SetTradeDelays( 1, 1, 0, 0 );
SetOption( "Initialequity", 100000 );
SetOption( "MaxOpenPositions", 20 );
SetPositionSize( 5, spsPercentOfEquity );

NewYearlyHigh = HHV( C, 250 );
Plot( NewYearlyHigh, "NewYearlyHigh", colorGreen, styleLine );
NewYearlyLow = LLV( C, 250 );
Plot( NewYearlyLow, "New Yearly Low", colorRed, styleLine );

Liquidity = EMA( V, 7 );
LiquidityOk = Liquidity >= 500000;

Turnover = EMA( C*V, 7 );
TurnoverOK = Turnover >= 500000;

SetCustomBacktestProc( "" );

if( Status( "action" ) == actionPortfolio )
{
bo = GetBacktesterObject();

bo.Backtest(); // run default backtest procedure
NumTrades = 0;

// iterate through closed trades first
for( trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade() )
{
trade.AddCustomMetric( "Liquidity", Liquidity );
trade.AddCustomMetric( "Turnover", Turnover );
NumTrades++;
}

bo.AddCustomMetric( "Liquidity", Liquidity );
bo.ListTrades();
}

Buy = C >= NewYearlyHigh AND( MarketID( 0 ) == 0 OR MarketID( 0 ) == 1 ) AND LiquidityOk AND TurnoverOk;
Sell = C <= NewYearlyLow;

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

P.S I am requiring the data for liquidity and turnover for two reasons. 1 I want to know the filter is working correctly and 2 I would like to know how to do it for future reference.
 
chipolte, in general you can find available functions by going to Help > Help Contents > AFL Function Reference (alphabetical and categorized).


Thanks Colion. I have had a look through there and was wondering if someone knows the short form of searching for a price cross above the 200day taking place within the past 20 days?

I was typing this but surely there is function for a shorter form?

cross(C,(MA(C,200) OR
cross(ref(C,-1),(ref(MA(C,200),-1))) OR
etc
etc
cross (ref(C,-200).................:bricks1:



Thanks in advance :)
 
Thanks Colion. I have had a look through there and was wondering if someone knows the short form of searching for a price cross above the 200day taking place within the past 20 days?

I was typing this but surely there is function for a shorter form?

cross(C,(MA(C,200) OR
cross(ref(C,-1),(ref(MA(C,200),-1))) OR
etc
etc
cross (ref(C,-200).................:bricks1:



Thanks in advance :)

please ignore. I forgot gringotts kindly answered me on this before.
 
Salaam everybody,

how can I add some space to the right side of my chart (for drawing my prediction arrows) in AmiBroker5.60?
(there is an option in the preference page as "blank bars in the right margin" but it didn't help)

thanks.
 
there is also another question/problem,
i want some alerts when price goes under a shape (trend line or horizontal line or a box or a circle)
it is possible now by "easy alerts" but it's not really easy! i want some kind of shapes.
 
there is also another question/problem,
i want some alerts when price goes under a shape (trend line or horizontal line or a box or a circle)
it is possible now by "easy alerts" but it's not really easy! i want some kind of shapes.

something like this:

AlertIf(Cross(Study("every_trendline_in_chart",GetChartID()),Close), "EXEC Calc.exe", "Launching external application",3);
 
Hi All,

I recently subscribed to LSE data through http://www.justdata.com.au/ which provides me with all historical listed U.K. listed equities however unlike Premium Data it does not include organised historical watch lists to check if a specific equity was included in an index at any given time i.e. FTSE100. Does anyone know if there is a way to do this?

Many thanks,

james
 
Hi All,

I recently subscribed to LSE data through http://www.justdata.com.au/ which provides me with all historical listed U.K. listed equities however unlike Premium Data it does not include organised historical watch lists to check if a specific equity was included in an index at any given time i.e. FTSE100. Does anyone know if there is a way to do this?

Many thanks,

james

James as I understand it this is basically due to the fact that the watchlist was created by the guys at Premium Data which would of taken them a bit of work.

If they provide a folder of delisted securities, you could create a custom list that incorporates the current FTSE100 and delisted stock data as a bit of a proxy, although that isn't ideal obviously.

Alternatively you could import a custom watchlist from excel, however you'd have to dig through the additions/subtractions of the index and give them custom symbols for the date range that they were included. And also ensure you have the delisted data to begin with.

A bit of work, however given the fact that it's only 100 stocks in the index it's manageable, but I wouldn't be surprised if over time you might have to dig through around 400 tickers.
 
Some other indices we've worked on...
The S&P 100 has had 217 constituents over the last 27 years.
The NASDAQ 100 has had 369 constituents over the last 21 years.
The S&P/ASX 100 has had 347 constituents over the last 24 years.

Your biggest challenge will be trying to match historical announcements with corporate actions, taking into account complex corporate restructures/spinoffs/mergers that muddy the waters considerably. Also, not all data vendors/index providers interpret the corporate actions the same way, so you often get a divergence which requires meticulous research.
 
hi all.

could anyone share the script to colour bars based on whether they are up or down?

So an up bar would be green and a downbar red

(as opposed to the standard colouring based on whether the close is higher than the open)

Thanks
 
Top