Change Opening Hours

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #235586 quote
    dubbzie
    Participant
    New

    I have created a script for trading the US TECH 100-CFD. I use SMA Daily Charts as entry and exit criteria. Is it possible to create a code that uses the opening hours of the underlying market, which are 09:30:00-22:00:00, instead of the CFD opening hours for backtesting and automatic trading?

    #235587 quote
    robertogozzi
    Moderator
    Master

    The indicator TRSMA at https://www.prorealcode.com/prorealtime-indicators/time-range-moving-averages-simple-exponential-weighted-trsma-trema-trwma/ will do the job, as you can set the desired time range. Outside that time range it remains flat.

    Iván González thanked this post
    #236117 quote
    dubbzie
    Participant
    New

    Takk…Unknown command for “CALCULATEONLASTBARS = 200”.

    #236118 quote
    robertogozzi
    Moderator
    Master

    That command is not available for strategies.

    If you want to embed that code into your strategy then you have to use these lines, choosing your preferred settins (Periods, StartTime and EndTime):

    Periods   = 20
    StartTime = 090000
    EndTime   = 180000
    i = 0
    TRSMA = 0
    FOR j = 0 TO 3000
       IF opentime[j] >= StartTime AND opentime[j] <= EndTime THEN
          TRSMA = TRSMA + close[j]
          i = i + 1
          IF i = Periods THEN
             BREAK
          ENDIF
       ENDIF
    NEXT
    TRSMA = (TRSMA / Periods)
    IF TRSMA = 0 THEN
       TRSMA = close
    ENDIF

    then use variable TRSMA to know the value.
    Alternatively, you can call the indicator using the CALL statement, as follows:

    TRSMA = CALL "TRSMA - Time Range SMA"[20, 90000, 240000]

    changing the values ​​20, 90000 (it would be 090000, but leading zeros are ignored) and 240000 as you like.

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

Change Opening Hours


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
dubbzie @dubbzie Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by robertogozzi
1 year, 6 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 07/21/2024
Status: Active
Attachments: No files
Logo Logo
Loading...