Can you combine AND/OR logic in the conditions section?

Advanced automation available in Guardian - Chat with others and share files here.
Post Reply
CallumPerry
Posts: 575
Joined: Wed Apr 19, 2017 5:12 pm

In Excel you can put a couple of AND statements inside an OR, can this be done with conditions? For example, if I want: (Back Price > 10 AND Market Volume > £1k) OR (Back Price < 10 AND Market Volume < £1k).

If so, would I need to structure that example like:

[Group: One or more must be True]

[Group: All must be True]
Condition A
Condition B

[End of Group]

[Group: All must be True]
Condition C
Condition D

[End of Group]

[End of Group]
CallumPerry
Posts: 575
Joined: Wed Apr 19, 2017 5:12 pm

The reason I wanted to know this, and if there is an easier way that I am missing, please let me know! I don't like how using an offset bet fires in both bets at the same time so I wait until my first bet is matched before firing in a closing order. In reality, I have two closing orders though; one for a profit and one where I take a loss. The profit order can sit 'X' ticks out straight away but the stoploss order obviously has to wait until the price drifts a few ticks before being fired in, else it will close immediately at the current price. Here is my problem:

I have a 'Closing Bet' rule which cancels the remaining lay amount on the selection. When the opening bet has been matched, I have a signal: Flag 1 = 1. I would like to add some conditions to 'Closing Bet' so it knows when to trigger. Flag 1 must equal 1 but also:

I need a condition that checks whether one of these closing bets has been fully matched. I can see 'Matched bet information' but this only looks at the previous bet, I need (potentially) the previous two. I'm fine with if one is partially matched before the other completely matches as my stake adjusts so I'm never unbalanced on one side or the other.

The other problem I have found is 3 things can happen:
1) Sometimes, only the profit point triggers and gets matched. (Latest bet = stake = fully matched. Nice!)

2) Sometimes the trade drifts, the stop loss is triggered and waiting on the next tick before getting fully matched. (Latest bet = stake = fully matched. Again, nice!)

3) Sometimes the trade drifts, the stop loss is triggered and waiting on the next tick BUT THEN the trade comes in once more and the profit is taken. The second to last bet is fully matched.

Can you see my problem? I want to know when either the profit or stop loss is fully matched so I can cancel the other one and reload to go once again. The AND/OR combinations I was thinking could account for each of the three possible routes above.
User avatar
Euler
Posts: 26521
Joined: Wed Nov 10, 2010 1:39 pm

Am I missing something? A fill or kill order will allow you to set a bet that only places one bet after the first has filled.
CallumPerry
Posts: 575
Joined: Wed Apr 19, 2017 5:12 pm

Sorry Peter, I have only been free at the weekends in the last few weeks.

When I have used offset it fires both bets in at the same time. When I have used Fill/Kill in the past, I then have had difficulties with orders being fully matched. The opening bet can sometimes be partially matched and the price runs away and then my strategy gets into more troubles.

To compensate I have my own rules which accounts for matched, unmatched, partially matched opening bets, profit points and stop loss points, I am quite OCD with my attention to detail. There's probably more efficient ways of doing it but I am ignorant to a lot of the inbuilt automation capabilities and my own experiences with using offset + fill/kill via Excel in the past.

I think I have figured out some of my problems using flags (signals) but I could still do with confirmation that you can put a few OR statements inside of an AND.

For example, I have 2 stored values: A = Profit Price and B = Stoploss price.

I want a rule to trigger is the following pair of conditions is true:

Unmatched money at stored value A = 0 AND profit is >0
OR
Unmatched money at stored value B = 0 AND profit is <0.

Does that make sense? I want BOTH of the conditions in the first line to trigger or BOTH in the second line to trigger. Can you combine two OR statements within an AND statement?
User avatar
Derek27
Posts: 25159
Joined: Wed Aug 30, 2017 11:44 am

CallumPerry wrote:
Sat Aug 28, 2021 9:24 pm
Sorry Peter, I have only been free at the weekends in the last few weeks.

When I have used offset it fires both bets in at the same time. When I have used Fill/Kill in the past, I then have had difficulties with orders being fully matched. The opening bet can sometimes be partially matched and the price runs away and then my strategy gets into more troubles.

To compensate I have my own rules which accounts for matched, unmatched, partially matched opening bets, profit points and stop loss points, I am quite OCD with my attention to detail. There's probably more efficient ways of doing it but I am ignorant to a lot of the inbuilt automation capabilities and my own experiences with using offset + fill/kill via Excel in the past.

I think I have figured out some of my problems using flags (signals) but I could still do with confirmation that you can put a few OR statements inside of an AND.

For example, I have 2 stored values: A = Profit Price and B = Stoploss price.

I want a rule to trigger is the following pair of conditions is true:

Unmatched money at stored value A = 0 AND profit is >0
OR
Unmatched money at stored value B = 0 AND profit is <0.

Does that make sense? I want BOTH of the conditions in the first line to trigger or BOTH in the second line to trigger. Can you combine two OR statements within an AND statement?
[Group: One must be true]
...[Group: All must be true]
......
...[End group]
...[Group: All must be true]
......
...[End group]
[End group]

Wouldn't that do it. I realise it turns into spaghetti for a complex and/or statement but it should suffice for the above.

Personally I don't use offset for automation as the market often gets suspended before the offset bet hits the exchange, so I prefer to have another rule that can test and repeat.
CallumPerry
Posts: 575
Joined: Wed Apr 19, 2017 5:12 pm

Derek27 wrote:
Sat Aug 28, 2021 10:00 pm
CallumPerry wrote:
Sat Aug 28, 2021 9:24 pm
Sorry Peter, I have only been free at the weekends in the last few weeks.

When I have used offset it fires both bets in at the same time. When I have used Fill/Kill in the past, I then have had difficulties with orders being fully matched. The opening bet can sometimes be partially matched and the price runs away and then my strategy gets into more troubles.

To compensate I have my own rules which accounts for matched, unmatched, partially matched opening bets, profit points and stop loss points, I am quite OCD with my attention to detail. There's probably more efficient ways of doing it but I am ignorant to a lot of the inbuilt automation capabilities and my own experiences with using offset + fill/kill via Excel in the past.

I think I have figured out some of my problems using flags (signals) but I could still do with confirmation that you can put a few OR statements inside of an AND.

For example, I have 2 stored values: A = Profit Price and B = Stoploss price.

I want a rule to trigger is the following pair of conditions is true:

Unmatched money at stored value A = 0 AND profit is >0
OR
Unmatched money at stored value B = 0 AND profit is <0.

Does that make sense? I want BOTH of the conditions in the first line to trigger or BOTH in the second line to trigger. Can you combine two OR statements within an AND statement?
[Group: One must be true]
...[Group: All must be true]
......
...[End group]
...[Group: All must be true]
......
...[End group]
[End group]

Wouldn't that do it. I realise it turns into spaghetti for a complex and/or statement but it should suffice for the above.

Personally I don't use offset for automation as the market often gets suspended before the offset bet hits the exchange, so I prefer to have another rule that can test and repeat.
^^ That's the kind of logic I was hoping would work. I try not to make individual rules too complex so fingers crossed, this type of logic works. It's within a later part of my system so difficult to test unless I created a whole new rule; guess I was just being lazy by asking here.

I am the same Derek. I prefer to have individual rules for each section of my bet handling matrix to test an repeat conditions upon every refresh. Thanks for the reply!
Post Reply

Return to “Bet Angel - Automation”