buy at a new all time high

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #101203 quote
    higherlows
    Participant
    New

    Looking for the entry condition to buy at a new all time high? Whats the code?

    #101207 quote
    robertogozzi
    Moderator
    Master

    It’s the number of previous bars you want to test that makes a high as the all-time high or not.

    If you run your code on a 1-minute TF, even with 1M bars (v11 will allow this huge number), you’ll get the highest high of roughly the last 3.5 years, while on a MONTHLY TF that would go back way more, thus making that high as a very likely all-time high,  since that instruments was first recorded as computer data, of course.

    Anyway the code would simply be:

    Buy 1 contract at highest[n](high) Stop

    “n” is the lookback number of bars. Bear in mind that ProOrder won’t allow 1M, neither 100k, as “n”, though I don’t know exactly. I know that max. preloaded bars can be 10,000.

    You could suggest supporting a new function, beyond HIGHEST and LOWEST:

    ALLTIME(high/low)

    to get the highest/lowest value since the very beginning, no matter what TF.

    Nicolas thanked this post
    #101263 quote
    Nicolas
    Keymaster
    Master

    You could also calculate in real time the new “all time high”, if you don’t want to use a predetermined period.

    hh = max(high,hh)
    
    if not onmarket and close crosses over hh[1] then 
     buy at market 
    endif

    Of course the all time high will depend of the history loaded. In the above example, you will also have to exit the order once in a while (depending of your conditions, e.g. takeprofit, stoploss, trailing stop, ..) to be able to re-enter in the market when a new breakout occurs.

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

buy at a new all time high


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
higherlows @higherlows Participant
Summary

This topic contains 2 replies,
has 3 voices, and was last updated by Nicolas
6 years, 8 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 06/22/2019
Status: Active
Attachments: No files
Logo Logo
Loading...