How can I code a rule that triggers a buy/sell signal multiple conditions?
For example, I want to go long when close>EMA(20), rsi >30 and CCI>0. I don’t know in which order the 3 conditions will happens, I want that every time 3 conditions happens(for the first time) it will triggers signal. I ask for EA wizard because I need custom indicators.
I hope my request is clear.
I try to explain better:
if I have only 2 conditions it’d be easy: ema20>ema50 and cci crosses over 0 OR cci>0 and ema20 crosses above ema50.
But what if I have 3 or more conditions? I am not looking for all 3 happening at the same candle, I want the FIRST TIME the 3 conditions happen.
For example firt we have the cross of ema20 above ema50, then 2 candle after cci goes over 0 and some candle after rsi goes above 30.
I am no expert in mql coding, but in easylanguage or prorealcode I would assign 1 to each positive condition, and their sum would be assigned a variable, f.e. buycond.
Buycond=3 when all conditions are met. If buycond=3 and buycond<3 (previous candle, so this is first time all conds are met) it will trigger order.
I hope it is more clear now.
yes, you are right. You can do it the same way in AlgoWizard. Setup 2 different tabs describing first 2 conditions and assign cond1 = 1 if the condition 1 is valid and cond2 = 1 if the condition 2 is valid
Finally setup a tab for the 3rd condition. If its valid AND cond1 + cond2 = 2 you can execute a trade and set cond1 & cond2 to 0 (zero)
You must be logged in to reply to this topic.