Stipulate Trading Times

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #30677 quote
    deletedaccount14122020
    Participant
    New

    Hello,

    My system trades on a 4 hour chart so new candles (and new trades) are triggered at 00:00, 04:00, 08:00, 12:00, 16:00, 20:00

    I am trying to add some code so that trading can only occur at 04:00, 08:00, 12:00 and 16:00 and not 00:00 and 20:00

    Can anyone advise if this is possible and if so which programming function(s) should I use

    Many thanks

    #30679 quote
    deletedaccount14122020
    Participant
    New

    As a follow up to this request I have ruled out using FLATBEFORE or FLATAFTER as I don’t want existing trades to be closed by these commands

    #30701 quote
    AutoStrategist
    Participant
    Veteran

    I was going to suggest this code to test against before making a trade:

    ValidTime = not ((time = 000000) or (time = 200000))

    But to my surprise I can’t get it to work as still takes some positions at 20:00.  Either a bug in the system or a bug in my thinking.

    @Nicholas can you take a look please

    Using a 4 hour chart on a forex pair using the code below it still takes some positions at 200000 (see attached screenshot) even though the TimeCount graph output is 0? Only does this for 200000 not any of the other times.

    defparam CUMULATEORDERS = true
    once TimeCount = 0
    if not (time = 200000) then
    Buy 1 contract at market
    if time = 200000 then
    TimeCount = TimeCount + 1
    endif
    endif
    graph TimeCount
    GBPUSD.jpg GBPUSD.jpg
    #30711 quote
    Eric
    Participant
    Master

    @TradeRanger

    You can probaly do it different ways

    you can try this

    ..and Time > 035900 and Time < 195900 Then buy..

    #30713 quote
    deletedaccount14122020
    Participant
    New

    Many thanks @ AutoStrategist and @Eric for your input. Like @AutoStrategist I got the same results with TIME 200000

    I’ve now incorporated the code from @Eric into my system and backtested it on 12 currency pairs and it all appears to be working correctly

    //Determine times when trading is allowed
    ValidTime = (TIME > 035900) AND (TIME <195900)

    once TradeTime = 1

    IF ValidTime THEN
    TradeTime = 1
    ELSE
    TradeTime = 0
    ENDIF

    Again thanks for your help

    Screen-Shot-2017-04-02-at-14.13.32.png Screen-Shot-2017-04-02-at-14.13.32.png
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Stipulate Trading Times


ProOrder: Automated Strategies & Backtesting

New Reply
Summary

This topic contains 4 replies,
has 3 voices, and was last updated by deletedaccount14122020
8 years, 11 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/02/2017
Status: Active
Attachments: 2 files
Logo Logo
Loading...