Backtesting trading hours

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #217266 quote
    OMXet
    Participant
    Junior

    Hello

    I’m sure someone here can help me ;>)

    I want to backtest if I  run the script certain hours, e.i. trading hours 03.00-23.00.

    More specific I’m interested to know when it is optimal to close all trades between 22.00-2300 and start script 02.00-05.00 in 10 minutes intervals.

    #217270 quote
    GraHal
    Participant
    Master

    when it is optimal

    Use the optimiser on Time … min 000000 max 2350000 step 001000.

    I mostly find optimal for Hour to be Hour > 9 and Hour < 21.

    If you want to avoid overnight charges then close all trades before 9pm uk time.

    #217549 quote
    ProRealAlgos
    Participant
    Junior

    I have found the ProRealTime optimizer to be quite buggy on FLATAFTER time aswell as genereal time conditions. Also, when optimizing a variable e.g. time from 220000 to 230000 with a step size of 1000, ProRealTime will also test time values that don’t exist e.g. 226000, 227000, 228000, and so on which will take unnecessary execution time.

    I prefer actually writing it as a long IF-statement. Takes more time to write the code, but seems more reliable.
    See example below where you optimize the variable a with a stepsize of 1.

    if a = 1 and time = 220000 then
    sell at market
    elsif a = 2 and time = 221000 then
    sell at market
    elsif a = 3 and time = 222000 then
    sell at market
    elsif... 
    .... and so on 
    endif
    
    #217554 quote
    PeterSt
    Participant
    Master
    if a = 1 and time = 220000 then

    I would not do it like that, because it is not said that your code will be called when nothing happened in the previous bar (no ticks). For 21:59:59 (Amsterdam) that would be unlikely but with 22:10 …
    So I would code it as > … and < …

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Backtesting trading hours


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
OMXet @omxet Participant
Summary

This topic contains 3 replies,
has 4 voices, and was last updated by PeterSt
2 years, 7 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 07/04/2023
Status: Active
Attachments: No files
Logo Logo
Loading...