Australian (ASX) Stock Market Forum

Amibroker FAQ

1) Buying a stock that has just crossed its highest high for 100 days. i have this:

cond1=HHVBars(H,100) == 0;

Is this right?

2) How do i make the buy price the price of the highest high for 100 days plus one tick? Currently it buys at the closing price but i want the buy price to be the price of the highest high that the price has crossed

3) How do i set the sell price to be the price of the stop loss. Currently it sells at the closing price of the day that the stop was tripped

4) I used to have a position size code but i think it was wrong
I want something like this

Capital = 100000;
Risk = 0.01*Capital;
PositionSize = Risk/(Close-my stop price)

Obviously i put in my code for my stop price that is easy enough. I can't work out how to get the position size to work though. For example if my stop price is 50 cents and buy price is $1 my risk is 50 cents for that trade and my total risk (example) is $5 per trade therefore i could buy 10 shares. Can that be done properly?
 
Hi,

Been stuck on this for days and wondering if someone can lend me a hand. I'm trying to obtain the highest volume that can be seen on the chart. I've managed this so far;

fvb = Status("firstvisiblebar");
MaxVol = LastValue(HHV(Volume, fvb));


What I'd like to do is zoom out, and allow "fvb" to recalculate.

i.e.
a) say the chart has 20 bars of data. fvb = 20
b) then I zoom out and now the chart has 40 bars. How can I get fvb now to equal 40? As in "auto-refresh" itself and then consequently, MaxVol is recalculated?

Appreciate any help. =)
 
The HHV function's second parameter is the number of days back from the current bar, not an absolute bar number. So try this instead:

fvb = Status("firstvisiblebar");
lvb = Status("lastvisiblebar");
hvol = HHV(Volume, lvb-fvb+1);
MaxVol = ValueWhen(lvb, hvol);

This is just off the top of my head, but I think it should work.

GP
 
This is a very basic question - does anyone know how to retain historical data in AmiBroker when IB is the data source? I am using intraday intervals and it only keeps a certain amount in the database. I have increased the number of bars in database settings, but it doesn't seem to make much difference.

I would also like to start accumulating daily charts for the SPI. Have set up a new database linked to IB data and selected EOD, but it ignores that and defaults back to one minute.

Any thoughts?
 
1) Buying a stock that has just crossed its highest high for 100 days. i have this:

cond1=HHVBars(H,100) == 0;

Is this right?
No, that is only equal to the HHV value, not crossed it. You want something like this:

cond1 = High > Ref(HHV(H, 100), -1);

That would be 99 instead of 100 if you count the crossing day as part of the 100 days.

2) How do i make the buy price the price of the highest high for 100 days plus one tick?
Set BuyPrice to Ref(HHV(H, 100), -1) plus whatever extra amount you want.

3) How do i set the sell price to be the price of the stop loss. Currently it sells at the closing price of the day that the stop was tripped
If you're doing the stop-loss yourself, set SellPrice to that value. If you're using the ApplyStop function, I'm not sure off the top of my head.

4) I used to have a position size code but i think it was wrong
I want something like this

Capital = 100000;
Risk = 0.01*Capital;
PositionSize = Risk/(Close-my stop price)

Obviously i put in my code for my stop price that is easy enough. I can't work out how to get the position size to work though. For example if my stop price is 50 cents and buy price is $1 my risk is 50 cents for that trade and my total risk (example) is $5 per trade therefore i could buy 10 shares. Can that be done properly?
That code looks okay to me, assuming you want the risk always based on $100K and not current equity. What's not working about it?

GP
 
GP,

Thanks. I will give that a go.


Sails,

Have you tried clicking the intraday settings (under database settings) and marking the "Allow mixed EOD/Intraday data"?

Also, enable the local data storage too.
 
GP,

Thanks. I will give that a go.


Sails,

Have you tried clicking the intraday settings (under database settings) and marking the "Allow mixed EOD/Intraday data"?

Also, enable the local data storage too.

Thanks EC - I did try it once but didn't seem to make much difference. Will try it again for a bit longer this time. Yes, local data storage has been enabled from the beginning.
 
Can anyone tell me how to retain the bar size once adjusted to what you want?

The template doesn't save it and I cannot fine any way of retaining after closing AB.

