Article

Bot Trigger Building Part 4

In the final Part of this tutorial, I would like the bot to stop and give us a warning message in the console if it has had X losses in a row.

Seeing as the bot runs fully automatic, if I am not in front of the computer and for whatever reason I am having a bad run, I'd like to limit my losses so that I have the opportunity to evaluate and not lose my account.

Bfexplorer can trigger based on account balance, but for the purpose of this tutorial it would be good to see how to build a trigger that actually monitors the performance of our custom bot, so that in the future should we wish, we can build upon this information - for example after x losses instead of stopping the bot, you may modify it to adjust your stake etc.

I hope that this Bot Trigger Building tutorial is a valuable resource for every user of Bfexplorer that wishes to build their own Bot.

Comments ( 7 )


  • Stefan
    1.10.2019 14:20:51

    We have got your strategy for horse racing programmed as bot trigger:

    Bot Trigger Building Part 2

    Bot trigger code is executed by bot called: “Execute Trigger Bot”, and trigger executes the action bot, so bot strategy that places bets or starts trading session. In my test I used: “Lay trade 4 ticks”. I named this strategy: “Horse Racing Bot Trigger”.

    So you have got your strategy that can be executed manually from My Strategies /Bots to Execute, on the market you open in Bet Event view, just selecting your strategy “Horse Racing Bot Trigger” and clicking on the Execute toolbar button.

    If you want to execute your strategy automatically on all races, then you can use “Bot Executor” tool.

    Bfexplorer app offer more general purpose bot strategies, one them is bot strategy named: “Execute Till Target Profit”, and that is what you need, to stop the execution of your strategy when it is executed automatically, when target profit or loss is reached. Again, the bot uses action bot to be executed, set by parameter BotName, in our case we want to execute: “Horse Racing Bot Trigger” and that is all. Just name your strategy (I named it: “My Horse Racing Strategy”) and execute it at set time relative to the race time (market start time).

    When programming your strategy using Bfexplorer BOT SDK, you have got access to all bfexplorer generated data with public interface, so you can access your betting results, or create your own version of “Execute Till Target Profit”.

    For instance Bfexplorer Console, the tool executing a script code to automate bfexplorer UI interaction, or querying data. The similar script can be programmed to read your strategy results and process data.

    For instance here is script opening Match Odds and Over/Under 2.5 Goals markets that met required parameters:

    SearchFootballMarkets.fsx

  • peteresgate@outlook.com
    2.10.2019 10:09:05

    Please see my attempt at Part 4. I added lines 75, 76, and 178 to 184.

    I basically wanted to have parameter maxLossesInRow and if the number of losses in row is less or equal to this parameter, then continue to execute bot, or else exit. Unfortunately it has some errors that hopefully can be corrected thanks?

    https://github.com/PeterEsgate/BfexplorerTestBots/blob/master/HorseRacingBotTrigger2

  • Stefan
    2.10.2019 10:21:05

    You cannot use console script code in your bot trigger code. It was created in other context and for other purpose.

    If you would read error message in Visual Studio or Visual Code (I do not know which IDE you are using.), then errors would suggest problems in your code.

    Please, just read what IDE suggests.

  • peteresgate@outlook.com
    2.10.2019 10:59:40

     Oh ok.  I sort of grabbed your code from My Staking Plan . Could you please explain the mechanism of how to run the console script and also have MyBotTrigger "get" the information from it?  And 1 other question- with my C sharp bot or my f sharp bot, would they require the console script as well for past bot results?

    Thanks.

  • Stefan
    2.10.2019 12:21:02

    Peter, I will really suggest you to read error messages when you build your bot trigger.

    First error reports:

    This function takes too many arguments, or is used in a context where a function is not expected.

    It is where you put HorseRacingBotTrigger2, so constructor of your bot trigger, constructor is function as input to the function:

    MyStrategyOperations.GetMyStrategyResults expects as input strategy name, so string/text value.

    Ok, when you correct input value, so incorrect context you type:

    let myStrategyResults = MyStrategyOperations.GetMyStrategyResults(botName)

    Then there is no other error in this line, but you must understand what is actually returned by GetMyStrategyResults, and how you will use it.

    When you hover your mouse over GetMyStrategyResults, tooltip shows you what you will get, and this data must be used in correct context as well.

    Please read about programming at least couple pages of text, because code is not just text.

    It is like you misspell a sentence the way no one is able to understand what you wanted to say.

    You can develop your bot trigger in C# programming language as well, but as script you can use only code written in F#.

    I can prepare simple bot trigger working with previous results, but I do not think you will manage to use such code yourself.

  • peteresgate@outlook.com
    2.10.2019 12:38:50

    Thanks Stefan, Yes I would really appreciate if you could design the bot that works on past results, and I will endeavour to thoroughly understand the code and learn f# so that I can do this myself in the future from what you have taught and shown in this tutorial series :)

  • Stefan
    2.10.2019 14:04:20

    For me it is really hard to help you with understanding a programming language, because I know many programming languages, and all is understandable for me.

    I can read or start programming with any programming language just from seeing code samples or tutorials in minutes.

    I would suggest reading the following post, or entire web site:

    https://fsharpforfunandprofit.com/posts/fsharp-in-60-seconds/

    On the Internet you can find a lot of videos, tutorials, books, and so on. As I mentioned if you have problems to understand F#, and C# is better alternative then you can switch your code to C# or Visual Basic.