AFL writing guide for new user

#61
Hi, I have a problem with the code below:

Code:
MA1 = MA(C, 32);
MA2 = MA(C, 16);

trig = Cross(MA2, MA1);
vLINE = Ref(trig, 16);

LLBars= LLVBars(L, 16 + 5);
pd = ValueWhen(trig,LLBars,0);
vLINELow = Ref(trig, pd);


//Plot(MA1, "MA1", colorYellow, styleLine);
//Plot(MA2, "MA1", colorBlue, styleLine);

Plot(vLINElow, "", colorGrey50 , styleArea|styleOwnScale);
It basically draws a vertical line to the lowest low over the previous 16 days preceding the fast MA crossing the slow MA. The main goal of this formula is to detect past cycles.

However, the way the formula is written, it won't be able to skip whipsaws.

I maen, if the MA(16) crosses MA(32) from below, the formula will go search the lowest low over the preceding 16 days, to detect the starting point of the cycle. Yet, if then the MA(16) soon crosses back the MA(32) from above the there's no point in drawing the line. Because that is a whipsaw.

So, as a general rule, if the MA(16) crosses MA(32) from below, then the cycle will be labeled by the vertical line (at the lowest low over the preceding 16 days the crossover) as long as the MA(16) does not cross back MA(32) from above over the next 16 days at least.

How can I add this rule to the formula?

Thanks

NB: picture below, you get to see at the very left of the chart the yellow crossing the orange from below. The formula is wrong in drawing the vertical line, because then the yellow shortly after crosses the orange from above...only 3/4 days later. So, the first vertical line should not be drawn.

Later on, you see one more crossover. The yellow crosses the orange from below and the formula draws a vertical line to the lowest low over the past 16 days. The formula is right, in fact, next time yellow crosses back orange from above is more then 16 days later...

Hopefully I made my self understood.

Thanks
 

Attachments

#64
#66
Heiken Ashi with Averrage Line : AFL

Code:

SetChartOptions(0,chartShowArrows | chartShowDates);
SetChartBkColor( colorBlack);
HaClose = (O + H + L + C)/4;
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
xDiff = (HaHigh - Halow) * 10000;
barcolor = IIf(HaClose >= HaOpen,colorWhite, 31);
PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "", barcolor, styleCandle );

PlotOHLC( IIf(HaClose >= HaOpen,HaHigh + 0.2, HaLow - 0.2), IIf(HaClose >= HaOpen,HaHigh + 0.2, HaLow - 0.2), IIf(HaClose >= HaOpen,HaHigh + 0.2, HaLow - 0.2), IIf(HaClose >= HaOpen,HaHigh + 0.2, HaLow - 0.2 ), "", colorGreen, styleLine );

PlotOHLC( IIf(HaClose >= HaOpen, HaLow - 0.2, HaHigh + 0.2), IIf(HaClose >= HaOpen, HaLow - 0.2, HaHigh + 0.2), IIf(HaClose >= HaOpen, HaLow - 0.2, HaHigh + 0.2 ), IIf(HaClose >= HaOpen, HaLow - 0.2, HaHigh + 0.2 ), "", colorRed, styleLine );



I think this is very close to the picture you gave me.


Debarghya Mukherjee brother can u help me please created this afl please if u kind (http://c1109.hizliresim.com/11/9/15/15029.png) thanks a lots
 
#67
hay dost you have done a fantastic job here, this thread has helped me a lot in understanding the AFL's and i hope i can write one or two AFL's as per my requirement now.:clap:
 
#68
Very useful toipics, I'm a new member here from Dhaka, feeling proud of having the chance of being a member of this family. however, I need an afl.....like :"Tested Auto Trading system". Is there anybody who can create this afl or can share it with me if you have?
Regards.
Kiron
 
#69
Dear Kironbgd,
yes I will help you. But all I want is that you guys learn from here. You guys make your own AFL. I want that everybody can implement his own logic n the AFL language. No need to ask so called experts to "Sir sir pleaseeeeeeeee make this afl for me". I will try to help as much as I can to all of you to teach writing AFl here.

If I want, I can update here thousands of AFL with colorful output and can make huge name. it is not what I want.

I also request to others to participate here to help others. If you made any AFL simple logic that can help new traders please share.
I wish best of luck to all of you for being a reader of this thread.


Very useful toipics, I'm a new member here from Dhaka, feeling proud of having the chance of being a member of this family. however, I need an afl.....like :"Tested Auto Trading system". Is there anybody who can create this afl or can share it with me if you have?
Regards.
Kiron
 
#70
Thanks for all your nice comments here. Your comments give me so much positive vibes, and I understand that my posts are useful to others.

It will be highly helpful to us, if you share your AFL here. We are not expecting huge big size AFL that gives us complex output. If you have simple logic and simple AFL solution then please share. Then new traders and new AFL learners will get helps from you.

Thank you


hay dost you have done a fantastic job here, this thread has helped me a lot in understanding the AFL's and i hope i can write one or two AFL's as per my requirement now.:clap:
 

Similar threads