50% All Time High / All Time Range

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

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

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:

P1=LOWESTLOW(RANGE=All Time);

P2=HIGHESTHIGH(RANGE=All Time);

(P1+P2) / 2

 

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

HIGHESTHIGH(RANGE=All Time)*0.50

 

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.

 

 

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

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

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/

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:

V1=(HIGHESTHIGH(RANGE=All Time, INCBAR=True)/2);
WITHINRANGE(CLOSE(),V1, PERCENT=2.00)

Capture

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

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.

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:

//Get Lowest Low;
P1=LOWESTLOW(RANGE=All Time);
//Get Highest High;
P2=HIGHESTHIGH(RANGE=All Time);
//Calculate range and multiply by %;
R1=(P2-P1)*0.382;
//Add to Lowest Low
P1+R1

Capture

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

//Get Lowest Low;
P1=LOWESTLOW(RANGE=All Time);
//Get Highest High;
P2=HIGHESTHIGH(RANGE=All Time);
//Calculate range and multiply by %;
R1=(P2-P1)*0.382;
R2=(P2-P1)*0.618;
//Add to Lowest Low
Plot1=P1+R1;
Plot2=P1+R2;