Add & subtract time

Forums ProRealTime English forum ProOrder support Add & subtract time

Viewing 10 posts - 1 through 10 (of 10 total)
  • #118095

    Hello there folks,

    I’m building a system that uses predefined time periods to enter trades. The time periods are derived from a single figure (i.e. 083000) combined with a number of minutes before and after the original figure to give a time zone where Pro Order is allowed to enter. For example, with an 8-minute buffer on either side, an original time of 083000 becomes an allowable trading zone that begins at 082200 and ends at 083800. I am manually typing a middle value for each trade, and then trying to automatically spread an entry range either side of it.

    The code I have added here creates the zone correctly most of the time using the top variables “beforetime” and “aftertime”, but when it tries to add from a time that is towards the end of the hour, i.e. 085600, it understandably fails to come up with the right time of 090400.

    085600 +

    000800 (8 minutes) =

    086400 (which obviously isn’t a real bar time because there is never a 64th minute in an hour!)

    Although I know it is possible for me to work around this by telling Pro Order to only enter each trade between a time range (i.e. between 085600 and 090400), unfortunately this is no good for my backtesting. I want to quickly be able to answer the question of “what would my profit have been last week if I increased the range from the middle figure to be +16minutes and -16minutes?” I need some way of finding the optimum width of my allowed trading zones without retyping every single entry and exit time.

    Does anyone know how I could do this?

    Thank you in advance…

     

     

     

    #118114

    Did you try adding code to achieve something like …

    4R = 4th digit from right
    5R = 5th digit from right

    If 4R = 6 Then
    4R  = 0
    5R = 5R  + 1
    Endif

     

     

     

    #118124

    Thanks for the response.

    No, I haven’t tried doing that. What syntax would I need in order to capture “4th digit from right” in a six-digit number?

    #118125

    I tried the same using hours/minutes to let stop/limit orders run a certain time in the future using a timeframe retrieval snippet from Nicolas & Vonasi, which then is possible to optimise with factor x .

    The problem occurred when reaching the end of the hour or let’s say the end of the day. I thought time would be more robust then bars because sometimes there are no bars when going to lower timeframes or have an instrument with low volatility.

    Anyway I settled with bars. So x bars after the bar I specify (and before). Have a look at the programming guide prorealtime on p11.

    Still i’am curious if you find a way for your approach!

    #118130

    What syntax would I need in order to capture “4th digit from right” in a six-digit number?

    Off the top of my head, no idea if / how it would work, but I was thinking somehow using …

    Time = 6R5R4R3R2R1R

    Might spark an idea in our resident coding wizards minds? 🙂

    #118136

    Above should read MyTime =  6R5R4R3R2R1R  (from your calcs / whatever you are calling the results of your calcs in your code).

    I say above as TIME (reserved word in PRT) could never get to 6 as a 4R digit etc.

    #118176

    time is  simply HH MM and SS.

    Then if we add a period of time on – for example HH=22 and we add 8 hours we get HH=30.

    Then we say that if HH>24 then HH=HH-24 which will mean HH=6.

    We also need to check if HH=24 and change it to HH=00 if it does.

    We then reassemble our HH MM and SS to get our new time value.

     

     

    1 user thanked author for this post.
    #118177

    Here is how to break time down to HH MM and SS

     

    3 users thanked author for this post.
    #118197

    Thanks for the suggestion, but I’m struggling to understand how to incorporate it into my current code. At the moment I have eight instances of time that I manually input (eventually this will be for every day of the week, so there will be 40). Do I need to copy your code and replace “opentime” with each instance of my manually inputted time, i.e. wedtime2=065800?

     

    #118198

    Vonasi time breakdown added as Log 197 here …

    Snippet Link Library

     

    1 user thanked author for this post.
Viewing 10 posts - 1 through 10 (of 10 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login