Pages:
Actions
  • #1 by JP_potts on 29 Dec 2022
  • I'm having some trouble utilising the time variables.

    I have triggers that open and close trades.  Sometimes they close with the incorrect stake, which means they leave the trade with a larger PL on one side.

    To get around this, I have created a trigger that waits a few minutes after the last matched bet, and then equalises the PL.  Which works quite well in Time Machine.



    The trigger above waits until 
    -There are no unmatched bets.
    -There is at least 1 matched bet
    -(now_time-bm_1_laytime) or (now_time-bm_1_backtime) is greater than 0.004

    I came up with 0.004 by dumping out the times, and working out what they meant.

    10:20:00 = 43487.4305563
    10:25:33 = 43487.4344155 

    By the above, I concluded that 0.004 is about 5 mins.

    Unfortunately, it doesn't work as expected.

    As you can see below, the trade is executing instantaneously:


    Would anyone be able to shed some light onto this, as I can't quite work out what I've done wrong?


  • #2 by MarkV on 29 Dec 2022
  • Hi
    Try:
    (now_time-bm_1_laytime)/mf_minute is greater than 5

    the helpfile has a section on the date and time format and time calculations but it is easier to use the variables that define a second, or a minute or an hour.

    e.g. the above formula could also be:
    (now_time-bm_1_laytime)/mf_second is greater than 300 
  • #3 by Tim (WellDoneSoft) on 29 Dec 2022
  • There is a principal difference in these variables:
    bu_1_backtime / bu_1_laytime - the time the bet was placed
    bm_1_backtime / bm_1_laytime - the time the bet was matched


    So it's always
    bm_1_backtime >= bu_1_backtime
    for the same bet.
    And... it's possible the last matched bet is not the same as the last unmatched bet was!
  • #4 by JP_potts on 29 Dec 2022
  • Thanks guys
Pages:
Actions