Buying as price crosses previous high

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #188066 quote
    from8to800
    Participant
    Average

    Hi all,

    I’m trying to program a strategy whereby if a condition for the previous week is true, then I want the system to buy at the market as soon as the current week crosses above the high of the previous week.

    For instance:

    Week #23 = Signal is true

    System buys during week #24, as soon as prices trade above the high of week #23. See attached picture to describe what I mean.

    Currently, the code is buying at market on Week #25. I suspect this is because it only confirms that the high of W#24 is higher than the high of W#23 once W#24 itself is finished, which is too late for what I want.

    Any ideas?

    Thank you.

    issue.jpg issue.jpg
    #188108 quote
    robertogozzi
    Moderator
    Master

    Post your topic in the correct forum:
    _ ProRealTime Platform Support: only platform related issues.
    _ ProOrder: only strategy topics.
    _ ProBuilder: only indicator topics.
    _ ProScreener: only screener topics
    _ General Discussion: any other topics.
    _ Welcome New Members: for new forum members to introduce themselves.

    I moved it from ProBuilder.

    Thank you 🙂

    If you are using a weekly TF, the strategy can only verify that week #24 has broken the prior high (week #23) when week #24 closes, so the trade will open at the beginning of week #25.

    You need to use the MTF (Multiple Time Frame) support to use your strategy on a lower TF, such as daily or hourly. In such case the strategy will still be run at the closing of a bar, but closing daily or hourly (or even less), thus not having to wait a whole week.

    If you search this forum for the word MTF you will be returned many links to code snippets and info on that topic.

    #188121 quote
    nonetheless
    Participant
    Master

    You can use something like this. The second timeframe can be anything you want (as Roberto said), then just add the rest of your strategy.

    timeframe(weekly, updateonclose)
    HW = high
    LW = Low
    
    timeframe(15 minutes)
    cb1 = close crosses over HW
    cs1 = close crosses under LW
    robertogozzi thanked this post
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Buying as price crosses previous high


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
from8to800 @from8to800 Participant
Summary

This topic contains 2 replies,
has 3 voices, and was last updated by nonetheless
4 years ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/11/2022
Status: Active
Attachments: 1 files
Logo Logo
Loading...