Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
"Three days before MA(18) and MA(48) cross each other"
I'm pretty new to AFL and have the following issue, where two conditions need to be true to return a buy signal:
I'd like to express that if a 48 days average and an 18 days average cross each other, plus the 18 days average is at the day of the crossing higher than 3 days before, it should give me a buy signal.
I tried the following:
Unfortunately this doesn't work, i guess it is because Cross() simply gives out 0 or 1 (false/true) for each day, and not a date, so it's not possible to use Ref() on its result.
I hope my concern is understandable and it would help me a lot if anybody has a tipp.
Thank you!
Can you help answer these questions from other members on NexusFi?
your concern is a bit ambiguous. but as far as i got it, you can try this:
MA1 = MA(C, 48);
MA2 = MA(C, 18);
Buy = Cross(MA2, MA1) AND Close > Ref(Close, -3);
and please read the amibroker guide and understand the basics of afl coding. amibroker doesn't backtests the program without buy, short, sell and cover conditions. all 4 are required.
Since English is not my first language, I am giving my best to express myself clearly, so sorry for any misunderstanding.
Buy = Cross(MA2, MA1) AND Close > Ref(Close, -3);
Doesn't Ref(Close, -3) refer to the closing price three days ago? (as I red on the amibroker online guide)
What I want is to compare the closing price of the day where MA and MA2 cross, with the closing price three days before the crossing.
Won't your code compare the closing price of the crossing with the closing price three days starting from today?
now, i am not an expert at coding, so i am not sure about the reference to close of 3 candles previous to Crossing, but i think the above code should do it.