Hello,

Thanks to all for the prompt reply. (I just figured out how to format
this, my 1st post looked a little strange).

EMA1 = EMA(C, 10);

EMA2 = EMA(C, 200);

Buycross = Cross(EMA1, EMA2);

Counter = Cum(Buycross);

Triples = Cross(Counter % 3 == 0, 0);

Plot(EMA1,"EMA10", colorRed,styleLine);

Plot(EMA2,"EMA20",colorBlue,styleLine);

Plot(Triples, "Triples", colorGreen, styleOwnScale | styleHistogram);

This code works absolutely fine, many thanks, only problem here: it
starts to count wrong(should count to 3, but counts to 2 only
considering the 1st triplele of crossovers, probably due to intializing
the EMA200) any suggestions? But I need you to understand where I am
coming from:

Obviously you are much more experienced in writing afl than me and I get
Mike's basic concept of avoiding loops for proefficient coding and the
"EMA-plot-labeling" was not correct.

You have to understand that I am trying to realize/code my ideas and the
2nd code is where I started off and probably would start off again, be
it good or bad programming. I do have your solution to my problem now,
but I still don't understand why my "concept" does not do the job. Of
course I did read the articles on "How AFL works", this was were I
started and also got a hand on the barcount funtion which I thought was
the problem (not counting the whole OHLC-array due to faster processing
speed). I also asked my brother on this simple one, who is used to
programming C. As AFL is "C-based" I would have assumed this code should
work. Please help me to understand what went wrong / is wrong in my
logic here, I consider understanding this basic concept to be very
important for future purpose.

Thanks in advance,

Matthias

Reply via email to