# candlesticks

How to download and try this example

    Usage: pl -gif candlesticks.htm
    Data source: quote.yahoo.com (Spreadsheet format)

    Japanese candlesticks.  Weekends are omitted.

    #proc page
    #if @DEVICE in gif,png
      scale: 0.7
    #endif

    #proc datesettings
    omitweekends: yes

    // define top plotting area using proc areadef
    #proc areadef
    title: Trailer Tongue Technologies Corp.
    rectangle: 1 3 5 5
    xscaletype: date dd-mmm-yy
    xrange: 5-Apr-99 1-Jun-99
    yrange: 50 60
    yscaletype: log
    #saveas: A

    // read data file using proc getdata
    #proc getdata
    file: stock.csv
    delimit: comma
    fieldnames: date open high low close volume

    // reverse the record order, since the data is provided in reverse chronological
    // order, using proc processdata
    #proc processdata
    action: reverse

    // set up X axis using proc xaxis
    #proc xaxis
    stubs: inc 5
    stubformat: Mmmdd
    stubrange: 5-Apr-99
    grid: color=gray(0.8)
    tics: none
    #saveas: XAX

    // set up Y axis using proc yaxis
    #proc yaxis
    stubs: inc 2
    // grid: color=gray(0.8)
    axisline: none
    tics: none

    // draw red (up) candlestick bars using proc bars
    // thin high/low bar..
    #proc bars
    select: @@close > @@open
    locfield: date
    segmentfields: low high
    thinbarline: width=0.3 color=red

    // thicker open/close bar..
    #proc bars
    select: @@close > @@open
    locfield: date
    segmentfields: open close
    barwidth: 0.04
    outline: no
    color: red

    // draw blue (down) candlestick bars using proc bars
    // thin high/low bar..
    #proc bars
    select: @@close <= @@open
    locfield: date
    segmentfields: low high
    thinbarline: width=0.3 color=blue

    // thicker open/close bar..
    #proc bars
    select: @@close <= @@open
    locfield: date
    segmentfields: open close
    barwidth: 0.04
    outline: no
    color: blue

    // do volume

    // define bottom plotting area using proc areadef
    #proc areadef
    #clone: A
    rectangle: 1 1.6 5 2.6
    yrange: 0 5000000
    yscaletype: linear
    title:

    // set up X axis using proc xaxis
    #proc xaxis
    label: Volume (1000s)
    ticincrement: 5
    grid: color=gray(0.8)
    labeldetails: adjust=0,0.2 size=8
    axisline: none
    tics: none

    // set up Y axis using proc yaxis
    #proc yaxis
    stubs: inc 1000 1000
    grid: color=gray(0.8)
    axisline: none
    tics: none

    // render histogram using proc bars
    #proc bars
    barwidth: 0.04
    color: dullyellow
    locfield: 1
    lenfield: 6
    outline: no