Time of candle opening vs time of candle closing

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #238562 quote
    Brad
    Participant
    Senior

    Hi All,

    Could someone please confirm the logic in the following code?

    IF (DayOfWeek = 1 AND Time <= 080000) THEN
       Trading = 0
    ELSE
       Trading = 1
    ENDIF

    The code specifies that no entries are allowed if it is Monday and the time is at or before 08:00.

    What happens if my trigger candle meets all the entry conditions, opens at 08:00, and closes at 08:15? Is this considered a valid entry, given that the candle closes at 08:15?

    Regards,
    Brad

    #238568 quote
    GraHal
    Participant
    Master

    trigger candle meets all the entry conditions, opens at 08:00

    But it wouldn’t meet the condition Time <= 080000, you would need to use Time < 080000?

    Brad thanked this post
    #238569 quote
    Brad
    Participant
    Senior

    My concern is when testing it on the demo account, the trade is triggered.

    Screenshot-2024-10-07-112555.png Screenshot-2024-10-07-112555.png
    #238577 quote
    GraHal
    Participant
    Master

    The candle that triggers the trade is the close of the 07:45 candle (which is < 080000) and then the trade is opened at 080000.

    Did you try it with Time < 080000 (not <=) is the trade still opened at 080000?

    EDIT / PS

    Just cheked your ss and the trade is opened at 081500 after being triggered at the close of the 080000 candle … so that is correct as your code??

    Iván González and Brad thanked this post
    #238580 quote
    Iván González
    Moderator
    Legend

    Exactly. As Grahal says, the activation occurs on the previous candle. The reason is that the condition Time <= 080000 is true on the previous candle (at the close of the candle it is already 8:00).

    Brad thanked this post
    #238582 quote
    Brad
    Participant
    Senior

    So, to avoid confusion, is the demo entry correct, as seen in the screenshot?

    #238583 quote
    GraHal
    Participant
    Master

    Yes, demo entry is correct as per your code … IF (DayOfWeek = 1 AND Time <= 080000) THEN

    Brad thanked this post
    #238585 quote
    Brad
    Participant
    Senior

    Thanks for the clarification, gents. That means a live trade was not triggered.

    #238604 quote
    robertogozzi
    Moderator
    Legend

    If you run this code you will se the entry ARROW plotted just under the candle labelled 08:00 every Monday, since the trade is actually entered at 08:00 because the order is placed when the 07:45 candle closes:

    IF OnMarket THEN
       SELL at Market
    ENDIF
    IF (DayOfWeek = 1 AND Time = 080000) THEN
       BUY at MArket
    ENDIF

    replacing line 4 by this one, you will se the entry ARROW plotted just under the candle labelled 08:15 every Monday, since the trade is actually entered at 08:15 because the order is placed when the 08:00 candle closes.

    IF (DayOfWeek = 1 AND OpenTime = 080000) THEN
    Iván González, Brad and druby thanked this post
    #238773 quote
    Brad
    Participant
    Senior

    Thanks Roberto

    Small changes can make big differences!

    robertogozzi thanked this post
Viewing 10 posts - 1 through 10 (of 10 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

Time of candle opening vs time of candle closing


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Brad @bradkinsey-2 Participant
Summary

This topic contains 9 replies,
has 4 voices, and was last updated by Brad
1 year, 11 months ago.

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