Any ideas AB gurus?

Thanks

.
 

Attachments

  • AB Bar size.jpg
    AB Bar size.jpg
    127.4 KB · Views: 17
Search the AB help files for "GraphXSpace"

If it's not specified in your formula AB uses a default level of GraphXSpace=2; which adds space of 2% above and below the chart when it's opened. Adjusting the GraphXSpace variable is the same as zooming/increasing/decreasing bar height.
 
Search the AB help files for "GraphXSpace"

If it's not specified in your formula AB uses a default level of GraphXSpace=2; which adds space of 2% above and below the chart when it's opened. Adjusting the GraphXSpace variable is the same as zooming/increasing/decreasing bar height.

Thanks Captain spot on I can vary the chart and it saves the last setting thanks again for your help
 
You could also adjust the settings manually via the "Parameters" box by adding something like:

GraphXSpace=Param("zoom",25,-20,50,5);

..to your formula. This would allow you to adjust settings manually and they would be saved the next time you open Amibroker. As with all things in AB there's several ways of doing things , (the new Gfx functions have opened up many new possibilities), it's just a matter of finding a way that suits your needs, whether that be formula based or gui based or a combination of both.
 
You could also adjust the settings manually via the "Parameters" box by adding something like:

GraphXSpace=Param("zoom",25,-20,50,5);

..to your formula. This would allow you to adjust settings manually and they would be saved the next time you open Amibroker. As with all things in AB there's several ways of doing things , (the new Gfx functions have opened up many new possibilities), it's just a matter of finding a way that suits your needs, whether that be formula based or gui based or a combination of both.

AB is amazing, saved the formula as a custom drag and drop in charts boom all charts fixed.
 
I'm trying to do a simple volume scan. All I want is a scan where the volume closes higher than the 2 standard deviations of its 20 day average.

I currently have this; Buy = Close > BBandTop( Close, 20, 2 );

However it is giving me results when the volume was higher not only today but for close's many days ago.

Can anyone help?

Sammy
 
Hi guys, have just subscribed to ASX data from my broker, and have a list of 500 stocks in excel with sector information that I'd like to add to AB.

Have been successful in using the Import function to add the symbols and their names, however not sure how to add the sector info. When I use the wizard, I can specify that ticker and full name of the symbol are in Column 1 and 2, however there is no option to specify the sector - ie. to get it to pick up sector info from Excel column 3 and add it to AB. Is there a way for me to achieve this?

Also, now I"ve got some 500 symbols with no data in AB under one watchlist, is it possible to do a "open all" so I can backfill all of them instead of doing one by one at a time?

Thanks any help appreciated!
 
Just bought amibroker the other day, and am having a bit of trouble getting the free data trial from Norgate (premium data) working. I think i have followed all the instructions as per the website, but still having no luck. Anyone have any ideas what i'm doing wrong?

Cheers,

Shaun.
 

Attachments

  • norgate.jpg
    norgate.jpg
    22.9 KB · Views: 2
Just bought amibroker the other day, and am having a bit of trouble getting the free data trial from Norgate (premium data) working. I think i have followed all the instructions as per the website, but still having no luck. Anyone have any ideas what i'm doing wrong?

Cheers,

Shaun.

Make sure you follow the instructions on the site
It's hard to tell what you have done because that screen just tells me you havn't either:

  • Downloaded the data
  • Set the database to C:/ProgramFiles/Amibroker/Asx-PremiumData (think that is the path, im not at home)
  • Used the Premium Data Database thingy in the Tools? menu (again not at home can't check)
  • Set the database to MetaStock plugin data

There are a few things that it could be
The instructions Richard Gives are pretty good

If you are still stuck try sending an email to support@premiumdata.net, they are pretty fast to reply

Cheers
Brad
 
I'm trying to do a simple volume scan. All I want is a scan where the volume closes higher than the 2 standard deviations of its 20 day average.

I currently have this; Buy = Close > BBandTop( Close, 20, 2 );

However it is giving me results when the volume was higher not only today but for close's many days ago.

Can anyone help?

Sammy


Do you still need this Sammy?
I've recently coded a system using Standard Deviations of Volume over a 30 day period, it would be easy to change around and adapt for your code if you like?

Cheers
Brad
 
Top