How can I plot a hi-low-close plot in Grapher via automation?

This article contains a sample script for creating a high-low-close plot and changing its properties.

To run this script:

  1. Copy the script below, or click here to download the BAS file: hi-low-close.BAS.
  2. In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Grapher 12\Scripter.
  3. Double click on Scripter.exe to launch Scripter.
  4. Press Ctrl+A to select all of the existing lines then press Delete.
  5. If you copied this script, press Ctrl+V to paste it into Scripter. If you downloaded it, click File | Open, select the BAS file from your downloads directory, and click Open.
  6. Click Script | Run to run the script.


Sub Main
'Declare the variable that references the application
Dim GrapherApp As Object

'Creates an instance of the Grapher Application object
'and assigns it to the variable named "GrapherApp"
Set GrapherApp = CreateObject("Grapher.Application")

'Make Grapher visible
GrapherApp.Visible = True

'Declare Docs Plot, Shapes, Graph1, and HighLow as Object
Dim Docs, Plot, Shapes, Graph1, HighLow As Object

'Assigns the Documents collection to the variable named "Docs"
Set Docs = GrapherApp.Documents

'Creates a new plot window and assign it to the variable named "Plot"
Set Plot = Docs.Add(grfPlotDoc)

'Assigns the AutoShapes collection to the variable named "Shapes"
Set Shapes = Plot.Shapes

'Adds a high-low-close graph and assigns it to the variable named "Graph1"
Set Graph1 = Shapes.AddHighLowGraph(GrapherApp.Path + "\samples\hilo.dat")

'Assigns the high-low-close graph to the variable named "HighLow"
Set HighLow = Graph1.Plots(1)

'Return the display type
Debug.Print "Display type = "; HighLow.DisplayType

'Set the display type as candlesticks
HighLow.DisplayType = grfDisplayCandlestick

'Return the fill object for the "Up fill style" and sets the color to green
HighLow.UpFill.PatternName("Diagonal Cross")

End Sub


Updated October 25, 2016

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Please sign in to leave a comment.