Closing trade for profit on individual trade rather than selection

We were all new to Bet Angel once. Ask any question you like here and fellow forum members promise not to laugh. Betfair trading made simple.
Post Reply
MartinJWilliams
Posts: 50
Joined: Tue May 10, 2022 3:10 pm

I'm running a number of bots looking for certain instances in the market. What I would like to do is to close the trade for a profit once this instance occurs which I understand how to do with the 'close trade on profit for greening' rule.

My question is if this instance occurs again 20 seconds later for example, the bot triggers but the selection is already showing a profit for or above the specified amount in the rule, would this not just close and green up again automatically? I'm looking for a way to take profit on the actual trade itself rather than the profit on the selection but am not sure how to approach it. Thanks.
User avatar
Dallas
Posts: 22731
Joined: Sun Aug 09, 2015 10:57 pm
Location: Working From Home

MartinJWilliams wrote:
Fri Nov 24, 2023 7:18 am
I'm running a number of bots looking for certain instances in the market. What I would like to do is to close the trade for a profit once this instance occurs which I understand how to do with the 'close trade on profit for greening' rule.

My question is if this instance occurs again 20 seconds later for example, the bot triggers but the selection is already showing a profit for or above the specified amount in the rule, would this not just close and green up again automatically? I'm looking for a way to take profit on the actual trade itself rather than the profit on the selection but am not sure how to approach it. Thanks.
You'd need addition close trade at profit rules, ie you first could trigger if your profit is greater than £5 and less than £9.99, the second if your profit is greater than £10 and less than £14.99 and so on

If you wanted to be more precise, ie, were looking for a minimum of £5 per trade, you can store your P/L with an adjustment of plus £5, then use a Stored Value condition to test if your P/L is greater than that Stored Value
Once it is and that rule triggers you'd store the value of your P/L with an adjustment of plus £5 again and so on
MartinJWilliams
Posts: 50
Joined: Tue May 10, 2022 3:10 pm

Thanks for getting back to me. I haven't used or come across using P/L yet so will do some reading on the forums and in the help files. Thanks again.
User avatar
Dallas
Posts: 22731
Joined: Sun Aug 09, 2015 10:57 pm
Location: Working From Home

MartinJWilliams wrote:
Fri Nov 24, 2023 6:07 pm
Thanks for getting back to me. I haven't used or come across using P/L yet so will do some reading on the forums and in the help files. Thanks again.
Thinking about it it might be worth me adding this as an example to the shared files section, so if you get stuck don't worry too much I'll upload something you could use as a starting point next week
MartinJWilliams
Posts: 50
Joined: Tue May 10, 2022 3:10 pm

I think I understand. I just wanted to clarify if you don't mind.

1) I need to store a value called 'PL' for example, this is the P/L of the selection, plus an adjustment of profit.
2) I need to add a 'close trade profit' with greening' condition that checks against the stored value 'PL' of the selection.

I'm assuming I can just add this stored value and condition as part of the initial back or lay bet.... though the 'close trade profit' condition doesn't feel like it belongs on the back bet, it feels like it should have a separate rule to close down the trade?... which would then present another set of problems. I just wanted to clarify so that I'm not glued to the screen for days waiting for something to trigger that never will :)



Thanks again for your help. Can't be easy, doing what you are doing. I've learnt a ton from yourself and this forum over the past month. Something quite amazing watching an event unfold, all the various elements of automation kick in and it all finally doing what it's supposed to do :)
User avatar
Dallas
Posts: 22731
Joined: Sun Aug 09, 2015 10:57 pm
Location: Working From Home

MartinJWilliams wrote:
Sat Nov 25, 2023 5:46 am
I think I understand. I just wanted to clarify if you don't mind.

1) I need to store a value called 'PL' for example, this is the P/L of the selection, plus an adjustment of profit.
2) I need to add a 'close trade profit' with greening' condition that checks against the stored value 'PL' of the selection.

I'm assuming I can just add this stored value and condition as part of the initial back or lay bet.... though the 'close trade profit' condition doesn't feel like it belongs on the back bet, it feels like it should have a separate rule to close down the trade?... which would then present another set of problems. I just wanted to clarify so that I'm not glued to the screen for days waiting for something to trigger that never will :)



