Australian (ASX) Stock Market Forum

Amibroker FAQ

Trash, just a slight clarification of the above when put in the context of data sources.

"Quotation data" is always stored when you have "data source" as "(local database)". If you use a data source (such as MetaStock, eSignal etc.) then price data will be cached in this database too, upon accessing the symbol within AmiBroker if you have "Local data storage" set to Enable.

Information data (what I call "metadata" regarding a security - market/group/shares outstanding/EPS etc.) is stored in two locations - once inside broker.master and secondly within the individual symbol file within the subfolders. If you delete the broker.master file, it will regenerate it from all of the individual files upon startup/opening that database. That takes a while though if you have thousands of symbols.
 
Trash, just a slight clarification of the above when put in the context of data sources.

"Quotation data" is always stored when you have "data source" as "(local database)". If you use a data source (such as MetaStock, eSignal etc.) then price data will be cached in this database too, upon accessing the symbol within AmiBroker if you have "Local data storage" set to Enable.

Yes, that's correct.

Information data (what I call "metadata" regarding a security - market/group/shares outstanding/EPS etc.) is stored in two locations - once inside broker.master and secondly within the individual symbol file within the subfolders. If you delete the broker.master file, it will regenerate it from all of the individual files upon startup/opening that database. That takes a while though if you have thousands of symbols.

Yes, that's correct too.
FYI, I have posted it in database management thread few days back (for cases where some symbol(s) and their information(s) would get lost for some reason).
http://amibrokerforum.proboards.com/thread/220/database-management
 
Question 1: It seems like User defined function don't return range of numbers as it does return without using function ..

Code:
SetBarsRequired( -2, -2 );
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
 

function tf_ma(e,d)
{
global i;
for (i=e; i<d; i++)
{
  tf = i * in1Minute;
  TimeframeSet(tf);
    meme =MA(C, 15);
   TimeframeRestore();
}
 m = TimeFrameExpand(meme,tf,expandPoint);
 for( b = 0; b < BarCount; b++ ) {
      //PlotText(" " , b, L[ b ], colorRed, colorDefault, -12 );
      if(m[b])  PlotText(" "+(i), b, L[b]-1-(i), colorCustom1);
   }
 return m;
}
 tf_ma(1,3); // calling the function

Question 2:


If you want to overlay Daily Timeframe Chart on Weekly Chart .. (Lower timeframe on higher timeframe )

1. Open Weekly timeframe

2. code:
Code:
_SECTION_BEGIN("Formula");
ddo = TimeFrameGetPrice( "O", inDaily, 0, expandPoint );
dh = TimeFrameGetPrice( "H", inDaily, 0, expandPoint );
dl = TimeFrameGetPrice( "L", inDaily, 0, expandPoint );
dc = TimeFrameGetPrice( "C", inDaily, 0, expandPoint );

PlotOHLC( ddo, dh, dl, dc, "Daily Close", colorWhite, styleCandle );
Plot( Close, "Daily Close", colorBlue );
_SECTION_END();

It doesn't work .. (Lower to Higher timeframe doesn't work )
Vice versa as usual Higher to lower (weekly on daily timeframe) does work ..

Lower to Higher timeframe ?? No ..

Happy New Year ??
 
Hi all and a happy new year.

I am having real trouble with writing this. Can anybody help please?

I am looking to identify days where the volume is greater than any DOWN DAY's volume over the past 5 days.

The part in bold is what i can't figure out ie so that we are ignoring and previous UP day volume in the past 5 days.

This is as far as I can get but obviously it is not what I want as is taking into account all days no matter if they were up days or down days.

V>ref(HHV(V,5),-1);

Thanks for any help.
 
Hi all and a happy new year.

I am having real trouble with writing this. Can anybody help please?

I am looking to identify days where the volume is greater than any DOWN DAY's volume over the past 5 days.

The part in bold is what i can't figure out ie so that we are ignoring and previous UP day volume in the past 5 days.

This is as far as I can get but obviously it is not what I want as is taking into account all days no matter if they were up days or down days.

V>ref(HHV(V,5),-1);

Thanks for any help.

I have a feeling I answered this a while back for you....?

a = ROC(C,1)<0;
aa = ValueWhen(a,V,1);
b = HHV(aa,5);
d = V>Ref(b,-1);
 
I have a feeling I answered this a while back for you....?

a = ROC(C,1)<0;
aa = ValueWhen(a,V,1);
b = HHV(aa,5);
d = V>Ref(b,-1);

Thanks again Gringotts. That's pretty darn good. Is there any way to do this without the ROC formula as that seems to filter out some days where the rise in price isn't that great?
 
Thanks again Gringotts. That's pretty darn good. Is there any way to do this without the ROC formula as that seems to filter out some days where the rise in price isn't that great?

Yes, nice code GB!

Chipotle, the code does what you asks - a is TRUE when there is a down day, then "aa" is a volume series when based on "a" being true.

If you want the condition to be a relative change (other than just a "down day") there is nothing to stop you changing the <0 to <x, where x is the % change you want to test against. I don't useROC a lot and would have to double-check references, but if you want a price series based on today's price being less than or equal to 10% increase on yesterday, think this would do the job:

