Need to convert my strategy into amibroker script

#11
@Bhulokeshwar

I am new to Amibroker. I see here that EMA periods are hardcoded into the script. In such a case, if one wants to optimize the EMA parameters, would one be able to do that, using Amibroker optimization button?

Is it possible to have a dialog box for keying in values for different EMAs and having these values as default? Such dialog box to be part of chart/script/initialization etc.?

Very nice to see experienced programmers fulfilling newbies requests. I hope that I shall be able to do the same for someone, someday!

@yogesh-tiwari

How have you found this strategy in 1. Manual Trading 2. Back-Testing the AFL 3. Trading using AFL signals in paper and real trading?

dear yogesh,good luck,i am giving complete afl as u required.do u want audible alarm also?
////////////////////////////////////////////
_SECTION_BEGIN("EMA CROSSOVER CHART");
LongPer = Param("Long Period", 13, 30, 100, 5);
ShortPer = Param("Short Period", 34, 30, 100, 5);
LongPer1 = Param("Long Period1", 3, 30, 100, 5);
ShortPer1 = Param("Short Period1", 5, 30, 100, 5);
LongMA = EMA(C, LongPer);
ShortMA = EMA(C, ShortPer);
LongMA1 = EMA(C, LongPer1);
ShortMA1 = EMA(C, ShortPer1);
LastHigh = HHV(H, LongPer);
GraphXSpace = 10;
Plot(LongMA, " EMA(C, " + WriteVal(LongPer, 1) + ")", colorBrightGreen, styleLine);
Plot(ShortMA, " EMA(C, " + WriteVal(ShortPer, 1) + ")", colorRed, styleLine);
Plot(LongMA1, " EMA(C, " + WriteVal(LongPer1, 1) + ")", colorBlue, styleLine);
Plot(ShortMA1, " EMA(C, " + WriteVal(ShortPer1, 1) + ")", colorBrown, styleLine);
Buy = Cross(LongMA, ShortMA);
Short = Cross(ShortMA, LongMA);
Cover = Cross(LongMA1, ShortMA1);
Sell = Cross(ShortMA1, LongMA1);
PlotShapes(shapeUpArrow * Buy, colorBrightGreen, 0, L, - 10);
PlotShapes(shapeDownArrow * Short, colorRed, 0, H, - 10);
PlotShapes(shapeUpArrow * Cover, colorBlue, 0, L, - 10);
PlotShapes(shapeDownArrow * Sell, colorBrown, 0, H, - 10);
Filter=Buy OR Sell;
Filter=Short OR Cover;
Sell=ExRem(Sell,Buy); Buy=ExRem(Buy,Sell);
Short=ExRem(Short,Cover); Cover=ExRem(Cover,Short);
AddColumn(Buy,"Buy");
AddColumn(Sell,"sell");
AddColumn(Short,"short");
AddColumn(Cover,"cover");
AddColumn(BuyPrice,"BuyPrice");
AddColumn(SellPrice,"SellPrice");
AddColumn(ShortPrice,"shortPrice");
AddColumn(CoverPrice,"coverPrice");
_SECTION_END();
 
#12
Hi Sanjay,

Good that you are trying to figure out a strategy that works well. Very instinctive attribute of an upcoming trader.

Anyways, coming to strategy, this has worked very well both on paper and realtime trading for me.

Few important points that you MUST keep in mind when you are using this one.
1. Keep very very strict stoplosses(you ll hit lot of stops in real trading), as rangebound market kills this strategy very badly.
2.Trending market would give huge profits.
3.There would be times when your stoploss would be hit and market would continue going in the same direction and by the time you get signal again, market would be exshauted already.
4.Moving averages have inherent time lag, so patience is the key, dont just jump in trade, look for confirmation.

Moving averages are the first thing that attracts every newcomer. I would suggest to do as much realtime paper trading as you can. Backtesting only gives an idea about how a strategy works. But realtime testing actually tests you.

There would be many instances when you ll see a signal(mostly during rangebound market) and after few stoploss hits, you wont take next trade fearing another stoploss hit.

Personally, I dont rely on moving averages anymore, they test a lot of patience.

Lastly, Keep looking for new ways to trade and test them realtime(without putting real money). It ll take few months for you to decide on a strategy or to develop one that suits you.(I did burn my hands, though). There are many strategies available on this website.

:thumb:

Regards
Yogesh
 
#15
//system:
Buy = (Cross( MACD(), Signal() ) AND Cross( RSI(), 30 )) AND Volume > 3*Ref(V,-1) AND V>50000;


//exploration
Filter = Buy;
AddColumn( Buy, "Buy", 1);
AddColumn( Volume, "Volume", 1);
AddColumn( Cross( MACD(), Signal() ), "MACD/Signal cross", 1);
AddColumn( Cross( RSI(), 30 ), "RSI / 30 cross", 1);
 

cbosein

Active Member
#17
Hi Yogesh,

Which Time frame you are using with this afl?

Thanks in advance,
Keerthi

Hi,

Fantastic!!

Work Well Done!! Kudoos to you friend.

It now works exactly,the way I wanted it to.

-----------------------------------------------

Thank you very much.

God Bless

Take care

Regards
Yogesh
 

cbosein

Active Member
#18
Hi AFL experts,

Can any one help writing AFL for my chart.

Condition: Averages values of last 5 periods/Time-frame of 5ema-High, 5ema-Low & 5ema-Close (i.e. ave. of 15 levels). For using in daily & Hourly charts.

Please help me.

Thanks in advance,
Keerthi
 

Similar threads