Tutorials
Getting started
Chart interface
Web components
Chart internals
Data integration
Customization
Frameworks and bundlers
Mobile development
Trading
Time Span Events
Term structures
ScriptIQ
Troubleshooting
Glossary
Reference
JSFiddles

Recipe 1: Draw A Horizonal Line at 100

Cookbook Home

IMPORTANT ProTip 1: Always, ALWAYS check that your punctuation marks are exactly like the examples below. This means make sure your parentheses, quotation marks, colons, etc. are typed exactly like the examples below.

What do we want to see?

An indicator line drawn across the chart at the y-axis value of 100:

img-ScriptIQ-line-100-Chart

How do I use ScriptIQ to create that line? (4 steps)

  1. Go to demo.chartiq.com (or your company's demo charting site).

    Click Studies

    Click New Script

    img-ScriptIQ-Menu-Item

    A panel beneath the chart should have opened with two buttons above that say "Apply" and "Clear":

    img-ScriptIQ-Panel

  2. Type into the panel the following EXACTLY:

    Line = 100
    
    plot(Line)
    
  3. Click Apply, and you should see a little message below that says "... indicator successfully added", and your chart should look like the following image:

    img-ScriptIQ-100-Line

  4. Click on the "100" line and hold for about 2 seconds and then drag it over the candle chart and release. You should now see your horizontal line at 100 overlaying your chart as seen below:

    img-ScriptIQ-line-100-Chart

Congratulations, you have just drawn your first line indicator!


Recipe 1 Secrets

Secret 1

Use study(" ") to give your indicator a name. For instance, type study("Horizontal at 100") above your previous entry — see example below:

study("Horizontal at 100")

Line = 100

plot(Line)

Now hit Apply and notice that when you click the Studies drop-down menu, your study has the name "Horizontal at 100".

Secret 2

"Line" is a type of variable name that can be changed. Developers assign values, like the number 5 or the name Chan to variables.

What this looks like with the word "Line" is:

Line = 5

or

Line = Chan

How we read this in normal English is:

The word "Line" actually means the number 5, or the word "Line" actually means the name Chan.

You can give any variable any value — also known as assignment!

Go ahead and create new variable names and make them represent different numbers/values, number calculations, or variable calculations like below. Then hit Apply!

Line = 100
LowerLine = 90
LowerLineCalculation = 100 - 20
AnotherLine = 100 - LowerLine
LowestLineCalculation = LowerLine - LowerLineCalculation

Secret 3

plot(___) does the work of drawing your indicator line on the chart. It uses the calculation assigned to the variable you type between the parentheses such as plot(LowerLine).

Go ahead and plot any of the lines above, or plot several at a time!

study("So Many Lines")
Line = 100
LowerLine = 90
LowerLineCalculation = 100 - 20
AnotherLine = 100 - LowerLine
LowestLineCalculation = LowerLine - LowerLineCalculation
plot(Line)
plot(LowerLine)
plot(LowerLineCalculation)
plot(AnotherLine)
plot(LowestLineCalculation)

Secret 4

plot(Line, color:"blue") will make the line color blue!

How did we do that!?

Inside of plot(___) we know that you can type your variable like Line, but you can place a comma after the variable and type color:" ", and then type any color you want inside the quotations marks!

Go ahead and make different colored lines like below:

study("A top blue band and a red bottom band")

Line = 100
Line2 = 90

plot(Line, color:"blue")
plot(Line2, color:"red")

ProTips!

ProTip 2: Grab the y-axis on the main chart and pull it down to compress all the lines together. They can get really spread out!

ProTip 3: Again, remember to click and hold on your new indicator for about 2 seconds and then drag it onto the main chart! :)


Recap:

  • 4 steps learned to make a line indicator
  • 4 secrets learned to name our indicators, create more lines, create more variables, and to add color!
  • 3 ProTips (if you include the IMPORTANT ProTip one from the top of the page)

Cookbook Home