Close at a set time on a previous day 

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

    Can some one please point me in the correct direction for some code, I am aiming for the following:

    Close at a set time on a previous day

    Where the time and the relative day are variable.

    Many thanks

    #133524 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    How can you close at a set time on a previous day, say yesterday?

    You should have closed yesterday.

    #133798 quote
    BoltBolt
    Participant
    New

    Apologies I might not have been clear in my wording. I am trying to perform a price test on historic prices as a set time of day to base the decision to open on.

    In words I am trying to achieve the following:

    I want the price at 4pm 5 days ago to compare to the price at 4pm yesterday. If this is positive I will open a position at the today at 11am .

    I have tried the below but is it not working as expected on 1 hour charts

    IF (dclose (5) <= dclose(1)) AND (hour=16 and minute = 0000) THEN

    C1= 1

    endif

    IF (C1=1 AND time = 080000 AND not daysForbiddenEntry) THEN

    BUY 1 PERPOINT AT MARKET

    ENDIF

     

    I am sure it must be simple, just new to this and trying to get some basic testing done.

    Man thanks for any input in advance.

    #133800 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    I understand. It’s not possible to reference past times using brackets as only past bars can be referenced.

    You have to save 5 prices at the same time, shifting them as days go by, then compare each day the previous one with the 5th previous one. You’ll have to use 5 different variable names (v11 might allow using arrays, but they are not much help this time):

    ONCE Day5 = 999999
    ONCE Day4 = 999999
    ONCE Day3 = 999999
    ONCE Day2 = 999999
    ONCE Day1 = 999999
    IF time = 160000 THEN
       Day5 = Day4
       Day4 = Day3
       Day3 = Day2
       Day2 = Day1
       Day1 = close
    ENDIF
    IF time = 110000 THEN
       C1 = 0
       IF Day5 <= Day1 THEN
          C1 = 1
       ENDIF
    endif
    IF (C1=1 AND time = 110000 AND not daysForbiddenEntry) THEN
       BUY 1 PERPOINT AT MARKET
    ENDIF
    #133801 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Sorry, I just edited line 15 due to mistyping.

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

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Close at a set time on a previous day 


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Bolt @richard_bolton Participant
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by robertogozzirobertogozzi
6 years, 4 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/27/2020
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...