Pages:
Actions
  • #1 by whitey86 on 25 Jun 2013
  • Hi all,

    I'm trying to work out the average trade on the 2nd selection and have written a trigger to get the data. The only problem is The very last variable avg_trade breaks the whole thing and I have no idea why. I have attached the tirgger below.

    If you have a look at the variables you can see there is a running total (running_total) and a counter (num) that counts when a trade of over £1 has taken place. So it should be running_total / num is the average - but use either variable and it breaks the whole thing.

    Try it for yourself, just remove avg_traded and the rest works fine.

    Any help would be greatful.

    Thanks,

    Whitey :)
  • #2 by MarkV on 25 Jun 2013
  • Hi
    Try this. It works OK, but updates the average at the frequency of 2x refresh rate because it is in a repeating block.
  • #3 by whitey86 on 25 Jun 2013
  • Thanks MarkV (and thanks for the help in the past),

    Can you think of a way to make it work faster? At the minute it works better than what I did but it is working out the average by adding 1 to num every 6 seconds or so - but in 6 seconds 20 bets could have been matched at all different amounts.

    Or is there a simpler way of doing it?

    Thanks,

    Whitey
  • #4 by MarkV on 25 Jun 2013
  • Hi
    If you view the formula running_total / num in the variables window, it shows the value and updates at a decent rate, using your original trigger.

    I was trying to see if there is a way to do the whole thing in one formula, but can't think of it just now. If I do I'll post.

    Can anyone else suggest how to improve the speed of the trigger?
  • #5 by mcbee on 25 Jun 2013
  • hi
    the   total_traded   variable, should be the first action, not the second, because  last_bet_amount  variable is using  the total_traded  as part of its calculation.


    mcbee
  • #6 by whitey86 on 26 Jun 2013
  • MarkV:

    Oh yeah, weird how you can use running_total / num in the variables window - you can use it like that in the triggers too - so I will just use it like that.

    mcbee:

    total_traded needs to be below last_bet_amount because last_bet_amount calulates what the total now minus the total before is to get the bet amount. Therefore total_traded will always need to be 1 behind

    Thanks,

    Whitey
Pages:
Actions