Highest bar in multiple ranges
Forums › ProRealTime English forum › ProOrder support › Highest bar in multiple ranges
- This topic has 3 replies, 3 voices, and was last updated 4 years ago by Mike Boorman.
-
-
03/02/2020 at 3:09 PM #120971
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?
Bot code123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530DEFPARAM CumulateOrders = Falsesl= 40slmove = 5longentry1= 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=125000Mon1end=135000Mon2start=152000Mon2end=162000Mon3start=174800Mon3end=184800Mon4start=190000Mon4end=200000Mon5start=0Mon5end=0Mon6start=0Mon6end=0Mon7start=0Mon7end=0Mon8start=0Mon8end=0tue1start=0tue1end=0tue2start=0tue2end=0tue3start=0tue3end=0tue4start=0tue4end=0tue5start=0tue5end=0tue6start=0tue6end=0tue7start=0tue7end=0tue8start=0tue8end=0wed1start=0wed1end=0wed2start=0wed2end=0wed3start=0wed3end=0wed4start=0wed4end=0wed5start=0wed5end=0wed6start=0wed6end=0wed7start=0wed7end=0wed8start=0wed8end=0thur1start=0thur1end=0thur2start=0thur2end=0thur3start=0thur3end=0thur4start=0thur4end=0thur5start=0thur5end=0thur6start=0thur6end=0thur7start=0thur7end=0thur8start=0thur8end=0fri1start=0fri1end=0fri2start=0fri2end=0fri3start=0fri3end=0fri4start=0fri4end=0fri5start=0fri5end=0fri6start=0fri6end=0fri7start=0fri7end=0fri8start=0fri8end=0if intradaybarindex=0 thenentryflag=0endifif time =mon1start and opendayofweek=1 thenentryflag=1endifif time =mon1end and opendayofweek=1 thenentryflag=0endifif time =mon2start and opendayofweek=1 thenentryflag=1endifif time =mon2end and opendayofweek=1 thenentryflag=0endifif time =mon3start and opendayofweek=1 thenentryflag=1endifif time =mon3end and opendayofweek=1 thenentryflag=0endifif time =mon4start and opendayofweek=1 thenentryflag=1endifif time =mon4end and opendayofweek=1 thenentryflag=0endifif time =mon5start and opendayofweek=1 thenentryflag=1endifif time =mon5end and opendayofweek=1 thenentryflag=0endifif time =mon6start and opendayofweek=1 thenentryflag=1endifif time =mon6end and opendayofweek=1 thenentryflag=0endifif time =mon7start and opendayofweek=1 thenentryflag=1endifif time =mon7end and opendayofweek=1 thenentryflag=0endifif time =mon8start and opendayofweek=1 thenentryflag=1endifif time =mon8end and opendayofweek=1 thenentryflag=0endifif time =tue1start and opendayofweek=2 thenentryflag=1endifif time =tue1end and opendayofweek=2 thenentryflag=0endifif time =tue2start and opendayofweek=2 thenentryflag=1endifif time =tue2end and opendayofweek=2 thenentryflag=0endifif time =tue3start and opendayofweek=2 thenentryflag=1endifif time =tue3end and opendayofweek=2 thenentryflag=0endifif time =tue4start and opendayofweek=2 thenentryflag=1endifif time =tue4end and opendayofweek=2 thenentryflag=0endifif time =tue5start and opendayofweek=2 thenentryflag=1endifif time =tue5end and opendayofweek=2 thenentryflag=0endifif time =tue6start and opendayofweek=2 thenentryflag=1endifif time =tue6end and opendayofweek=2 thenentryflag=0endifif time =tue7start and opendayofweek=2 thenentryflag=1endifif time =tue7end and opendayofweek=2 thenentryflag=0endifif time =tue8start and opendayofweek=2 thenentryflag=1endifif time =tue8end and opendayofweek=2 thenentryflag=0endifif time =wed1start and opendayofweek=3 thenentryflag=1endifif time =wed1end and opendayofweek=3 thenentryflag=0endifif time =wed2start and opendayofweek=3 thenentryflag=1endifif time =wed2end and opendayofweek=3 thenentryflag=0endifif time =wed3start and opendayofweek=3 thenentryflag=1endifif time =wed3end and opendayofweek=3 thenentryflag=0endifif time =wed4start and opendayofweek=3 thenentryflag=1endifif time =wed4end and opendayofweek=3 thenentryflag=0endifif time =wed5start and opendayofweek=3 thenentryflag=1endifif time =wed5end and opendayofweek=3 thenentryflag=0endifif time =wed6start and opendayofweek=3 thenentryflag=1endifif time =wed6end and opendayofweek=3 thenentryflag=0endifif time =wed7start and opendayofweek=3 thenentryflag=1endifif time =wed7end and opendayofweek=3 thenentryflag=0endifif time =wed8start and opendayofweek=3 thenentryflag=1endifif time =wed8end and opendayofweek=3 thenentryflag=0endifif time =thur1start and opendayofweek=4 thenentryflag=1endifif time =thur1end and opendayofweek=4 thenentryflag=0endifif time =thur2start and opendayofweek=4 thenentryflag=1endifif time =thur2end and opendayofweek=4 thenentryflag=0endifif time =thur3start and opendayofweek=4 thenentryflag=1endifif time =thur3end and opendayofweek=4 thenentryflag=0endifif time =thur4start and opendayofweek=4 thenentryflag=1endifif time =thur4end and opendayofweek=4 thenentryflag=0endifif time =thur5start and opendayofweek=4 thenentryflag=1endifif time =thur5end and opendayofweek=4 thenentryflag=0endifif time =thur6start and opendayofweek=4 thenentryflag=1endifif time =thur6end and opendayofweek=4 thenentryflag=0endifif time =thur7start and opendayofweek=4 thenentryflag=1endifif time =thur7end and opendayofweek=4 thenentryflag=0endifif time =thur8start and opendayofweek=4 thenentryflag=1endifif time =thur8end and opendayofweek=4 thenentryflag=0endifif time =fri1start and opendayofweek=5 thenentryflag=1endifif time =fri1end and opendayofweek=5 thenentryflag=0endifif time =fri2start and opendayofweek=5 thenentryflag=1endifif time =fri2end and opendayofweek=5 thenentryflag=0endifif time =fri3start and opendayofweek=5 thenentryflag=1endifif time =fri3end and opendayofweek=5 thenentryflag=0endifif time =fri4start and opendayofweek=5 thenentryflag=1endifif time =fri4end and opendayofweek=5 thenentryflag=0endifif time =fri5start and opendayofweek=5 thenentryflag=1endifif time =fri5end and opendayofweek=5 thenentryflag=0endifif time =fri6start and opendayofweek=5 thenentryflag=1endifif time =fri6end and opendayofweek=5 thenentryflag=0endifif time =fri7start and opendayofweek=5 thenentryflag=1endifif time =fri7end and opendayofweek=5 thenentryflag=0endifif time =fri8start and opendayofweek=5 thenentryflag=1endifif time =fri8end and opendayofweek=5 thenentryflag=0endifif not onmarket and entryflag=1 and lowest[4] = lowest[30] and longentry1 thenBUY 1 PERPOINT AT MARKETentryflag=0slprice = close - slendifif not onmarket and entryflag=1 and highest[4] = highest[30] and shortentry1 thenSellshort 1 perpoint at marketentryflag=0slprice = close + slendifif longonmarket and high - sl > slprice + slmove thenslprice = high - slendifif longonmarket and close < longexit1 thensell at marketendifif shortonmarket and low + sl < slprice - slmove thenslprice = low + slendifif shortonmarket and close > shortexit1 thenexitshort at marketendifset stop ploss 60graph highest[4] = highest[30]03/02/2020 at 3:58 PM #120978You don’t specify to check the highs so it will be checking the close. It should be like this.
1if not onmarket and entryflag=1 and highest[4](high) = highest[30](high) and shortentry1 then1 user thanked author for this post.
03/02/2020 at 4:01 PM #120979Because you did not specify the data on which HIGHEST and LOWEST have to cumpute their values, thus CLOSE is assumed.
Use this, instead:
1lowest[4](loW) = lowest[30](low)and (high) with HIGHEST.
03/02/2020 at 4:50 PM #120991Ah yes, of course. I can’t believe I forgot that!!!
Thank you.
-
AuthorPosts
Find exclusive trading pro-tools on