AmiBroker formula Language

Dear Praveen & Subratabera,

Thanx for providing me with the afl. My apologies for replying so late.

AFL works fine, but when i backtest it, it gives only for longs, whereas shorts should also be there. As per the system when a long is closed, then short is intiated at that very same time.

Is it possible to incorporate that too in AFL.

Thx for all the help and looking forward to an early reply.

Sunil

p.s. How do i add ur message while replying, at the moment i m just copying and pasting
Unread 22nd March 2007, 07:56 AM
bvpraveen bvpraveen is offline
Senior Member

Join Date: May 2006
Location: Bangalore
Posts: 605
bvpraveen is on a distinguished road
Default Re: AmiBroker formula Language
Quote:
Originally Posted by sunilhv0 View Post
...
Basically i m looking for an AFL for crossover of EMA 5 and EMA 13.
...
Hi,

To add to Subratabera's code, the below AFL is the generalized one. You can give any EMA periods to both short and long periods.

You can use it for Explore also in Automatic Analysis.

Code:

_SECTION_BEGIN("EmaCrossoverSystem");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));

ShortPeriod = Param("ShortPeriod", 5, 2, 200, 1);
LongPeriod = Param("LongPeriod", 13, 2, 200, 1);

Buy=Cross(EMA(C,ShortPeriod),EMA(C,LongPeriod));
Sell=Cross(EMA(C,LongPeriod),EMA(C,ShortPeriod));

MYcolor = IIf( EMA(C,ShortPeriod) > EMA(C,LongPeriod) AND C>Peak(C,3,1), colorBrightGreen, IIf(EMA(C,LongPeriod) > EMA(C,ShortPeriod) AND C<Peak(C,3,1), colorRed, colorBlue));
PlotOHLC( Open, High, Low, Close, "", Mycolor, styleBar );

shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorGreen, colorRed ),0, IIf( Buy, Low, High ) );

Filter=Buy OR Sell;

SetOption("NoDefaultColumns", True );
AddColumn( DateTime(), "Date", formatDateTime );
AddTextColumn( FullName(), "Full name", 77 , colorDefault, IIf( Buy, colorGreen, colorRed ) );
AddColumn( IIf( Buy, 66, 83 ), "Signal", formatChar, colorDefault, bkcolor =IIf (Buy,colorGreen, colorRed ));
_SECTION_END();

Praveen.
Reply With Quote
 
...
As per the system when a long is closed, then short is intiated at that very same time.

Is it possible to incorporate that too in AFL.
...
Just make this changes:
Buy = Cover = Cross(EMA(C,ShortPeriod),EMA(C,LongPeriod));
Sell= Short = Cross(EMA(C,LongPeriod),EMA(C,ShortPeriod));

p.s. How do i add ur message while replying, at the moment i m just copying and pasting
Click the "Quote" button at the right bottom corner of the post.

Praveen.
 
Just make this changes:
Buy = Cover = Cross(EMA(C,ShortPeriod),EMA(C,LongPeriod));
Sell= Short = Cross(EMA(C,LongPeriod),EMA(C,ShortPeriod));


Click the "Quote" button at the right bottom corner of the post.

Dear Praveen,

Thx for such an early reply, it is working fine, wll fine tune it further with ur help.

Thx a lot

Sunil
 
hello!!

Can somebody help me?
How can I set that display function wich allows to see the candles:
-if Close price higher then the last close price and within day the close price is higher then open price green hollow candle(normally can set in)
-if Close price higher then the last close price BUT within day the close price is lowest than open price fully green candle!!
-if Close price lowest than last Close price fully red candle
- if Close price lowest than last Close price BUT within day Close price is higher than Open price posible to show red hollow candle?
I tried to setup on Preferences but this option is not allowed.If I colouring the candles I cant see the hollow candles(bullish days).I think it need a new formula but couldnt made it.
Thank you very much if you can help ...
 
hello!!

Can somebody help me?
How can I set that display function wich allows to see the candles:
-if Close price higher then the last close price and within day the close price is higher then open price green hollow candle(normally can set in)
-if Close price higher then the last close price BUT within day the close price is lowest than open price fully green candle!!
-if Close price lowest than last Close price fully red candle
- if Close price lowest than last Close price BUT within day Close price is higher than Open price posible to show red hollow candle?
I tried to setup on Preferences but this option is not allowed.If I colouring the candles I cant see the hollow candles(bullish days).I think it need a new formula but couldnt made it.
Thank you very much if you can help ...
Hi,

Go through this discussion and see if it helps you out:
http://finance.groups.yahoo.com/group/amibroker/messages/75715?threaded=1&m=e&var=1&tidx=1

Praveen.
 
dear friends,

I am using Futures Intra-day data provided by Soumya for study, especially NIFTY Fut. The Data is in Tick format which I can see in 1min, 5min, 15min, 1hr format easily. I want to create AFLs where the tick data will automatically get converted into 5min, 10 min, 15min, 30min and 1hr chart....

For this purpose I will have to use TimeFrameSet(). Can anybody help me
how to use this function for required time period mentioned?

have a nice day
JB
 
Hello friends,

Is it possible to fomulate Modified Moving Average in AFL?
MAV is discussed in New Commodity Trading by Kaufman and Trading DiNapoli Levels by Joe DiNapoli

Formula of MAV is as follows:

MAVt=MAVt-1 + (P1 - MAVt-1)/n

where
MAVt is the current Modified Moving Average value
MAVt-1 is the previoud days Modified Moving Average value
P1 is current price
n is number of periods
The starting point is calculated identically to that of a simple Moving Average.

Thanks

Sudesh
 

Similar threads