50% All Time High / All Time Range

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

This topic contains 8 replies, has 5 voices, and was last updated by Darren Darren 3 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #28543
    Avatar
    Jonathan
    • Topics: 31
    • Replies: 46
    • Posts: 77

    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

    Attachments:
    #29023
    Avatar
    Stephen
    • 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
    Matthew
    Matthew
    • Topics: 4
    • Replies: 186
    • Posts: 190

    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
    Avatar
    Jonathan
    • Topics: 31
    • Replies: 46
    • Posts: 77

    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

    #37731
    Avatar
    Stephen
    • 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
    Darren
    Darren
    • Topics: 41
    • Replies: 280
    • Posts: 321

    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/

    #53733
    Darren
    Darren
    • Topics: 41
    • Replies: 280
    • Posts: 321

    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

    #53745
    Avatar
    Evan
    • Topics: 3
    • Replies: 4
    • Posts: 7

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

    #53755
    Darren
    Darren
    • Topics: 41
    • Replies: 280
    • Posts: 321

    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.

Viewing 9 posts - 1 through 9 (of 9 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