a = ROC(C,1)<10;
 
Hoping someone can help me with multi-timeframe backtesting. I've read the AB tutorial many times and always got hung up. Time I got this sorted.

So could someone please post a code for something like the following, including what A/A time frame settings to use:

"if yesterday's daily close observed a stochastic cross, then today, buy MA cross on 5 minute time frame".

TIA
 
Hi All,

I'm looking to find out a little bit more information about this function. Like most I currently use Norgate for Australian & U.S. equity data however I've also starting building databases for other exchanges as well importing through the Import Wizard. I have the dates that specific equities joined and left the index i.e. FTSE100. I'm trying to figure out if it is possible to use the IsIndexConstituent function with this information or if there is a different function that would work equally as well.

At the moment I am building quarterly watch lists which contain the equities included for the quarterly re balance. This almost works perfectly except for when a intra-quarter addition/removal happens due to M&A hence why I am looking to be able to utilize something similar to the IsIndexConstituent function.

Any help is greatly appreciated!

Many thanks,

James
 
Hoping someone can help me with multi-timeframe backtesting. I've read the AB tutorial many times and always got hung up. Time I got this sorted.

So could someone please post a code for something like the following, including what A/A time frame settings to use:

"if yesterday's daily close observed a stochastic cross, then today, buy MA cross on 5 minute time frame".

TIA

How about you starting to write a code the way you think it would work and then it gets corrected here?

Let's start with baby steps:
1. Getting yesterday's daily stoch cross through some level being viewed from intraday interval.
 
How about you starting to write a code the way you think it would work and then it gets corrected here?

Let's start with baby steps:
1. Getting yesterday's daily stoch cross through some level being viewed from intraday interval.

Thanks for the reply. I figured it out eventually.
 
Hi all

new to the forum and AFL!

i can mange the basics ok but stuggle on the custom back test

what i am trying to do is:
I use Norgate premium data,

what I am trying to do is rank the 10 industry groups based on ROC. I plan to use ETF tickers for this.

Once ranked i then want to buy the weakest 2 stocks based on ROC in the top 3 industry groups

is it possible to do this multi level ranking?

Thanks!!!
 
Hi All,


I’m starting to do some futures testing and looks for some help on position sizing. Is anyone able to point me to where I can find different position sizing methods for futures?


Specifically looking to be able to base the position size on risk parity i.e. calculate the number of contracts to buy = (0.001 x equity)/(ATR50 * PointValue).


The logic behind this is that multiplying the average true range by the point value of the specific futures contract results in how much profit/loss to expect from a normal days movements. Setting the risk factor to 0.001 meaning I’m willing to get an impact of 0.1% on my portfolio, and therefore need to multiply the risk factor with the portfolio equity to arrive at the daily impact in dollars. Then dividing this by the expected average impact of each contract fives the number of contracts to buy.


My understanding is that the calculation should look like this, however I’m having difficulty with the equity part of the equation. Does anyone know how to pull in the current equity portfolio value?


Riskfactor = Param("Risk Factor",0.01,0.005,1,0.005);

Risk = (Riskfactor*Equity())/(Ref(ATR(50),-1) * PointValue);

PositionSize = Risk * MarginDeposit;

Any help is greatly appreciated.

Thanks,

James
 
Hi All,


I’m starting to do some futures testing and looks for some help on position sizing. Is anyone able to point me to where I can find different position sizing methods for futures?


Specifically looking to be able to base the position size on risk parity i.e. calculate the number of contracts to buy = (0.001 x equity)/(ATR50 * PointValue).


The logic behind this is that multiplying the average true range by the point value of the specific futures contract results in how much profit/loss to expect from a normal days movements. Setting the risk factor to 0.001 meaning I’m willing to get an impact of 0.1% on my portfolio, and therefore need to multiply the risk factor with the portfolio equity to arrive at the daily impact in dollars. Then dividing this by the expected average impact of each contract fives the number of contracts to buy.


My understanding is that the calculation should look like this, however I’m having difficulty with the equity part of the equation. Does anyone know how to pull in the current equity portfolio value?


Riskfactor = Param("Risk Factor",0.01,0.005,1,0.005);

Risk = (Riskfactor*Equity())/(Ref(ATR(50),-1) * PointValue);

PositionSize = Risk * MarginDeposit;

Any help is greatly appreciated.

Thanks,

James


i think use SETOPTION UsePrevBarEquityForPosSizing

for risk can use:
Risk = 2;
PstSize = Risk * buylimitprice / StopAmount;
SetPositionSize( pstsize, spspercentofequity );
 
Hi Wysiwyg,

Thanks for that, originally I thought this would not work correctly given I was looking for it to have no great impact than 0.2% of my total equity per day. However after manually calculating the position size based off the number of contracts and matching it against this it works perfectly.

Thanks for the help,

James
 
Hi guys,

I am writing a strategy that uses daily bars but trades only once a week. I can't change the time frame to weekly because I need daily bars for certain reasons.

I need a code snippet that returns a true condition if it is the first trading day of the week. Can anyone help me out? I've tried a few things and gotten close but nothing I am prepared to rely on for live trading.

Cheers
rb
 
Top