Multiple functions in one script for ATR

Good afternoon,

I’m currently very new to scripting and am having a lot of trouble with the following code.

var1 = HIGHESTHIGH(RANGE=All Time);
var2 = LOWESTLOW(RANGE=All Time);
(var1+var2)*0.50
(var1+var2)*0.25

I want to create a button that essentially looks like a fibonacci retracement from the ATH to ATL with a 25%,50% and 75% retracement.
This way the ATR will adjust as price moves higher and i wont have to keep moving the retracement tool.

The code above is not correct, i can get it to draw a single line (the 50%) but when i add the code for the second it says it’s invalid.
Is there a link i need to add or another way or writing this so it works?

Also the line is a basic line and i’d like to add the percentage value to it if possible but i couldn’t find any information on how to do that.

Hi Corey,

For examples on how to setup multi plot scripts in Optuma please refer to the following article:

https://help.optuma.com/kb/faq.php?id=722

Lecture 10 of the free Intermediary scripting course also covers multi plot scripts in detail:

https://learn.optuma.com/course/intermediate-scripting/?course_type=content&course_page=1&lecture=10

You can use your Optuma username and password to access the course.

Hi Corey,

Simply put, scripts can provide two types of outputs:

  • Single variable value - only one per script and typically used with SHOWBAR and CHART ELEMENT
  • Plots - you can have many plots with related or unrelated variables and typically used with SHOWPLOT (on the chart) and SHOWVIEW (in a separate view).
What you are trying to do would use the Plot function something like this:
var1 = HIGHESTHIGH(RANGE=All Time);
var2 = LOWESTLOW(RANGE=All Time);
//
Plot1 := (var1+var2)*0.50;
Plot1.Color := clBlue;
Plot1.PlotStyle := Line;      // possible values are (Line, Dot, Histogram, Step, Shaded)
Plot1.LineStyle := Solid;
Plot1.FillColor := clBlue;
//
Plot2 := (var1+var2)*0.25;
Plot2.Color := clRed;
Plot2.PlotStyle := Line;    // possible values are (Line, Dot, Histogram, Step, Shaded)
Plor2.Linestyle := dash;
Plot2.FillColor := clBlue;
You would the display your plots on the chart using SHOWPLOT.

You can have many Plots - I’ve had up to Plot6. You can have more although the chart or SHOWVIEW gets pretty cluttered.

Cheers

Trevor

Thank you both for the incredible information and assistance. I had tried the plots but could not for the life of me get them to work!.
It’s all working well now and i feel a lot more confident writing all the scripts i want to create.

Cheers

Actually just a follow up to the previous post. Is there a way to add labels to the chart for the final plot calculation?
If there is a training package i could read that would be much appreciated.

Cheers

Hi Corey,

The only way I know of labelling the plots is to use the TEXT tool and apply the label to the chart near the plot. Unfortunately, if the PLOT moves the TEXT tool will not move with it.

By the way, I made a couple of typos in the script I posted above (me confusing scripting with Optuma Pascal):

  • "color" should be "colour", and
  • "plor2" should be "plot2"
Also I've used ":="(which works) in lieu of "=". That's also a carryover from my working in Optuma Pascal.

Cheers

Trevor

 

Hey guys - as well as the text box you can enable the Show in Price Scale property of the Show Plot tool:

 

Capture

Note you can save the formula as an indicator and add it to your toolbox, and Save Settings as Default under Actions so that the value will always show.

Thanks again Trevor, yeah i figured out the errors and got it working, much appreciated.

Thanks for the information Darren, i found that cluttered up the side bar a lot so have just decided to add a caption instead to click and get the info.

Cheers guys