Return last market close

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #140581 quote
    martentornquist
    Participant
    New

    I am trying to make some code to return the last market close (since DClose(1) seems to return the midnight close) to calculate the rate of change since last market close in ProOrder. I think the following code should work (trying to debug it by adding it as an indicator):

    marketCloseTime = 173000
    marketCloseHour = 17
    marketCloseMinute = 30
    barLength = 3
    intradayCloseBar = marketCloseHour * 60 / barLength + marketCloseMinute / barLength
    intradayBars = 24 * 60 / barLength
    currentBar = OpenHour * 60 / barLength + OpenMinute / barLength
    
    IF (OpenTime >= marketCloseTime) THEN
    numberOfBars = currentBar - intradayCloseBar
    ELSE
    numberOfBars = intradayBars - intradayCloseBar + currentBar
    ENDIF
    
    RETURN close[numberOfBars]

    but it is not… It seems like the numberOfBars ends up being “fixed” when used together with close[], so the last bar of gets the close of 173000 correct, but the second last gets 172700 which is not what I want. I want all bars to return the close of the last 173000.

    If I do “RETURN numberOfBars” then it correctly returns the number of bars since last 173000.

    What am I missing? Or is there some easier way to get the last market close?

    Thanks in advance!

    /Mårten

    #140583 quote
    robertogozzi
    Moderator
    Master

    Try this:

    ONCE x = close
    IF OpenTime = 173000 THEN
       x = close
    ENDIF
    RETURN x AS "Last Daily Close"
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Return last market close


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzi
5 years, 7 months ago.

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