Welcome to the struggle. I've been slowly learning AFL and quite enjoy it. It's as easy or complex as you want it to be. For my needs it seems like a perfect solution compared to Python or R. Just having a lot of functions built in and knowing their solid is great. I couldn't imagine making my own back testing engine. The back tester also has a lot of flexibility if you want to get into the custom back tester options which I haven't had a need for.
I'd sugges the yahoo amibroker forum for questions like this. Little slow at times but as long as you come in with some AFL and the issue someone will chime in. Usually anyone who come in and ask "I need this code" with no attempt at trying themselves just gets moved a long. It'd be endless if everyone coded the requests and everyone has their own projects their working on besides wasting time on writing some of the ridiculous requests I've seen. But something like yours would get a solid reply.
As a beginner myself I think the easiest option is using the BarsSince(Array) function. It calculates the bars since the array was true.
So say you wanted it to be 5 days bang on....
buyCon1 = Cross( MACD(), Signal() );
BuyCon2 = Cross(MA(C,30),MA(C,10));
Entry = BuyCon2 AND BarsSince(buyCon1) == 5;
Buy = Entry ;
Sell = 0;
Perhaps you wanted within a 5 day window, just change the == to < 5 , etc.
Also be aware of how AFL counts bars. For instance in a back test, it will label a trade which entered on a bar and exited the next bar as a holding day of 2 bars.
If you wanted to fool around with it visually you could try using some Plot functions and opening it in a new chart and adding the AFL or drag and clicking the AFL to the chart.
buyCon1 = Cross( MACD(), Signal() );
BuyCon2 = Cross(MA(C,30),MA(C,10));
Entry = BuyCon2 AND BarsSince(buyCon1) == 5;
Buy = Entry ;
Sell = 0;
PlotShapes(shapedigit1*buyCon1,colororange);
PlotShapes(shapedigit2*buycon2,colorlightblue);
PlotShapes(shapeUpArrow*Entry,colorgreen);
Just put that in a charts AFL ( I usually make a new blank chart as to not screw with my templates) and just scroll a chart and look for the shapes and make sure everything is happening when it should. It'll plot a shapedigit1 at each con1 and shapedigit 2 at buy2 and when the 2 line up for entry at Entry it should plot a uparrow. Good way to verify AFL visually.
Edit: It does get frustrating at times to try and program an idea. It's very easy to have an idea of what you want to do but to program it in any language in a mathematical form that a computer can understand is very difficult. It is satisfying though when you do nail what you wanted to do though.