50% All Time High / All Time Range

Optuma Forums Optuma Scripting 50% All Time High / All Time Range

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #28543
    AvatarJonathan
    • Topics: 35
    • Replies: 55
    • Posts: 90

    Depending on your trading style these scripts may be beneficial to you.

     

    This script will update the 50% All Time Range & All Time High instead of you having to go through the process yourself.

     

    – Show Plot
    – Chart Element

    (50% All Time Range)
    P1 = LOWESTLOW(RANGE=All Time) ;
    P2 = HIGHESTHIGH(RANGE=All Time) ;
    (P1 + P2) / 2

    (50% All Time High)
    HIGHESTHIGH(RANGE=All Time)*0.50

    • This topic was modified 3 years, 7 months ago by AvatarJonathan.
    Attachments:
    #29023
    AvatarStephen
    • Topics: 0
    • Replies: 2
    • Posts: 2

    Hi,

    I am new to this scripting.

    I tried to create the 50% All Time High / All Time Range as shown above but it won’t work. Is it supposed to be written exactly as shown above.  As soon as I type in P2 there is a message in red at the bottom saying please enter a valid script to add to this criteria. BELOW IS HOW I HAVE WRITTEN THE SCRIPT.

    -Show Plot

    -Chart Element

    P1=LOWESTLOW(RANGE=All Time);

    P2=HIGHESTHIGH(RANGE=All Time

    (P1+P2) / 2

    HIGHESTHIGH(RANGE=All Time)*0.50

    #29151
    MatthewMatthew
    • Topics: 5
    • Replies: 293
    • Posts: 298

    Hi Stephen,

    In the original example, there are two different scripts.

    In the first script (to use with a Show Plot indicator) It looks like you are missing 2 characters at the end of the second line:

     

    The second script is to be used with the Chart Element indicator:

     

    If you are new to scripting i would highly recommend the free courses available here.  They are a  great way of learning the scripting module in Optuma.

     

     

    #29171
    AvatarJonathan
    • Topics: 35
    • Replies: 55
    • Posts: 90

    Hello,

    Sorry – I will update this so everyone can understand.

    For this process you will be using 2 tools, both tools are to be setup with the exact same script.

    So you will have 2x setup of Show Plot and 2x setup of Chart Element to achieve both of these scripts in action. It might be good to color code these different colors.

    – Show Plot
    – Chart Element

    ——————————————–

    To script the ‘50% All Time Range’ use;
    P1 = LOWESTLOW(RANGE=All Time) ;
    P2 = HIGHESTHIGH(RANGE=All Time) ;
    (P1 + P2) / 2

    ——————————————–

    To script the ‘50% All Time High’ use;
    HIGHESTHIGH(RANGE=All Time)*0.50

    • This reply was modified 3 years, 6 months ago by AvatarJonathan.
    #37731
    AvatarStephen
    • Topics: 0
    • Replies: 2
    • Posts: 2

    Thanks Jonathon,

    I have written the two scripts separately and they show up separately as 50% All Time High and 50% All time range under My Scripts in the script editor. Then when I open a chart, I open the tools and go to chart element it brings up the code. I right click to edit the field and  to bring up the script I can only get 50 % of all time high.

    I can bring up the plot for both scripts but cannot edit the name of the script . Also if, when I lock the time/price in the  element screen does that actually lock the time/price in the scripts?

    Ta

    #37759
    DarrenDarren
    • Topics: 55
    • Replies: 463
    • Posts: 518

    Hi Stephen,

    One option would be to save the script as an indicator, in the same view (ie it will be applied to the same price scale as the chart).

    Capture

    This will then be added to your list of tools, and available from the right-click menu:

    Capture

    For more on custom tools see Lecture 13 here: https://learn.optuma.com/course/introduction-to-scripting/

    • This reply was modified 3 years, 4 months ago by DarrenDarren.
    #53733
    DarrenDarren
    • Topics: 55
    • Replies: 463
    • Posts: 518

    Use the following in a scan, Show Bar or custom bar colour for stocks within 2% of the 50% level of their all-time high:

    Capture

    1 user thanked author for this post.
    #53745
    AvatarEvan
    • Topics: 3
    • Replies: 4
    • Posts: 7

    Wouldnt 50% of the all time range be (H-L) /2, so (P2-P1)/2.?

    #53755
    DarrenDarren
    • Topics: 55
    • Replies: 463
    • Posts: 518

    Hi Evan,

    That would be 50% of the range, so if the high was 100 and the low was 20 half the range would be 80/2 = 40. But 40 is not halfway between the high and low – you need to add it to the low to get the midpoint of the H-L range, ie 20+40 = 60.

    Instead it would be much easier to use (H + L)/2 = 60. See Jonathan’s earlier post above.

    #56727
    DarrenDarren
    • Topics: 55
    • Replies: 463
    • Posts: 518

    To calculate X% of a range you need to subtract the low from the high and multiply by the %, and then add the result to the low. So for 38.2% of the all-time range:

    Capture

    To add multiple % ranges to one Show Plot, eg 38.2% and 61.8%:

    2 users thanked author for this post.
Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.

Pin It on Pinterest

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close