AmiBroker formula Language

#81
Here is the required AFL:

Code:
_SECTION_BEGIN("BarChart");
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 )) ));
UpColor = ParamColor("UpColor", colorBrightGreen);
DownColor = ParamColor("DownColor", colorRed);
MyColour = IIf(C >= O, UpColor, DownColor);
PlotOHLC(O,H,L,C,"Price", MyColour, styleBar);
Plot( Volume, _DEFAULT_NAME(), IIf(C>O, ParamColor("UpVolume", colorBlue), ParamColor("DownVolume", colorViolet)), ParamStyle( "Style", styleHistogram | styleOwnScale | styleThick, maskHistogram  ), 2 );
_SECTION_END();
Praveen.
Thanks a lot for workin this out BVP. But im gettin an error. General syntax error. Can u pls recheck.
 
#82
Dear praveen
Thanks for ur immediate reply, i'll try to learn something abt backtesting from user manual.
Keep on active in this thread.
Best wishes
Raj
 
#83
Thanks a lot for workin this out BVP. But im gettin an error. General syntax error. Can u pls recheck.
Hi Swagat,

I don't see any syntax error in the code. I double checked it. I'm using Amibroker 4.9.

Let me know the exact error which you are getting, along with the line where it is throwing the error.

Praveen.
 
#84
Dear praveen
Thanks for ur immediate reply, i'll try to learn something abt backtesting from user manual.
Keep on active in this thread.
Best wishes
Raj
Backtesting and Automatic Analysis are very powerful in Amibroker. Fortunately backtesting is simple and if you face any problems, post here. Amibroker users can try to help you out.

All the best,
Praveen.
 
#87
Dear Praveen and all,

Hi, i m back to disturb u all again.

Basically i m looking for an AFL for crossover of EMA 5 and EMA 13.

Buy when EMA 5 crosses from below EMA 13 and price also above the crossover
Sell when opposite happens
basically would like it for 30 or 60 minute, so that i can have stop loss as the low of previous bar for longs and vice versa for shorts.

I know i m asking for too much, but i have got a lot in past too.

with regards,

Sunil
 
#88
Dear Praveen and all,

Hi, i m back to disturb u all again.

Basically i m looking for an AFL for crossover of EMA 5 and EMA 13.

Buy when EMA 5 crosses from below EMA 13 and price also above the crossover
Sell when opposite happens
basically would like it for 30 or 60 minute, so that i can have stop loss as the low of previous bar for longs and vice versa for shorts.

I know i m asking for too much, but i have got a lot in past too.

with regards,

Sunil
Try this...

Buy=Cross(EMA(Close,3),EMA(Close,13));
Sell=Cross(EMA(Close,13),EMA(Close,3));
PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorBlue);
PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed);

Subrata Bera.
 
#89
...
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.
 

Similar threads