Need help in wiritng amibroker afl code

hello friends,

i need help in writing afl code for amibroker…

buy condition = when cci(40) higher than 50 and rsi crossover -20

but then thing is signal should generated based on RSI…when rsi touch below -20 it gets buy only when it check cci(40) is higer then 50

sell condition = when cci(40) lower than -50 and rsi crossover 80

[email protected]