Author Topic: Error when trying to place a bet in a trigger  (Read 1186 times)

Tags:
  • All members
  • Posts: 5
Error when trying to place a bet in a trigger
« on: 28 Aug 2021, 15:29 »
Hi,
I've modified one of the triggers supplied with marketfeeder to use a user variable to hold the amount to bet. I initially set this variable (current_bet) to 2.00.

This works fine with the first bet but when I recalculate the value of the variable after a loss the variable is set to the correct amount but with a load of trailing zeros (e.g. 1.18000000). This then causes the bet to fail with the error:

Selection: Aratus, initial expr.: current_bet, intermediate: 1.18000000), final: 1.18000000).
14:15:01   Error in the trigger expression of price or amount for selection "Aratus".
14:15:01   All bets will be discarded.

I know it's the amount and not the price that has the error because if I reset the user variable in the view user variables window to 1.18 the bet gets placed immediately.

How do you stop the user variables from getting the zeros on the end?

  • Moderator
  • Posts: 3597
*
Re: Error when trying to place a bet in a trigger
« Reply #1 on: 30 Aug 2021, 08:52 »
Hi
Difficult to say without seeing the trigger but several things could be worth checking:

"current_bet" is a very common user variable in staking plan triggers, and it's value could be updated by any number of triggers. If your user variable is intended to be a separate variable, then check the trigger file to see if "current_bet" is referenced anywhere else. If yes then change the name of your user variable so that it is unique.

Have you initialized your user variable before including it in calculations triggers etc. Either by using a Constant, or by setting a value with a trigger.

The Scope of a user variable, like individually per selection, could conflict for example with a Constant which always has Global scope.      
Please read the following disclaimer with regards to the information you may request and obtain on our forum. This specifically concerns trigger files and various instructions as to how to implement a strategy.

  • All members
  • Posts: 5
Re: Error when trying to place a bet in a trigger
« Reply #2 on: 30 Aug 2021, 11:00 »
Thanks for the reply.

Following on from your comments I've looked at the set of triggers again and I can see that the user variable current_bet gets set from the value in another user variable current_loss and it's that variable that gets set to a floating point number with the trailing zeros.

I've changed the name of current_loss to my_current_loss to avoid any possible clashes with frequently used names and rerun the triggers. Unfortunately, the same problem happens.

The variable my_current_loss is defined as a constant and set to an initial value of 0.00.

I've attached some screenshots of before an after the first bet is settled.

This first bet gets placed ok. I then settle the market and make the bet lose. This causes the trigger that deals with a loss to fire and set the appropriate variables.

11:43:29Checking market "Horse Racing / GB / Wolverhampton 30th Aug / 13:00 Wolverhampton 30th Aug - To Be Placed".
11:43:29Checking condition and Market's Settled P/L is less than 0.
11:43:29Condition is: TRUE. valid for 1 selections: Youllovemewheniwin.
11:43:29Selection: Youllovemewheniwin, initial expr.: current_step + 1, intermediate: 1+1, final: 2.
11:43:29Setting variable current_step to 2.
11:43:29Selection: Youllovemewheniwin, initial expr.: my_current_loss - last_pl, intermediate: 0--2.36, final: 2.36000000.
11:43:29Setting variable my_current_loss to 2.36000000.
11:43:29Selection: Youllovemewheniwin, initial expr.: IF(current_step > 1, my_current_loss, current_bet)), intermediate: IF(2>1,2.36000000,2.00)), final: 2.36000000).
11:43:29Setting variable current_bet to 2.36000000).


The user variables are now as shown in the second attachment.

As you can see, my_current_loss is set to 2.36000000 which in turn sets current_bet to 2.36000000. This causes the next bet to fail when using current_bet as the amount to bet.

Any idea why this happens?

  • Moderator
  • Posts: 3597
*
Re: Error when trying to place a bet in a trigger
« Reply #3 on: 30 Aug 2021, 16:53 »
Hi
This formula will not resolve correctly - it puts an extra close bracket which can be seen in the log:

11:43:29Setting variable current_bet to 2.36000000)

IF(current_step > 1, my_current_loss, current_bet))
should be
IF(current_step > 1, my_current_loss, current_bet)

also, I would rename my_current_loss to something unique which does not contain "current_loss", eg. mcl


Please read the following disclaimer with regards to the information you may request and obtain on our forum. This specifically concerns trigger files and various instructions as to how to implement a strategy.

  • All members
  • Posts: 5
Re: Error when trying to place a bet in a trigger
« Reply #4 on: 31 Aug 2021, 11:41 »
Hi
I've fixed the error with the IF statement (removed erroneous bracket) and I tested it again.

The value of the variables still had the trailing zeros but the next bet got placed ok.

So, the error with the IF statement was the cause of the problem all along and not the trailing zeros.

Obviously, each time I manually set the current_bet variable to a value without the zeros it removed the bracket from the end.

Sorry to have wasted your time on this MarkV as I should have noticed this straight away.

Many thanks.




 

Please note, BetFair is seems to be currently OFFLINE