coding 4-day low/high

Forums ProRealTime English forum ProOrder support coding 4-day low/high

Viewing 9 posts - 1 through 9 (of 9 total)
  • #96361

    I am wondering how to put down two things in code:

    1: Go short if today’s close is a new 4-day high

    2. Close the short position if today’s close is a new 4-day low

    Help would be much appreciated!

    #96362

    Hope this should help

    1 user thanked author for this post.
    #96364

    Go 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:

     

    #96386

    Ok good question, maybe I didn’t specify it well enough.

    I want today’s close to be higher than the last 3 days’ closes so I guess Harrys code is what I want.

    But why is there equal signs and not ‘<‘ and ‘>’ signs?

    #96390

    Try this version: 😉

    s1 = close is higher than the higher close of the last 3 days

    exit1 = close is lower than the lower close of the last 3 days

    #96391

    Harry’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.

    #96393

    I can’t edit from my mobile.

    Vonasi’s code does something different.

    Nicolas’code has just a slightly different approach.

    #96405

    Harrys 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.
    #96407

    Thank you guys for the help and you Vonasi for the explanation.

Viewing 9 posts - 1 through 9 (of 9 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login