365 day high has occurred in the last 50 days

Optuma Forums Optuma Scripting 365 day high has occurred in the last 50 days

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #65877
    Karen
    • Topics: 21
    • Replies: 32
    • Posts: 53

    I am looking to do a show bar when true. I have modified the code below but it is not working – I want to know whether anytime in the last 50 days whether there was a 365 day high – True or false.

    Further to the below the calculation should be satisfied across month, week and day charts when assessing whether the 365 day high was in the last 50 days (ie the requirement is 50 days not 50 bars). I hope that makes sense. Coding is below.

    //365 day high has occurred in the last 50 days

    V1= HIGHESTHIGH(BARS=365, BACKTYPE=Days);  High()>V1
    TIMESINCESIGNAL(V1, UNIT=Days, FIRSTSIGNALONLY=False) <= 50

    Can someone please assist with what I am doing wrong. Thanks.

    • This topic was modified 2 weeks ago by Karen.
    #65880
    Matthew
    • Topics: 5
    • Replies: 421
    • Posts: 426

    Hi,

    The High() > V1 needs to be on its own line and assigned a different variable, the TimeSinceSignal() then needs to be wrapped around that.

    Additionally, for it to run on multiple time frames but return the same result you need to set a time frame override on a few of the lines.

    The final script would look like this:

    Here's an example of the output...

    Ex7

    • This reply was modified 1 week ago by Matthew.
    1 user thanked author for this post.
    #65885
    Karen
    • Topics: 21
    • Replies: 32
    • Posts: 53

    Hi Matthew,

    I have attached a chart using the coding.  The green star at the top is the criteria but it is showing more than 1 star for the weekly and monthly charts. How do I get it to show just 1 star above the relevant bar (in each of the daily, weekly and monthly charts)?

    Thanks,
    Karen

    • This reply was modified 1 week ago by Karen.
    #65915
    Darren
    • Topics: 66
    • Replies: 661
    • Posts: 727

    Hi Karen,

    It’s because the V1 and V2 variables are loading daily data in a weekly chart,  so you can have 5 true results within a weekly bar (and 20+ in a monthly), hence the duplication.

    Change V1 and V2 to the following, and it will look back a year no matter the timeframe of the chart, instead of data for 365 calendar days.

    V1 = HIGHESTHIGH(BACKTYPE=Weeks, BARS=52);
    V2 = HIGH() CrossesAbove V1;

    #65981
    Karen
    • Topics: 21
    • Replies: 32
    • Posts: 53

    Hi Darren,

    The formula results are still not working the way it is intended to work.  Please see attached chart – if you scroll to the very start of the chart there are green stars when there are no red stars.  I basically am trying to achieve a green star where a red star has appeared provided it is within 80 days of the red star occurring (and this should apply for daily, weekly and monthly charts accordingly). I have tried all types of combinations of codes and if functions but cannot get it to work.

    Can you please have a look at it and let me know what is wrong with the formula please.

    Thanks and kind regards,
    Karen

    • This reply was modified 4 days ago by Karen.
    #66001
    Matthew
    • Topics: 5
    • Replies: 421
    • Posts: 426

    Hi,

    It’s because a value of zero is being returned at the very start, which passes the criteria of V3 (less than or equal to 80). You need to adjust that variable so that 0 is also excluded.

    With this adjustment, the large group of results at the start of the charts is removed.

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

Pin It on Pinterest