Need AFL code for Heikin Ashi

Hi Guys,
I am new to AFL coding and need help to get code to buy at first green candle and sell at the second consecutive red signal where second candle low is lower than the previous Red candle.
This is for Heikin Ashi.
Please find the attachment for more information.

Very similar implementation (but not exact) done here