Help for Amibroker Function & AFL

#1
Hi everyone,

I want your help to convert following Metstock function in Amibroker function:

(1) IsDefined( )
(2) BBandTop(c,15,E,3)
(3) BBandTop(c,15,S,3)
(4) PREV


In amibroker we use BBandTop(c,15,3) but how to enter simple or exponantial period.

Following is an AFL in which I want to explore Buy & Sell price for last 1 yrs of every stock:

aa=Cross(C,EMA(C,20));
bb=Cross(EMA(C,20),C);
state=IIf(BarsSince(aa)<BarsSince(bb),1,0);
state>Ref(state,-1);
Buy = state>Ref(state,-1);
Sell = state<Ref(state,-1);

Cll=IIf(Buy,C,0);
sll=IIf(Sell,C,0);

Filter=Buy ;

AddColumn(Cll,"Bvalue");
AddColumn(sll,"svalue");


But when I run explore it give "0" in sell price column.
Please guide me what changes should I do in the above afl.

Regards,

(moneypick)
 
#2
Hi,

As I don't know Metastock language, I'm not able to help with your first query. Can you give me the link for Online reference of Metastock language?

I think Prev means previous bars signal of an array. In AFL, its 'ref'.

Regarding your AFL, I didn't understand it. If you can explain it, we can try to give/correct the AFL.

Praveen.
 
#3
Hi BV,

Here is description of metastock function for your perusal:

bbandtop( DATA ARRAY, PERIODS, METHOD, DEVIATIONS )
EXAMPLE:bbandtop( close, 10, S, 2 )

FUNCTION Calculates the top Bollinger Band of DATA ARRAY using METHOD calculation method and shifted upward DEVIATION standard deviations. Valid methods are SIMPLE, EXPONENTIAL, WEIGHTED, TIMESERIES, TRIANGULAR, and VARIABLE (these can be abbreviated as S, E, W, T, TRI, and VAR).

My question is, how shall we use METHOD in Amibroker.

-------------------
isdefined(DATA ARRAY)

FUNCTION Returns 1 if all data necessary to calculate the formula is available, 0 if not.

EXAMPLE The formula "isdefined(mov(c,20,s))"
will return a 0 if there are less than 20 periods of data loaded in the chart.
------------------------
The PREV constant allows you to create self-referencing formulas. A self referencing formula is one that is able to reference the "previous" period's value of itself.
For example, the following is an example of a self referencing formula:
((H+L+C)/3) + PREV
This simple formula divides the high, low, and closing prices by 3 and then adds this value to yesterday's value of the ((H+L+C)/3).
The calculation of the popular indicator On Balance Volume illustrates the use of the PREV function.

(if(c>ref(c,-1),1,-1)*volume)+PREV
Although On Balance Volume can be calculated without the use of the PREV function, an exponential moving average cannot (other than using the mov() function). The following formula shows how a 18% exponential moving average (approximately 10-periods) is calculated using the PREV function.
(close*0.18)+(PREV*0.82)
------------------------------

I have a system and I want to know closing price of every stock when BUY and SELL signal occurs. condition is --Every time Sell price after buy price. The said AFL created for that purpose.

Regards,

(moneypick)