Stop Loss tick by tick

LAY bet 30.00 EUR matched at 2,94. BACK bet 30.00 EUR placed at 3,05. Market going against me.
My idea is: When the conditions of StopLoss are met, move bets "tick by tick" every 2500* miliseconds. In several steps, not in one huge StopLoss step as usual. (* for example)

 tick-by-tick stop loss

 

I would like to see how can I prepare bot (or part of code). Thanks.

Comments (2)

  1. StefanBelo Says:
    Wednesday, March 31, 2010

    C# source code for betfair bot

    To program such betfair bot functionally you can reuse the bot PlaceBetBot to place your opening bet and then override DoYourJob method to add required features for your trading bot. First you have to realize through which states your bot will go, after the PlaceBetBot bot places its opening bet and signals that your opening bet is fully matched, so your bot can continue with trading.

    So what are those states?

    1. TradingState.WaitingForTrade - after the PlaceBetBot done its job, and your bot is ready to place closing bet.
    2. TradingState.BackingInProgress or TradingState.LayingInProgress - after your bot places its closing bet and the bet is unmatched. In this state you have to check if your bet position reaches preset stop loss level, if so your bot must start updating your unmatched bet 1 tick down/up (depending on your opening bet) every preset timeout (2500 ms).
    3. TradingState.BackingBetDone or TradingState.LayingBetDone - When all your bets are matched, at this state you can show a message saying about your profit or loss and stop your bot, job done.

    You can write following C# code:

    public override void DoYourJob()
    {
      base.DoYourJob();
    
      if (betPlaced)
      {
        switch (tradingState)
        {
          case TradingState.WaitingForTrade:
            ClosePositionForProfit();
            break;
          case TradingState.BackingInProgress:
          case TradingState.LayingInProgress:
            if (GetCanUpdateClosePosition())
            {
              UpdateClosePosition();
            }
            break;
          case TradingState.BackingBetDone:
          case TradingState.LayingBetDone:
            StopBot();
            break;
          default:
            break;
        }
      }
    }
    

    Your bot uses all parameters of the PlaceBetBot, and the trading part of your bot uses following three parameters:

    • MinOddsDifference [ticks] to close position for profit
    • StopLossOnPercentageLiability [ticks] to close position for loss
    • StopTradingCycleAtProfit - time [ms] to wait for bet updating when using tick by tick mode

    Your bot class name is:

    Bfexplorer.Scripting.PlaceBetClosePostionStopLossTickByTickBot

    Use it with the Bot Executor and MyBot settings. I have included this betfair bot script to the latest version of Bfexplorer PRO so you will find the source code file in the MyBots folder. Install the latest version of Bfexplorer PRO.

  2. Mir. Says:
    Monday, April 05, 2010

    This is exactly what I wanted. Thanks again.


Do you want to comment this article? Sign up here or login.