|
Post by halcyondaze on Oct 19, 2020 15:36:54 GMT
I have an automated strategy that lays the greyhound favorite using DAlambert. I would like to get the strategy to reset if it hits 3 losers in a row.
I have tried adding a max reset of 10 and a reset condition of
dbo.fn_strategyproperty(@id_strategy,'losing_trades_row') >2
but it doesn't work. It either stops betting or continues unchanged.
Is it possible to restart a strategy after 3 losers in a row ?
Steve.
|
|
|
Post by Ipposnif on Oct 19, 2020 16:48:44 GMT
I will check, maybe there is a bug
|
|
|
Post by halcyondaze on Oct 21, 2020 13:59:30 GMT
What ever Reset I use, I haven't got any resets to work. At best the strategy just stops placing bets
|
|
|
Post by Ipposnif on Oct 22, 2020 6:03:10 GMT
I didn't find any bug in the reset functionality. Save the strategy to an XML file and post here the content or send it to me with a private message. I will check it for you.
|
|
|
Post by halcyondaze on Oct 22, 2020 7:42:00 GMT
<strategy name="Auto - DAlembert Lay Greyhound Fav (Original)"
description="https://www.ipposnif.com/strategies.asp"
guiversion="3.0"
capital="10"
total_bets="1"
repeat_layed_bet="n"
only_first_bet_trigs_trade="n"
max_active_markets="1"
max_market_trades="1"
max_liability="1"
lay_odd_range_lower="2.0"
lay_odd_range_upper="4.3"
back_odd_range_lower=""
back_odd_range_upper=""
betting_time_range_lower="-00:01:00"
betting_time_range_upper="00:01:00"
daily_stop_profit_lower="2"
daily_stop_profit_upper="2"
max_market_open_trades="1"
market_status="All"
overround_back_min=""
overround_back_max="106"
overround_lay_min=""
overround_lay_max=""
playable_event_types="Greyhound Racing"
playable_market_types="WIN"
playable_countries="GB"
playable_racecourses="All"
event_time_range_lower=""
event_time_range_upper=""
event_time_timezone=""
show_input_checks="n"
select_all="n"
market_check_presence="n"
show_input_back="n"
show_input_lay="n"
show_input_3="n"
show_betting_frame_back="n"
show_betting_frame_lay="n"
show_betting_frame_3="y"
max_reset="10"
reset_condition="dbo.fn_StrategyProperty(@id_strategy, 'losing_trades_row' ) >2"
selection_criteria="SQL Assertion"
runner_order_criteria="Order by Price"
selection_criteria_string="@id_horse = @id_favourite_1"
bets_per_market_criteria="Single trade per market"
link_strategy_id="0"
link_criteria=""
link_amount=""
only_manually_selected_option="n"
use_other="n"
use_manual_betting="n"
use_market_filters="y"
use_runner_filters="y"
manual_trigger="n"
manual_betting_controls="None"
overround_all_bets="n"
only_markets_with_inplay_option="n"
>
<bet index="1"
bid_type="LAY"
persistence="Lapse"
place_condition=""
price_ticks="2"
price_betref="1"
price_criteria="Best LAY Price +/- Ticks"
price_formula=""
update_option="y"
epure_prices="n"
update_interval="5"
offset_min_price="1.9"
offset_max_price=""
use_lacking_capital="n"
offset_min_size=""
offset_max_size=""
bet_size="dbo.fn_alembertsize(@id_strategy, (@initial_capital/500), @bet_price, @bid_type)"
bet_size_is_target_amount="n"
fill_kill_ticks=""
fill_kill_seconds=""
close_trade_oncreate="n"
close_trade_onmatch="y"
close_trade_ondelete="n"
remove_check_oncreate="n"
remove_check_onmatch="n"
remove_check_ondelete="n"
delete_condition=""
/>
<bet index="2"
bid_type=""
persistence=""
place_condition=""
price_ticks="0"
price_betref="1"
price_criteria=""
price_formula=""
update_option="n"
epure_prices="n"
update_interval=""
offset_min_price=""
offset_max_price=""
use_lacking_capital="n"
offset_min_size=""
offset_max_size=""
bet_size=""
bet_size_is_target_amount="n"
fill_kill_ticks=""
fill_kill_seconds=""
close_trade_oncreate="n"
close_trade_onmatch="n"
close_trade_ondelete="n"
remove_check_oncreate="n"
remove_check_onmatch="n"
remove_check_ondelete="n"
delete_condition=""
/>
<bet index="3"
bid_type=""
persistence=""
place_condition=""
price_ticks="0"
price_betref="1"
price_criteria=""
price_formula=""
update_option="n"
epure_prices="n"
update_interval=""
offset_min_price=""
offset_max_price=""
use_lacking_capital="n"
offset_min_size=""
offset_max_size=""
bet_size=""
bet_size_is_target_amount="n"
fill_kill_ticks=""
fill_kill_seconds=""
close_trade_oncreate="n"
close_trade_onmatch="n"
close_trade_ondelete="n"
remove_check_oncreate="n"
remove_check_onmatch="n"
remove_check_ondelete="n"
delete_condition=""
/>
<bet index="4"
bid_type=""
persistence=""
place_condition=""
price_ticks="0"
price_betref="1"
price_criteria=""
price_formula=""
update_option="n"
epure_prices="n"
update_interval=""
offset_min_price=""
offset_max_price=""
use_lacking_capital="n"
offset_min_size=""
offset_max_size=""
bet_size=""
bet_size_is_target_amount="n"
fill_kill_ticks=""
fill_kill_seconds=""
close_trade_oncreate="n"
close_trade_onmatch="n"
close_trade_ondelete="n"
remove_check_oncreate="n"
remove_check_onmatch="n"
remove_check_ondelete="n"
delete_condition=""
/>
<bet index="5"
bid_type=""
persistence=""
place_condition=""
price_ticks="0"
price_betref="1"
price_criteria=""
price_formula=""
update_option="n"
epure_prices="n"
update_interval=""
offset_min_price=""
offset_max_price=""
use_lacking_capital="n"
offset_min_size=""
offset_max_size=""
bet_size=""
bet_size_is_target_amount="n"
fill_kill_ticks=""
fill_kill_seconds=""
close_trade_oncreate="n"
close_trade_onmatch="n"
close_trade_ondelete="n"
remove_check_oncreate="n"
remove_check_onmatch="n"
remove_check_ondelete="n"
delete_condition=""
/>
<bet index="6"
bid_type=""
persistence=""
place_condition=""
price_ticks="0"
price_betref="1"
price_criteria=""
price_formula=""
update_option="n"
epure_prices="n"
update_interval=""
offset_min_price=""
offset_max_price=""
use_lacking_capital="n"
offset_min_size=""
offset_max_size=""
bet_size=""
bet_size_is_target_amount="n"
fill_kill_ticks=""
fill_kill_seconds=""
close_trade_oncreate="n"
close_trade_onmatch="n"
close_trade_ondelete="n"
remove_check_oncreate="n"
remove_check_onmatch="n"
remove_check_ondelete="n"
delete_condition=""
/>
<bet index="7"
bid_type=""
persistence=""
place_condition=""
price_ticks="0"
price_betref="1"
price_criteria=""
price_formula=""
update_option="n"
epure_prices="n"
update_interval=""
offset_min_price=""
offset_max_price=""
use_lacking_capital="n"
offset_min_size=""
offset_max_size=""
bet_size=""
bet_size_is_target_amount="n"
fill_kill_ticks=""
fill_kill_seconds=""
close_trade_oncreate="n"
close_trade_onmatch="n"
close_trade_ondelete="n"
remove_check_oncreate="n"
remove_check_onmatch="n"
remove_check_ondelete="n"
delete_condition=""
/>
<bet index="8"
bid_type=""
persistence=""
place_condition=""
price_ticks="0"
price_betref="1"
price_criteria=""
price_formula=""
update_option="n"
epure_prices="n"
update_interval=""
offset_min_price=""
offset_max_price=""
use_lacking_capital="n"
offset_min_size=""
offset_max_size=""
bet_size=""
bet_size_is_target_amount="n"
fill_kill_ticks=""
fill_kill_seconds=""
close_trade_oncreate="n"
close_trade_onmatch="n"
close_trade_ondelete="n"
remove_check_oncreate="n"
remove_check_onmatch="n"
remove_check_ondelete="n"
delete_condition=""
/>
<bet index="9"
bid_type=""
persistence=""
place_condition=""
price_ticks="0"
price_betref="1"
price_criteria=""
price_formula=""
update_option="n"
epure_prices="n"
update_interval=""
offset_min_price=""
offset_max_price=""
use_lacking_capital="n"
offset_min_size=""
offset_max_size=""
bet_size=""
bet_size_is_target_amount="n"
fill_kill_ticks=""
fill_kill_seconds=""
close_trade_oncreate="n"
close_trade_onmatch="n"
close_trade_ondelete="n"
remove_check_oncreate="n"
remove_check_onmatch="n"
remove_check_ondelete="n"
delete_condition=""
/>
<bet index="10"
bid_type=""
persistence=""
place_condition=""
price_ticks="0"
price_betref="1"
price_criteria=""
price_formula=""
update_option="n"
epure_prices="n"
update_interval=""
offset_min_price=""
offset_max_price=""
use_lacking_capital="n"
offset_min_size=""
offset_max_size=""
bet_size=""
bet_size_is_target_amount="n"
fill_kill_ticks=""
fill_kill_seconds=""
close_trade_oncreate="n"
close_trade_onmatch="n"
close_trade_ondelete="n"
remove_check_oncreate="n"
remove_check_onmatch="n"
remove_check_ondelete="n"
delete_condition=""
/>
<bet index="11"
bid_type=""
persistence=""
place_condition=""
price_ticks="0"
price_betref="1"
price_criteria=""
price_formula=""
update_option="n"
epure_prices="n"
update_interval=""
offset_min_price=""
offset_max_price=""
use_lacking_capital="n"
offset_min_size=""
offset_max_size=""
bet_size=""
bet_size_is_target_amount="n"
fill_kill_ticks=""
fill_kill_seconds=""
close_trade_oncreate="n"
close_trade_onmatch="n"
close_trade_ondelete="n"
remove_check_oncreate="n"
remove_check_onmatch="n"
remove_check_ondelete="n"
delete_condition=""
/>
<bet index="12"
bid_type=""
persistence=""
place_condition=""
price_ticks="0"
price_betref="1"
price_criteria=""
price_formula=""
update_option="n"
epure_prices="n"
update_interval=""
offset_min_price=""
offset_max_price=""
use_lacking_capital="n"
offset_min_size=""
offset_max_size=""
bet_size=""
bet_size_is_target_amount="n"
fill_kill_ticks=""
fill_kill_seconds=""
close_trade_oncreate="n"
close_trade_onmatch="n"
close_trade_ondelete="n"
remove_check_oncreate="n"
remove_check_onmatch="n"
remove_check_ondelete="n"
delete_condition=""
/>
<bet index="13"
bid_type=""
persistence=""
place_condition=""
price_ticks="0"
price_betref="1"
price_criteria=""
price_formula=""
update_option="n"
epure_prices="n"
update_interval=""
offset_min_price=""
offset_max_price=""
use_lacking_capital="n"
offset_min_size=""
offset_max_size=""
bet_size=""
bet_size_is_target_amount="n"
fill_kill_ticks=""
fill_kill_seconds=""
close_trade_oncreate="n"
close_trade_onmatch="n"
close_trade_ondelete="n"
remove_check_oncreate="n"
remove_check_onmatch="n"
remove_check_ondelete="n"
delete_condition=""
/>
<bet index="14"
bid_type=""
persistence=""
place_condition=""
price_ticks="0"
price_betref="1"
price_criteria=""
price_formula=""
update_option="n"
epure_prices="n"
update_interval=""
offset_min_price=""
offset_max_price=""
use_lacking_capital="n"
offset_min_size=""
offset_max_size=""
bet_size=""
bet_size_is_target_amount="n"
fill_kill_ticks=""
fill_kill_seconds=""
close_trade_oncreate="n"
close_trade_onmatch="n"
close_trade_ondelete="n"
remove_check_oncreate="n"
remove_check_onmatch="n"
remove_check_ondelete="n"
delete_condition=""
/>
<bet index="15"
bid_type=""
persistence=""
place_condition=""
price_ticks="0"
price_betref="1"
price_criteria=""
price_formula=""
update_option="n"
epure_prices="n"
update_interval=""
offset_min_price=""
offset_max_price=""
use_lacking_capital="n"
offset_min_size=""
offset_max_size=""
bet_size=""
bet_size_is_target_amount="n"
fill_kill_ticks=""
fill_kill_seconds=""
close_trade_oncreate="n"
close_trade_onmatch="n"
close_trade_ondelete="n"
remove_check_oncreate="n"
remove_check_onmatch="n"
remove_check_ondelete="n"
delete_condition=""
/>
<bet index="16"
bid_type=""
persistence=""
place_condition=""
price_ticks="0"
price_betref="1"
price_criteria=""
price_formula=""
update_option="n"
epure_prices="n"
update_interval=""
offset_min_price=""
offset_max_price=""
use_lacking_capital="n"
offset_min_size=""
offset_max_size=""
bet_size=""
bet_size_is_target_amount="n"
fill_kill_ticks=""
fill_kill_seconds=""
close_trade_oncreate="n"
close_trade_onmatch="n"
close_trade_ondelete="n"
remove_check_oncreate="n"
remove_check_onmatch="n"
remove_check_ondelete="n"
delete_condition=""
/>
<bet index="17"
bid_type=""
persistence=""
place_condition=""
price_ticks="0"
price_betref="1"
price_criteria=""
price_formula=""
update_option="n"
epure_prices="n"
update_interval=""
offset_min_price=""
offset_max_price=""
use_lacking_capital="n"
offset_min_size=""
offset_max_size=""
bet_size=""
bet_size_is_target_amount="n"
fill_kill_ticks=""
fill_kill_seconds=""
close_trade_oncreate="n"
close_trade_onmatch="n"
close_trade_ondelete="n"
remove_check_oncreate="n"
remove_check_onmatch="n"
remove_check_ondelete="n"
delete_condition=""
/>
<bet index="18"
bid_type=""
persistence=""
place_condition=""
price_ticks="0"
price_betref="1"
price_criteria=""
price_formula=""
update_option="n"
epure_prices="n"
update_interval=""
offset_min_price=""
offset_max_price=""
use_lacking_capital="n"
offset_min_size=""
offset_max_size=""
bet_size=""
bet_size_is_target_amount="n"
fill_kill_ticks=""
fill_kill_seconds=""
close_trade_oncreate="n"
close_trade_onmatch="n"
close_trade_ondelete="n"
remove_check_oncreate="n"
remove_check_onmatch="n"
remove_check_ondelete="n"
delete_condition=""
/>
<bet index="19"
bid_type=""
persistence=""
place_condition=""
price_ticks="0"
price_betref="1"
price_criteria=""
price_formula=""
update_option="n"
epure_prices="n"
update_interval=""
offset_min_price=""
offset_max_price=""
use_lacking_capital="n"
offset_min_size=""
offset_max_size=""
bet_size=""
bet_size_is_target_amount="n"
fill_kill_ticks=""
fill_kill_seconds=""
close_trade_oncreate="n"
close_trade_onmatch="n"
close_trade_ondelete="n"
remove_check_oncreate="n"
remove_check_onmatch="n"
remove_check_ondelete="n"
delete_condition=""
/>
<bet index="20"
bid_type=""
persistence=""
place_condition=""
price_ticks="0"
price_betref="1"
price_criteria=""
price_formula=""
update_option="n"
epure_prices="n"
update_interval=""
offset_min_price=""
offset_max_price=""
use_lacking_capital="n"
offset_min_size=""
offset_max_size=""
bet_size=""
bet_size_is_target_amount="n"
fill_kill_ticks=""
fill_kill_seconds=""
close_trade_oncreate="n"
close_trade_onmatch="n"
close_trade_ondelete="n"
remove_check_oncreate="n"
remove_check_onmatch="n"
remove_check_ondelete="n"
delete_condition=""
/>
</strategy>
|
|
|
Post by halcyondaze on Oct 22, 2020 8:01:02 GMT
I have checked in the database and looked at all the functions and all appears to be fine. The only thing I haven't been able to check is the call to reset. I have called a select in the database command window to get the Lose_Row_Trades from tbl_Strategies and it returns the expected value. I'm not very familiar with MSSQL, but I know enough to do some testing. dbo.sp_Reset_Ipposnif works when run on the database.
If there is a problem and its not just my error, could it be the trigger to call the reset. I haven't witnessed a reset in any strategy while trying to test.
Steve.
|
|
|
Post by Ipposnif on Oct 22, 2020 10:51:41 GMT
Personally, I use the reset with the Masaniello strategies and it works fine. Now I'm running your strategy, let's wait for a streak of three losses in a row. p.s. if you want to show the result of an SQL expression, the easiest way is to use the Expression watcher: right-click on a horse name -> Expression watcher
|
|
|
Post by halcyondaze on Oct 22, 2020 12:10:36 GMT
|
|
|
Post by halcyondaze on Oct 22, 2020 12:32:38 GMT
steveseymour.co.uk/tmp/watch.PNGI don't see the reset function in the Expression Watch ? Is this the problem ? The reset is not being added. I see the Max Reset value is there. But I added it manually - should it have been there already ?
|
|
|
Post by Ipposnif on Oct 22, 2020 16:28:23 GMT
You did well, the reset condition is not included in the default list, you have to add it manually. Regarding the reset of your strategy, for Murphy's law, when you want a loss it never comes so I didn't manage to have three losses in a row. Now I have reduced it to 2 losses in a row. Let's see.
|
|
|
Post by halcyondaze on Oct 22, 2020 18:07:29 GMT
I'm going to try another method as you have the Masaniello strategy check @betsize. I will put the reset statement to @bet_size > 0.15 which should be roughly equivalent to a fourth stake and then hopefully do the reset.
|
|
|
Post by halcyondaze on Oct 22, 2020 18:27:33 GMT
OK, that failed too. But I know what the problem is. The Strategy reset after 3 losers (@bet_size = 0.16) which was > 0.15. But the next stake was still 0.16, so the reset doesn't reset the staking plan progression pointer.
Can that be fixed ?
|
|
|
Post by Ipposnif on Oct 22, 2020 19:29:08 GMT
Yes, this is the problem, the D'Alembert was not meant to work with reset (for what I remember it was developed before the reset functionality). So it refunds the capital but doesn't restart the series. You can fix this yourself: open Database Command and execute the code below. The difference with the existing function is in the condition and NumReset=0 that force the function to work only with the last round series. I will apply the fix for everyone in the next release. Cheers!
ALTER FUNCTION [dbo].[fn_AlembertSize] (@id_strategy int, @unit_value numeric(18,6), @current_price numeric(18,6), @bidtype char(1)) RETURNS numeric(18,2)
AS BEGIN
declare @size numeric(18,6) declare @price numeric(18,6) declare @profit numeric(18,6) declare @capital numeric(18,6) declare @capital_last numeric(18,6) declare @win_units numeric(18,6) declare @bet_units numeric(18,6) declare @r numeric(18,2) declare @bf_fee_discount decimal(18,6) declare @capital_df decimal(18,6)
select @bf_fee_discount=5*convert(numeric(18,6),valuenum) from tbl_syscfg where Codice='bf_fee_discount' select @capital=capital from tbl_Strategies where ID=@id_strategy set @capital_last=@capital set @win_units=0 set @bet_units=1
DECLARE C3 CURSOR LOCAL STATIC FORWARD_ONLY READ_ONLY FOR select netprofit from (select * from tbl_trades union all select * from tbl_trades_old) tbl_trades where id_strategy=@id_strategy and NumReset=0 and deleted=0 and isnull(netprofit,0)<>0 and status='S' order by id OPEN C3 FETCH NEXT FROM C3 INTO @profit WHILE (@@fetch_status <> -1) BEGIN if @profit>0 begin set @win_units=@win_units+@bet_units set @bet_units=@bet_units-1 if @bet_units=0 set @bet_units=1 end else begin set @win_units=@win_units-@bet_units set @bet_units=@bet_units+1 end set @capital_last=@capital_last + case when @profit>0 then (@profit*(1-@bf_fee_discount)) else @profit end FETCH NEXT FROM C3 INTO @profit END CLOSE C3 DEALLOCATE C3 set @capital_df=@capital+(@win_units*@unit_value)-@capital_last
if @capital_df<0 begin set @capital_df=0 end else begin set @capital_df=(@capital_df/@bet_units) end
if @bidtype='b' begin set @r=((@capital_df+(@bet_units*@unit_value))*(1+@bf_fee_discount))/(@current_price-1) end else begin set @r=((@capital_df+(@bet_units*@unit_value))*(1+@bf_fee_discount)) end if @r<@unit_value set @r=@unit_value return @r
END
|
|
|
Post by halcyondaze on Oct 22, 2020 20:26:50 GMT
Excellent.
Thank you.
|
|
|
Post by halcyondaze on Oct 23, 2020 12:12:07 GMT
|
|
|
Post by halcyondaze on Oct 23, 2020 15:26:11 GMT
Testing custom progression as a staking plan also doesn't reset. I had a 3 price custom progression. It reaches the end and stops. reset condition @bet_size = 0 doesn't reset - it just stops.
It looks like the reset function doesn't restart the strategy for custom progression
|
|
|
Post by Ipposnif on Nov 10, 2020 19:38:30 GMT
Hi, I will rerun the strategy with the fix tomorrow, and try to find out the cause of the issue. Thank you for your patience!
|
|
|
Post by Ipposnif on Nov 12, 2020 19:43:28 GMT
I can confirm that there is an issue. The strategy starts resetting correctly, but after a while, something stops it from working well. I have configured the strategy to reset after two losses in a row. Currently, I'm quite busy with other projects, but I will investigate this issue as soon as I can and let you know.
|
|
|
Post by Ipposnif on Dec 2, 2020 19:19:06 GMT
I found out finally the reason for the wrong reset. Reset conditions are not processed in synchronous with the strategy bet placement condition but in an asynchronous way every 15 seconds. Since your strategy asks for a reset before the capital is finished, it happens sometimes that a new bet is placed before the reset conditions are checked. This prevents the reset to be executed because the reset can be executed only when there are no open bets. This has been done for performance reasons: it is too expensive to check the reset condition every strategy condition check, and normally a strategy is reset when it has finished its capital. Anyway, there is a loop around: no bet must be placed before a certain amount of seconds is elapsed since the last bet settlement. So if we wait, for example, for 30 seconds before placing a new bet, we are sure that the reset condition (every 15 secs) is checked before. Using the Database Command tool, execute the following SQL query, which will add a new variable:
insert into tbl_sysvariables (name,declaration,funct) select 'last_check_bet_seconds', 'declare @last_check_bet_seconds int', 'select @last_check_bet_seconds=DATEDIFF(second, isnull((select top 1 [lastget] from (select [lastget] from tbl_bets_old where ID_Strategy=@id_strategy union all select [lastget] from tbl_bets where ID_Strategy=@id_strategy) dvtbl order by [lastget] desc), dateadd(second,1,getdate())),getdate())';
This new variable is called @last_check_bet_seconds and it returns the number of seconds elapsed from the last status change of the previous bet in the same strategy. If there is no previous bet, for example, because the strategy just started, it returns -1. Ipposnif changes the status of a bet, for the last time, when it has been settled. Finally, you have to add in the strategy's bet Trigger Condition the following assertion:
@last_check_bet_seconds = -1 or @last_check_bet_seconds > 30
I'm testing this for a while without issues. Let me know if it worked also for you. Regards!
|
|