Code for trading day and time

Forums ProRealTime English forum ProOrder support Code for trading day and time

Viewing 6 posts - 1 through 6 (of 6 total)
  • #175699

    Hello I would like to know how to code to compare two candlestick of too different trading date and with a defined trading time :

    exemple

    how to compare the opening price of a 5 min candlestick the 2021 08 15 @ 10h30 and the closing price of a 5 min candlestick the 2021 07 15 @ 17h35
    I can’t find this in the compagny’s trading book exemples.

    Many thanks for your help

    Regards

    #175706

    There’s no specific instruction, you need to store the current value  in a variable, then use FOR…NEXT to scan past candles until you find the desired one:

    Only post in the language of the forum that you are posting in. For example English only in the English speaking forums and French only in the French speaking forums.

    I moved it from the French forum.

    Thank you 🙂

     

    #175710

    Many thanks for your help and your reactivity

    best regards

     

    Pierre

    #175843

    Dear Mr Robertogozzi hello,

     

    Once again thanks for your help

    Is it possible to get another help :

     

    I would like to know if it’s possible for the function Opentime and Opendate to use a variable value : to be able in a backtest to optimize

    for exemple the best trading time and the best trading day for a trading system

    exemple

    I want to backtest this system :

     

    I compare the opening price of a 5 minute candle today (it could be a variable as well to test 10 minutes 30 minutes, 1 minute…) @ 10h30

    (for exemple but I would like to use a variable data to see if it’s better to compare the previous day @ 10 h30 o r 10h25 or 10h35 …)

    with the closing price of a contract the previous trading day @ 18h30 (for exemple but I would like

    to use a variable data to see if it’s better to compare the previous day @ 18 h30 o r 18h35 or 18h40 …)

    If it’s up, I buy a contrat and then I keep the position for a few hours, and I sell this osition of 1 contract later today @ 16h30

    (for exemple but I would like to use a variable data to see if it’s better to keep the position later or sooner @ 16 h35 o r 16h40 or 15h30 or 15h35 …)

     

    I would appreciate if you can help me on this code

    Many thanks for your time

    Best regards

     

    Pierre

    #175866

    Yes for both OpenTime and OpenDate, but as to OpenDate I can’t think of any situation where optimization could be of much use.

    For both of them you can replace numeric constants with a variable name of your choice to be used in optimization.

    For OPENTIME you can set a starting time, say 090000, an ending time, say 170000 and a step, say 010000 for 1 hour.

    I suggest that you always enter 6 digits and ignore if they are later dropped.

    OPENDATE requires 8 digits, instead.

     

    #175983

    TIMEFRAME does not support variables, so you have to optimize it changing the TF manually.

    To compare any candle today with the previous at a given time you have to use a variable, then compare any subsequent candle with it:

    Then use Time1830 to be compared to other candles, it will change everyday at 183000 (you can optimize it as explained above).

Viewing 6 posts - 1 through 6 (of 6 total)

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