Thanks again for your help. Can't be easy, doing what you are doing. I've learnt a ton from yourself and this forum over the past month. Something quite amazing watching an event unfold, all the various elements of automation kick in and it all finally doing what it's supposed to do :)
Yes, you are correct on both points above

I actually forgot the close trade profit condition can now test against stored values so as you've rightly said that could be used instead of a Stored Value Condition which I originally suggested in my last post

The 'Close Trade Profit Condition' would be added to a 'Close Trade on Selection with Greening' rule (not the back or lay bet rule/s)

What specfic problems would it cause using a separate Close trade on selection with greening rule?
MartinJWilliams
Posts: 50
Joined: Tue May 10, 2022 3:10 pm

I was worried about another bot having a position/angle open on the same horse so didn't want to use a close position rule that would close down the positional together, that's why I was hoping to be able to include the rule within the bet conditions in order to just take some additional profit out.

An example would be that there may be a long-term drift on that my bots have picked up and taken a position on early in the morning, the expectation being that it would continue to drift. During the morning there maybe an opportunity to steal some additional value as the price moves back and forth within that drift. These separate bots I would prefer to interact in the market with the intention of achieving a set profit before stopping and waiting for another instance, leaving the original position open. Using the set profit condition seemed like an easy off switch for the bot, rather than risking the market moving against me.
I'm not sure I can picture how that could work without closing the position on the horse altogether though, potentially leaving some value on the table of the horse that was going to continue to drift.
User avatar
Dallas
Posts: 22731
Joined: Sun Aug 09, 2015 10:57 pm
Location: Working From Home

MartinJWilliams wrote:
Sat Nov 25, 2023 4:14 pm
I was worried about another bot having a position/angle open on the same horse so didn't want to use a close position rule that would close down the positional together, that's why I was hoping to be able to include the rule within the bet conditions in order to just take some additional profit out.

An example would be that there may be a long-term drift on that my bots have picked up and taken a position on early in the morning, the expectation being that it would continue to drift. During the morning there maybe an opportunity to steal some additional value as the price moves back and forth within that drift. These separate bots I would prefer to interact in the market with the intention of achieving a set profit before stopping and waiting for another instance, leaving the original position open. Using the set profit condition seemed like an easy off switch for the bot, rather than risking the market moving against me.
I'm not sure I can picture how that could work without closing the position on the horse altogether though, potentially leaving some value on the table of the horse that was going to continue to drift.
If I understand you correctly the only way you could do that is to use 'Global Settings' on the parameters tab and 'Offset bet with greening'
That will calculate the stake required to green up that position based on the stake used, but you can only use ticks or percent as the offset amount
But it will mean that every trade is independent for you.

So as an example you could have a long swing trade going from the morning with a 30 tick offset bet with greening, then have a number of scalps using 5 tick offset bets with greening etc
MartinJWilliams
Posts: 50
Joined: Tue May 10, 2022 3:10 pm

Thanks Dallas, I tend to use these anyway for that reason.... I think I'm probably looking at it the wrong way. Thinking it through, I think the answer is probably for me to refine the scalping bots further in order to test when the instance that was profitable is starting to change, rather than rely on an 'off button'. I think sometimes I'm looking for the perfect trade every time when in reality, that's never going to happen.
MartinJWilliams
Posts: 50
Joined: Tue May 10, 2022 3:10 pm

Hi Dallas,

I wanted to try your idea out of closing the trade for a £5 profit. I was hoping the attached rule would store the P&L as a value called 'profit_loss', adding an additional £5. Once the selection was in profit of £5, it would close, green up and then store the new P&L value with an additional £5. The idea being that the automation could trigger again and start the process all over again to make the next £5. I was hoping you wouldn't mind checking the attached to see if I've got the right end of the stick with this?
Thanks,

