I have 5 buy conditions and I want whenever any three conditions met buy should happen i.e:
buycondition1=......;
buycondition2=......;
buycondition3=......;
buycondition4=......;
buycondition5=......;
buy= whenever any3 conditions out of the above 5 met
@santy the BUY signal you are attempting to create can be coded so that you have a BUY only on the first bar where your signal is triggered (an IMPULSE signal), or you can have your signal show up on every bar that it remains true (a STATE signal).
Or graphically,
As for your second question about crossing above your trigger threshold you should familiarize yourself with the functions used in the code. https://www.amibroker.com/guide/afl/cross.html
As @NowToLook wrote, your buyconditions will add up in increments of one, from 1-5. To reach your trigger (3) from below your trigger you need the sum of your buyconditions to equal 3 or greater, which means to CROSS above 2.
P.S. IMHO it is a good idea to create an Exploration and/or a chart to help illustrate what your variables are calculating.
Hi!
Your code above was very helpful thank you.
Please can you let me know how to code for 3 out of 5 averages above a fixed value,.
For example you are using 5 EMA's on RSI and you want to code a buy condition to be valid only if 3 out of these 5 EMA's are above 45.
Thanks
@Vikas.sood your question seem identical to the original post on this thread. So the answer is exactly the same too,
If your question is really about coding a moving average above a certain threshold, show us your attempted code and let us know where you are having difficulty.