Two conditions are met.
-
Hi. How can I do, if two conditions are met, open an operation?
These conditions are separated by an indeterminate number of candles.
For example a junction of EMAS and a stocahastic level.
-
Must both conditions to be meet at the same time/candle?
-
Not in the same candle.
First one and then the other, but not in consecutive candles.
There may be a separation of x candles. -
You can try this

Define a variable like -> bool FirstCondIn == false
If FirstCondIn == false, the true block (2) output Will pass and the EA Will look for the 1st condition.
If the 1st condition is met, the true block (3) output Will pass and FirstCondIn == true
As the FirstCondIn == true, the yellow block (2) output Will pass and the EA Will look for the 2nd condition having the 1st as true. While FirstCondIn == true, the EA Will not look for the 1st condition until block (7) reset its value to false.
-
Hello and what modification should I do so that when this pattern is given and I am buying it, I will not go back to doing another operation until the first condition returns to resfresh or give?
-
@juan-manuel-quiñonero Gracias Jose
-
Take a look at the example. The first condition is only checked when "No Position" block is true. So, if there is a trade running, it is not allowed to open a new trade.
-
True the problem is when once the 1st condition is given and every time that the 2nd condition will come back to operate, in my case I want that for every time the 1st condition is once again only operated once when the 2nd condition, in this way we have this sequence: 1st condition + 2nd condition = to a single operation and until the 1st condition does not return to be added to the 2nd again again no more operations are established
-
When you have variables, you can modify them as you want. You set the variable for the first condition to "true" when the condition is true, then the variable remains "true" until you set it to "false", which can be at any time.
But always try to think, is it even needed to do this stuff. Because you can just check 2 condition at the same time:
1 - Is the current price below MA
2 - Is oscillator above level XDepends on the first condition. You don't say exactly what it is, so for me it looks like it is: Price crosses MA. But you know, if at the current moment Price is < MA, this means that some candles ago the price crossed MA. The question is, do you even care when that happened...
-
Hi, I try to explain it better, the conditions are these:
1º Once the rsi crosses 70 or 30 for purchase or sale, this is waiting for the 2nd condition to occur.
2º The 2nd condition would be the crossing of the line 0 of the macd, but only for once, that is to say that if there are new crosses to the zero line that does not introduce more operations until the 1st condition changes.Explain me well? Thanks for everything
-
I think the best in this case is what josecortesllobat explained above. There are basically 2 ways to do such thing - starting from the current candle to look in the past candles and detect the signal, or while the EA is running to wait for each signal to happen (and use variables to store the current state). I generally prefer the first method when it's easy enough to use it, and it can be used in some custom indicator, but I don't think that it's a good idea in the EA.
By the way, here is another interesting method: https://fxdreema.com/demo/mt4-wait-crossovers But I don't think that this can be used for your case.
-
I have the same problem that cristobaljosemt5 ,
@cristobaljosemt5 , Have you solve the problem?
My steps are:
- price down the MA and blue arrow
- rsi > 70
open buy
I copy just the same of the example, and the problems is that when the trade is finish the EA should come back again to the first condition , and it doesn´t do it
i attached a screenshoot and the EA
0_1555545065567_Melm 13 (27).mq4
In adition i have another problem, If i put a secon block in the second condition (on the right side) the EA dont make trades.
Thanks for teh help and Regards
-
@josecortesllobat , hi, i am trying to use this same concept, but i do not now what to put in description of the variable, could you help?
-
@edward-brazil

Number (1) is okay. That is the first occurance that your indicator value crossed up (or a bit later) below your clipping level. But what abot the case I marked with (2)?If that is also a valid entry, than your first condition is that price closes below the Moving Average or whatever indicator is on the chart and you take all occurances that your oscilator brakes some clipping level.
If you only wnat to take the first occurance, than it's a bit more tricky. -
hi dear friend
wath is the name oh block number 4 ?