AFL coding, Plz Help !!!

I

indiabulz

Guest
#1
Hello Traderji,

I am a swing trader and recently bought Amibroker 5.30. I have a trading system which needs to be coded as per AFL. Kindly Help me.

Chart: Daily
Indicators: Slow Stochstic (9,2), SMA 90.

Buy = When Slow Stochastic (9,2) crosses the 20 Level from below & Closing price is above the 90 SMA.

In other words, Slow Stochastic (9,2) (Today) > 20 & Slow Stochastic (9,2) (Yesterday) =< 20.

Sell = After 5 trading days from the day of buying. i.e. after 5 candles on a daily candlestick chart.

I also want a Blue Arrow indicating Buy signal and Red Arrow indicating sell signal on the chart.


I would be greatly Thankful if anybody could help me in this regard. Thanks in Advance.
 
#2
hi indiabulz

have you tried the afl code wizard? it's built into ab and might help you, i'm still learning it myself. Good luck!
 

iamaaditya

Active Member
#3
Hello Traderji,

I am a swing trader and recently bought Amibroker 5.30. I have a trading system which needs to be coded as per AFL. Kindly Help me.

Chart: Daily
Indicators: Slow Stochstic (9,2), SMA 90.

Buy = When Slow Stochastic (9,2) crosses the 20 Level from below & Closing price is above the 90 SMA.

In other words, Slow Stochastic (9,2) (Today) > 20 & Slow Stochastic (9,2) (Yesterday) =< 20.

Sell = After 5 trading days from the day of buying. i.e. after 5 candles on a daily candlestick chart.

I also want a Blue Arrow indicating Buy signal and Red Arrow indicating sell signal on the chart.


I would be greatly Thankful if anybody could help me in this regard. Thanks in Advance.
here is the code.. its very simple strategy and i have assumed you will used EOD data or Daily view (since you mentioned 5 days), if you want to formula to still work while viewing intraday chart, then it will have to be modified, let me know in that case....

// code for indiabulz by iamaaditya
// june 05, 2010

Buy = Cross(StochK(9,2), 20) AND C > MA(C, 90);

Sell = Ref(Buy, -5);

PlotShapes(Buy*shapeUpArrow, colorBlue);
PlotShapes(Sell*shapeDownArrow, colorRed);


Plot(C, "c", colorWhite, styleCandle);


P.S: remove the last line (plot(C)...), and you can drag and drop this formula on any chart/inidicator..
 
I

indiabulz

Guest
#4
here is the code.. its very simple strategy and i have assumed you will used EOD data or Daily view (since you mentioned 5 days), if you want to formula to still work while viewing intraday chart, then it will have to be modified, let me know in that case....

// code for indiabulz by iamaaditya
// june 05, 2010

Buy = Cross(StochK(9,2), 20) AND C > MA(C, 90);

Sell = Ref(Buy, -5);

PlotShapes(Buy*shapeUpArrow, colorBlue);
PlotShapes(Sell*shapeDownArrow, colorRed);


Plot(C, "c", colorWhite, styleCandle);


P.S: remove the last line (plot(C)...), and you can drag and drop this formula on any chart/inidicator..
THANKS a lot Aaditya for you response. I have some modifications to be done with this formula. Can i have your Mail ID or phone number plz.
 

iamaaditya

Active Member
#5
Hey, why don't you put the request for changes here so that even others will be able help and some more will benefit,

I don't have problem giving my email. its : aaadityaprakash@ g m a i l.c o m (remove the spaces after @).

but do consider my request...

Happy Trading....
 
Last edited:
I

indiabulz

Guest
#6
Hey, why don't you put the request for changes here so that even others will be able help and some more will benefit,

I don't have problem giving my email. its : aaadityaprakash@ g m a i l.c o m (remove the spaces after @).

but do consider my request...

Happy Trading....
Hello Aaditya, Just a small modification in the given formula. In the condition to buy i want to ADX>30 which would assure a good trend. Kindly re-write the formula plz.
 

iamaaditya

Active Member
#7
Hello Aaditya, Just a small modification in the given formula. In the condition to buy i want to ADX>30 which would assure a good trend. Kindly re-write the formula plz.
That's simple.....

Code:
// code for indiabulz by iamaaditya
// june 05, 2010

Buy = Cross(StochK(9,2), 20) AND C > MA(C, 90) AND ADX(14) > 30;

Sell = Ref(Buy, -5);

PlotShapes(Buy*shapeUpArrow, colorBlue);
PlotShapes(Sell*shapeDownArrow, colorRed);


Plot(C, "c", colorWhite, styleCandle);
P.S: remove the last line (plot(C)...), and you can drag and drop this formula on any chart/inidicator..

I have assumed the parameter you want to use for ADX is its default value 14, change it to any other value like ADX(28) or ADX(Param("ADX",14, 1, 100, 1 )), this will allow you to change the value from parameter window...
 
#8
Dear, I want to learn AFL coding. Any Ebook to download, or web references? I`ve searched a lot, and found nothing. Even nothing is in web on AFL Code Wizard of amibroker. SOS!
 

iamaaditya

Active Member
#9
Dear, I want to learn AFL coding. Any Ebook to download, or web references? I`ve searched a lot, and found nothing. Even nothing is in web on AFL Code Wizard of amibroker. SOS!
Start here : http://www.amibroker.com/guide/tutorial.html

Also download the PDF on Amibroker User Guide.

And remember the most important thing for learning AFL (also applies to all programming languages), you must start writing codes, try different ideas, you will get bugs and then when you resolve those bugs you will start mastering the languages.

Also studying AFLs from Amibroker library is good idea because most of them are well documented..

and ofcourse traderji members are always there to help you at any stage....

all the best
 
#10
..and ofcourse traderji members are always there to help you....

all the best
`and ofcourse traderji members are always there to help you....'. . Yes my brother, traderji, it`s resources like you, and specially Zultan, all are great. Aneway, i will try to follow your tips.
 

Similar threads