coding 4-day low/high
Forums › ProRealTime English forum › ProOrder support › coding 4-day low/high
- This topic has 8 replies, 5 voices, and was last updated 5 years ago by therookie.
-
-
04/13/2019 at 4:56 PM #9636104/13/2019 at 5:41 PM #96362123456789101112131415DEFPARAM PRELOADBARS = 100DEFPARAM Cumulateorders = Falses1 = (close = highest[4](close))exit1 = (close = lowest[4](close))size = 1If s1 THENsellshort size contracts at marketENDIFIf exit1 and shortonmarket thenexitshort at marketENDIF
Hope this should help
1 user thanked author for this post.
04/13/2019 at 5:54 PM #96364Go short if today’s close is a new 4-day high
Bit difficult to be 100% certain what you mean by this. Do you mean that today’s close has to be higher than the last three closes (which is what Harrys has coded) or do you mean that today’s close has to be higher than the highest high of the last three candles?
For the latter your conditions would need to be:
12s1 = close > highest[3](high[1])exit1 = close < lowest[3](low[1])04/14/2019 at 12:20 PM #9638604/14/2019 at 12:39 PM #9639004/14/2019 at 12:44 PM #96391Harry’s code (lines 4-5) does its job correctly, current close MUST be >= than the previous 3 candles.
Vonasi’s code does the same job with a slightly different approach.
04/14/2019 at 12:50 PM #96393I can’t edit from my mobile.
Vonasi’s code does something different.
Nicolas’code has just a slightly different approach.
04/14/2019 at 2:29 PM #96405Harrys code does the job by obtaining the value of the highest close in the last four candles and comparing it to the current close. It assumes that if they are the same value then this close must be the highest. It does not however allow for the fact that one or more of the closes could have identical values in which case your entry criteria is not strictly being met. Nicolas’ version and my version do allow for this possibility. Nicolas’ does it with the last three closes which is what you want whereas my version just does the same thing with the last three highs.
1 user thanked author for this post.
04/14/2019 at 3:31 PM #96407 -
AuthorPosts
Find exclusive trading pro-tools on