molanis.com/forum - Tools for MetaTrader : The place to ask about the best expert advisor builder, expert advisor downloads, and expert advisor programming

AFTER YOU REGISTER SEND US AN EMAIL TO ACTIVATE YOUR ACCOUNT - Before posting:-1- Please read the user guide -2- Try the examples -3- Search in the forum
It is currently Sat May 11, 2024 3:46 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Using "AND" with "OR" In Series
PostPosted: Mon May 21, 2012 6:54 pm 
Offline

Joined: Wed Mar 14, 2012 12:31 am
Posts: 118
Hello Support,

I've got a question about using both "AND" and "OR" in a sequential series. Basically, I have four (4) MQL Blocks:

MQL Block(1)
MQL Block(2)
MQL Block(3)
MQL Block(4)

The trade logic requires:

MQL(1) AND MQL(2) -OR- MQL(3) -OR- MQL(4)

So, conditions 1 AND 2, or 1 AND 3, or 1 AND 4, will trigger the trade.

I've had much more complex problems to solve, but for some bizarre reason, I'm having difficulty linking these blocks correctly in the Diagram in a streamline fashion, without doing a whole lot of replication of MQL(1). So, to reduce the amount of block replication, I tried the following:

Image

However, this presents a problem because in the "OR" layer, MQL(1) seems to be cut out of the equation where the connections are made from Start to MQL(3) and MQL(4). So, it would seem that the "OR" layer here, does not evaluate MQL(1) and MQL(2) as the trade logic requires, with MQL(3) and MQL(4) being evaluated in sequence as "OR" conditions. This looks suspect.

If this is somehow correct, please let me know. If not, what would I need to change, other than tossing everything under a single MQL Block and using "OR" pipes (||) to obtain the sequential (cascading) evaluation effect that I'm looking for. I could stick everything under a single MQL Block, but I want to see all the major conditions separately.

Thanks!
cfx


Top
 Profile  
 
 Post subject: Re: Using "AND" with "OR" In Series
PostPosted: Mon May 21, 2012 7:01 pm 
Offline

Joined: Wed Mar 14, 2012 12:31 am
Posts: 118
Hello Support,

Let me ask this question a slightly different way.

Would it be correct to say, that whenever I use just one (1) order execution icon like Buy (in this example), that ALL conditions ABOVE the Buy icon, get evaluated as a singular construct, even though those condition layers contain many (more than one) "AND" or "OR" operator?

Stated another way, is it true that no matter what I hang off the Start block, if ALL layers point to just one (1) Buy block, then even though some of the layers are separated by "AND" or "OR" - ALL conditions must be evaluated in the sequence in which they appear in the diagram?

Thanks,
cfx


Top
 Profile  
 
 Post subject: Re: Using "AND" with "OR" In Series
PostPosted: Mon May 21, 2012 7:19 pm 
Offline

Joined: Wed Mar 14, 2012 12:31 am
Posts: 118
Updated:

Tested the above diagram and it absolutely does not work as intended.

Ok, so - how do I get the "AND" to work with the "OR" in sequence?

Thanks,
cfx


Top
 Profile  
 
 Post subject: Re: Using "AND" with "OR" In Series
PostPosted: Mon May 21, 2012 8:14 pm 
Offline

Joined: Wed Mar 14, 2012 12:31 am
Posts: 118
Having the need to move along quickly, I simply reduced the problem using the following method:

MQL(1) AND MQL(2)

Where, MQL(2) now contains all sequentially evaluated conditions separated by 'OR' pipes (||) as follows:

(Condition1) || (Condition2) || (Condition3)

Image

Hope this helps somebody out there.

cfx


Top
 Profile  
 
 Post subject: Re: Using "AND" with "OR" In Series
PostPosted: Tue May 22, 2012 9:30 am 
Offline
Site Admin

Joined: Fri Oct 16, 2009 3:40 pm
Posts: 451
You can also do:
A AND B connect to BUY
C AND D connect to BUY2 (same parameters as BUY1)
The effect is (A AND B) OR (C AND D) - it works fine if you control the max number of positions in the Start icon. It should be equal to one, otherwise two orders will be sent to the metatrader server


Top
 Profile  
 
 Post subject: Re: Using "AND" with "OR" In Series
PostPosted: Tue May 22, 2012 10:10 am 
Offline

Joined: Wed Mar 14, 2012 12:31 am
Posts: 118
So, should I assume then that "OR" only works in-line by itself?

Else, one needs to "fabricate" an "OR" by essentially doing what you just said, creating multiple independent points of execution (Buy1, Buy2, Buy3, etc.) that use different MQL and/or TA+ blocks and controlling the number of Lots open at one time?

Thanks,
cfx


Top
 Profile  
 
 Post subject: Re: Using "AND" with "OR" In Series
PostPosted: Tue May 22, 2012 10:03 pm 
Offline

Joined: Tue Dec 22, 2009 12:22 am
Posts: 1761
You cannot create nested AND - ORs unless you use the MQL icon. This means that you cannot create this (A or B) AND (c or D) unless you use the mql icon like you did


Top
 Profile  
 
 Post subject: Re: Using "AND" with "OR" In Series
PostPosted: Wed May 23, 2012 11:43 am 
Offline

Joined: Wed Mar 14, 2012 12:31 am
Posts: 118
molanisfx wrote:
You cannot create nested AND - ORs unless you use the MQL icon. This means that you cannot create this (A or B) AND (c or D) unless you use the mql icon like you did


Got it. I've gotten used to using the MQL blocks anyway.

Thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by Molanis © 2009