…. Actually, thinking about it. I would probably also need to add a second condition to the green up rule in case the P&L goes into a loss. I’m guessing it would be just the same as the +£5 condition just a -£5 version to accompany it?
You do not have the required permissions to view the files attached to this post.
User avatar
Dallas
Posts: 22731
Joined: Sun Aug 09, 2015 10:57 pm
Location: Working From Home

MartinJWilliams wrote:
Fri Dec 01, 2023 9:12 pm
Hi Dallas,

I wanted to try your idea out of closing the trade for a £5 profit. I was hoping the attached rule would store the P&L as a value called 'profit_loss', adding an additional £5. Once the selection was in profit of £5, it would close, green up and then store the new P&L value with an additional £5. The idea being that the automation could trigger again and start the process all over again to make the next £5. I was hoping you wouldn't mind checking the attached to see if I've got the right end of the stick with this?
Thanks,

…. Actually, thinking about it. I would probably also need to add a second condition to the green up rule in case the P&L goes into a loss. I’m guessing it would be just the same as the +£5 condition just a -£5 version to accompany it?
I'll try and take a look in the morning, or if not once the racing has finished tomorrow, but I did create and post an example earlier this week in the form of a Servant which you might want to take a look at, it might confirm if you have your right or if not what you may need to edit
viewtopic.php?f=58&t=28388
MartinJWilliams
Posts: 50
Joined: Tue May 10, 2022 3:10 pm

Thanks Dallas. It looks like my version is missing a bunch of steps compared to your Servant.
Probably wishful thinking, but I thought I could just store the P&L of all runners as a value 'profit_loss', once at start-up. The 'close trade' rule condition could just then cross reference 'profit_loss' at every re-arm against the actual P&L. Modifying the 'profit_loss' value once the 'close trade' rule had been actioned. I guess I was hoping that this rule could sit alongside my other automation without me having to amend and add signals to every other automation rule.
User avatar
Dallas
Posts: 22731
Joined: Sun Aug 09, 2015 10:57 pm
Location: Working From Home

MartinJWilliams wrote:
Sat Dec 02, 2023 5:54 am
Thanks Dallas. It looks like my version is missing a bunch of steps compared to your Servant.
Probably wishful thinking, but I thought I could just store the P&L of all runners as a value 'profit_loss', once at start-up. The 'close trade' rule condition could just then cross reference 'profit_loss' at every re-arm against the actual P&L. Modifying the 'profit_loss' value once the 'close trade' rule had been actioned. I guess I was hoping that this rule could sit alongside my other automation without me having to amend and add signals to every other automation rule.
If you were doing a single trade per race then just storing the P/L after each market is settled could be done that way.

But if doing multiple trades each market then you'll need the extra rules so as to keep updating the P/L with conditions to ensure it triggers at the right times.
tbh it took a few more than I expected, but as if often the case the foundation is usually very simple, but as you start testing a file and begin ironing out the wrinkles and put in counter measures it can quickly swell
MartinJWilliams
Posts: 50
Joined: Tue May 10, 2022 3:10 pm

Thanks Dallas. Now that the racing has finished, adding in all of these extra rules will give me something to do this evening :)

A quick question. When scalping for example, I'll often have multiple duplications of an automation file, taking a position on reverse best price, 2nd reverse best price etc. I wanted to check to see if having the same stored value name 'matched price' for example would cause an issue or does every rule require a unique value name?
MartinJWilliams
Posts: 50
Joined: Tue May 10, 2022 3:10 pm

Sorry, me again.

I'm trying to work through this but I'm struggling to understand how it's possible to group all of the rules together for a piece of automation (back or lay bet) that is triggering via a series of conditions and not via a Servant.

Rule 1: Clear Signals/Stored Values - I can see how this can be associated with the selection by using the same conditions that would trigger the back or lay bet of the automation to trigger the Clear Signal rule.
Rule 2: Back bet - Straight forward as above, driven by the conditions.
Rule 3: Signal no Unmatched Bets & Rule 4: - Store P/L After Matched Bet - I can't picture how to link these two rules to to a back bet driven by conditions outside of a Servant environment, if it's at all possible.
Thanks again.
Post Reply

Return to “Bet Angel for newbies / Getting started”