Highest bar in multiple ranges

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #120971 quote
    Mike Boorman
    Participant
    Average

    Hello,

    I’m a bit confused by an entry that my program has just made that my rules ought to have prevented. The rule is “only enter if highest in the last four bars equals the highest in the last 30 bars”.

    The screengrab below shows the highest flag occurring at 13:14, even though quite clearly there has been a higher bar at 12:58. I can’t understand why the high flag was allowed to return. Does anyone know why this is?

    DEFPARAM CumulateOrders = False
    
    sl= 40
    slmove = 5
    
    longentry1= close crosses over SuperTrend[1.5,34]
    shortentry1= close crosses under SuperTrend[1.5,34]
    longexit1= max (slprice, SuperTrend[1.5,34])
    shortexit1= min (slprice, SuperTrend[1.5,34])
    
    Mon1start=125000
    Mon1end=135000
    Mon2start=152000
    Mon2end=162000
    Mon3start=174800
    Mon3end=184800
    Mon4start=190000
    Mon4end=200000
    Mon5start=0
    Mon5end=0
    Mon6start=0
    Mon6end=0
    Mon7start=0
    Mon7end=0
    Mon8start=0
    Mon8end=0
    
    tue1start=0
    tue1end=0
    tue2start=0
    tue2end=0
    tue3start=0
    tue3end=0
    tue4start=0
    tue4end=0
    tue5start=0
    tue5end=0
    tue6start=0
    tue6end=0
    tue7start=0
    tue7end=0
    tue8start=0
    tue8end=0
    
    wed1start=0
    wed1end=0
    wed2start=0
    wed2end=0
    wed3start=0
    wed3end=0
    wed4start=0
    wed4end=0
    wed5start=0
    wed5end=0
    wed6start=0
    wed6end=0
    wed7start=0
    wed7end=0
    wed8start=0
    wed8end=0
    
    thur1start=0
    thur1end=0
    thur2start=0
    thur2end=0
    thur3start=0
    thur3end=0
    thur4start=0
    thur4end=0
    thur5start=0
    thur5end=0
    thur6start=0
    thur6end=0
    thur7start=0
    thur7end=0
    thur8start=0
    thur8end=0
    
    fri1start=0
    fri1end=0
    fri2start=0
    fri2end=0
    fri3start=0
    fri3end=0
    fri4start=0
    fri4end=0
    fri5start=0
    fri5end=0
    fri6start=0
    fri6end=0
    fri7start=0
    fri7end=0
    fri8start=0
    fri8end=0
    
    if intradaybarindex=0 then
    entryflag=0
    endif
    
    
    if time =mon1start and opendayofweek=1 then
    entryflag=1
    endif
    
    if time =mon1end and opendayofweek=1 then
    entryflag=0
    
    
    endif
    
    if time =mon2start and opendayofweek=1 then
    entryflag=1
    endif
    
    if time =mon2end and opendayofweek=1 then
    entryflag=0
    
    
    endif
    
    if time =mon3start and opendayofweek=1 then
    entryflag=1
    endif
    
    if time =mon3end and opendayofweek=1 then
    entryflag=0
    
    
    endif
    
    if time =mon4start and opendayofweek=1 then
    entryflag=1
    endif
    
    if time =mon4end and opendayofweek=1 then
    entryflag=0
    
    
    endif
    
    if time =mon5start and opendayofweek=1 then
    entryflag=1
    endif
    
    if time =mon5end and opendayofweek=1 then
    entryflag=0
    
    
    endif
    
    if time =mon6start and opendayofweek=1 then
    entryflag=1
    endif
    
    if time =mon6end and opendayofweek=1 then
    entryflag=0
    
    
    endif
    
    if time =mon7start and opendayofweek=1 then
    entryflag=1
    endif
    
    if time =mon7end and opendayofweek=1 then
    entryflag=0
    
    
    endif
    
    if time =mon8start and opendayofweek=1 then
    entryflag=1
    endif
    
    if time =mon8end and opendayofweek=1 then
    entryflag=0
    
    
    endif
    if time =tue1start and opendayofweek=2 then
    entryflag=1
    endif
    
    if time =tue1end and opendayofweek=2 then
    entryflag=0
    
    
    endif
    
    if time =tue2start and opendayofweek=2 then
    entryflag=1
    endif
    
    if time =tue2end and opendayofweek=2 then
    entryflag=0
    
    
    endif
    
    if time =tue3start and opendayofweek=2 then
    entryflag=1
    endif
    
    if time =tue3end and opendayofweek=2 then
    entryflag=0
    
    
    endif
    
    if time =tue4start and opendayofweek=2 then
    entryflag=1
    endif
    
    if time =tue4end and opendayofweek=2 then
    entryflag=0
    
    
    endif
    
    if time =tue5start and opendayofweek=2 then
    entryflag=1
    endif
    
    if time =tue5end and opendayofweek=2 then
    entryflag=0
    
    
    endif
    
    if time =tue6start and opendayofweek=2 then
    entryflag=1
    endif
    
    if time =tue6end and opendayofweek=2 then
    entryflag=0
    
    
    endif
    
    if time =tue7start and opendayofweek=2 then
    entryflag=1
    endif
    
    if time =tue7end and opendayofweek=2 then
    entryflag=0
    
    
    endif
    
    if time =tue8start and opendayofweek=2 then
    entryflag=1
    endif
    
    if time =tue8end and opendayofweek=2 then
    entryflag=0
    
    
    endif
    
    
    if time =wed1start and opendayofweek=3 then
    entryflag=1
    endif
    
    if time =wed1end and opendayofweek=3 then
    entryflag=0
    
    
    endif
    
    if time =wed2start and opendayofweek=3 then
    entryflag=1
    endif
    
    if time =wed2end and opendayofweek=3 then
    entryflag=0
    
    
    endif
    
    if time =wed3start and opendayofweek=3 then
    entryflag=1
    endif
    
    if time =wed3end and opendayofweek=3 then
    entryflag=0
    
    
    endif
    
    if time =wed4start and opendayofweek=3 then
    entryflag=1
    endif
    
    if time =wed4end and opendayofweek=3 then
    entryflag=0
    
    
    endif
    
    if time =wed5start and opendayofweek=3 then
    entryflag=1
    endif
    
    if time =wed5end and opendayofweek=3 then
    entryflag=0
    
    
    endif
    
    if time =wed6start and opendayofweek=3 then
    entryflag=1
    endif
    
    if time =wed6end and opendayofweek=3 then
    entryflag=0
    
    
    endif
    
    if time =wed7start and opendayofweek=3 then
    entryflag=1
    endif
    
    if time =wed7end and opendayofweek=3 then
    entryflag=0
    
    
    endif
    
    if time =wed8start and opendayofweek=3 then
    entryflag=1
    endif
    
    if time =wed8end and opendayofweek=3 then
    entryflag=0
    
    
    endif
    
    if time =thur1start and opendayofweek=4 then
    entryflag=1
    endif
    
    if time =thur1end and opendayofweek=4 then
    entryflag=0
    
    
    endif
    
    if time =thur2start and opendayofweek=4 then
    entryflag=1
    endif
    
    if time =thur2end and opendayofweek=4 then
    entryflag=0
    
    
    endif
    
    if time =thur3start and opendayofweek=4 then
    entryflag=1
    endif
    
    if time =thur3end and opendayofweek=4 then
    entryflag=0
    
    
    endif
    
    if time =thur4start and opendayofweek=4 then
    entryflag=1
    endif
    
    if time =thur4end and opendayofweek=4 then
    entryflag=0
    
    
    endif
    
    if time =thur5start and opendayofweek=4 then
    entryflag=1
    endif
    
    if time =thur5end and opendayofweek=4 then
    entryflag=0
    
    
    endif
    
    if time =thur6start and opendayofweek=4 then
    entryflag=1
    endif
    
    if time =thur6end and opendayofweek=4 then
    entryflag=0
    
    
    endif
    
    if time =thur7start and opendayofweek=4 then
    entryflag=1
    endif
    
    if time =thur7end and opendayofweek=4 then
    entryflag=0
    
    
    endif
    
    if time =thur8start and opendayofweek=4 then
    entryflag=1
    endif
    
    if time =thur8end and opendayofweek=4 then
    entryflag=0
    
    
    endif
    
    if time =fri1start and opendayofweek=5 then
    entryflag=1
    endif
    
    if time =fri1end and opendayofweek=5 then
    entryflag=0
    
    
    endif
    
    if time =fri2start and opendayofweek=5 then
    entryflag=1
    endif
    
    if time =fri2end and opendayofweek=5 then
    entryflag=0
    
    
    endif
    
    if time =fri3start and opendayofweek=5 then
    entryflag=1
    endif
    
    if time =fri3end and opendayofweek=5 then
    entryflag=0
    
    
    endif
    
    if time =fri4start and opendayofweek=5 then
    entryflag=1
    endif
    
    if time =fri4end and opendayofweek=5 then
    entryflag=0
    
    
    endif
    
    if time =fri5start and opendayofweek=5 then
    entryflag=1
    endif
    
    if time =fri5end and opendayofweek=5 then
    entryflag=0
    
    
    endif
    
    if time =fri6start and opendayofweek=5 then
    entryflag=1
    endif
    
    if time =fri6end and opendayofweek=5 then
    entryflag=0
    
    
    endif
    
    if time =fri7start and opendayofweek=5 then
    entryflag=1
    endif
    
    if time =fri7end and opendayofweek=5 then
    entryflag=0
    
    
    endif
    
    if time =fri8start and opendayofweek=5 then
    entryflag=1
    endif
    
    if time =fri8end and opendayofweek=5 then
    entryflag=0
    
    
    endif
    
    if not onmarket and entryflag=1 and lowest[4] = lowest[30] and longentry1 then
    BUY 1 PERPOINT AT MARKET
    entryflag=0
    slprice = close - sl
    endif
    if not onmarket and entryflag=1 and highest[4] = highest[30] and shortentry1 then
    Sellshort 1 perpoint at market
    entryflag=0
    slprice = close + sl
    endif
    
    if longonmarket and high - sl > slprice + slmove then
    slprice = high - sl
    endif
    
    if longonmarket and close < longexit1 then
    sell at market
    endif
    
    if shortonmarket and low + sl < slprice - slmove then
    slprice = low + sl
    endif
    
    if shortonmarket and close > shortexit1 then
    exitshort at market
    endif
    
    set stop ploss 60
    
    graph highest[4] = highest[30]
    Screen-Shot-2020-03-02-at-14.58.17.png Screen-Shot-2020-03-02-at-14.58.17.png
    #120978 quote
    Vonasi
    Moderator
    Master

    You don’t specify to check the highs so it will be checking the close. It should be like this.

    if not onmarket and entryflag=1 and highest[4](high) = highest[30](high) and shortentry1 then
    Mike Boorman thanked this post
    #120979 quote
    robertogozzi
    Moderator
    Master

    Because you did not specify the data on which HIGHEST and LOWEST have to cumpute their values, thus CLOSE is assumed.

    Use this, instead:

    lowest[4](loW) = lowest[30](low)

    and (high) with HIGHEST.

    #120991 quote
    Mike Boorman
    Participant
    Average

    Ah yes, of course. I can’t believe I forgot that!!!

    Thank you.

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

Highest bar in multiple ranges


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 3 replies,
has 3 voices, and was last updated by Mike Boorman
5 years, 12 months ago.

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