ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Next Chart Project - OHLC chart with the works
Posted by icm63 on Feb-15-2009 10:31
Attachments:
Hi,

Just completed a Point and Figure Chart with your tool for asp.net project, and now I am moving onto the next chart I require..

A stock chart for say Dow Jones

I have attached it..There three areas, each requires different attributes.
Area1 : OHLC, Trendlines, Channels, text and custome markers
Area 2: Volume bars, and volume average bands
Area 3 : Volume average between swings, the green line represents the average volume between point 1 and 2 marked on the main chart.

I will store all object point parameters in a sql table, and via a asp.net datagrid will allow editing by user. So all the trendline start and end dates, with start and end points will be stored in a table and loaded when chart is updated.

Required :
1) what chart format is best, finance chart ?
2) Whats best for area 2 and area3

Please advise on how chart director will best build this chart ???

Also once built I will want to do mouse over price trailing, hopefully in all areas (1,2,3)
ChartRequired.gif

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Feb-16-2009 01:19
Hi icm63,

1) what chart format is best, finance chart ?

Yes. You may start with the FinanceChart object.

2) Whats best for area 2 and area3

The FinanceChart object supports multiple indicator charts. You may plot the volume bars, and some custom data series (the "volume bands") in the second chart. You may plot another custom data series (the "average volume between select swings on main chart").

Like in other XYCharts, you may include tooltips and image maps in FinanceCharts for are data representations (lines, bars, candlesticks, etc).

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Feb-16-2009 02:36
Ok thats my start point, I will post my issues on this thread for this chart, thanks!

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Feb-17-2009 09:48
Attachments:
Questions

1) The right hand Y axis, how do I limit the price range to 5% above the highest price and 5 % below the lowest price ?

2) How to add the Volume average bands onto the 'Indicator Volume' bars ?

3) I assume when I do mouse over of the price bars I can get Date, open, High, low, close, volume ??? Is that correct ?
FinanceChart001.jpg

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Feb-17-2009 10:34
also to add to the above

4) How can I shade color between Volume Average banks, say a shade of red or gray ?

5) How does one draw a two point trendline ?

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Feb-17-2009 19:39
Hi icm63,

1) The right hand Y axis, how do I limit the price range to 5% above the highest price and 5 % below the lowest price ?

In your current chart, your highest price is around 380, and your lowest price is 0. (You can see in the legend box that your "Open" price is 0.) The axis scale is 0 - 400. So it is already within 5% of your highest and lowest price.

I think your data have errors. It is not common to have a stock with an open price of 0. To create a correct chart, the data must be correct first.

2) How to add the Volume average bands onto the 'Indicator Volume' bars ?

I assume you already have the data series for the "Volume average bands" (it is not clear to me where the data comes from, so I assume your code must already have the data). You may use FinanceChart.addIndicator, FinanceChart.addLineIndicator2, and FinanceChart.addBarIndicator2 to add lines and bars to an indicator chart. For example:

Dim myIndicator As XYChart = c.addIndicator(100)
Dim line1 As LineLayer = c.addLineIndicator2(myIndicator, myUpperVolAvgBandData, &Hff0000)
Dim line2 As LineLayer = c.addLineIndicator2(myIndicator, myLowerVolAvgBandData, &Hff0000)
c.addBarIndicator2(myIndicator, myVolData, &H6666ff, "Vol")

3) I assume when I do mouse over of the price bars I can get Date, open, High, low, close, volume ??? Is that correct ?

As in any XYChart, you can add tooltips by adding an image map to the chart. For example:

WebChartViewer1.ImageMap = c.getHTMLImageMap("", "", "title='" & c.getToolTipDateFormat() & " {value|G}'")

4) How can I shade color between Volume Average banks, say a shade of red or gray ?

You may add an InterLineLayer between the "Volume Average banks" (I assume you ema the "Volume average bands"). See the sample code "Line Comparison" for an example. It is like:

c.addInterLineLayer(line1.getLine(0), line2.getLine(1), &H8099ff99, &H8099ff99)

5) How does one draw a two point trendline?

You may use:

myChart.addLine(point1X, point1Y, point2X, point2Y, &H000000)

In the above, myChart is the XYChart object representing the chart to which you want to draw the line. (point1X, point1Y) and (point2X, point2Y) are the pixel (x, y) coordinates of the points relative to the chart. If you are using data coordinates instead, you may layout the chart first (BaseChart.layout) to auto-scale the axes, then use XYChart.getXCoor and XYChart.getYCoor to convert the data coordinates into pixel coordinates.

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Feb-17-2009 23:52
.."In your current chart, your highest price is around 380, and your lowest price is 0. (You can see in the legend box that your "Open" price is 0.) The axis scale is 0 - 400. So it is already within 5% of your highest and lowest price.

I think your data have errors. It is not common to have a stock with an open price of 0. To create a correct chart, the data must be correct first."...



MY goog data has no ZERO price in it...see attached file..

So how do I change Y axis to be 5% up and 5% down ??

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Feb-17-2009 23:56
Oooh wait a minute, as I wanted HLC and not OHLC is left the open array as NULL or I did not load any data into it...

Dim open() as double

m = number of records
Redim Open(m)

But no data was loaded into it, so I guess its packed with zeros

So with this setup how does one do the 5% thing, done based on the CLOSE price of the chart ?

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Feb-18-2009 00:59
Hi icm63,

According to VB.NET syntax (I assume you are using ASP.NET), your code fills the array with 0. You may refer to the VB.NET documentation for details.

If you do not have any data, please just use an empty array (not NULL - I am not too sure what is NULL, as it does not seem to be a keyword in VB.NET).

Dim open() as double = {}

Also, I am not exactly sure what is 5% mean in your message (5% of what?). If you mean 5% of the lowest and highest price, the code is:

'mainPriceChart = the XYChart object representing the main price chart
mainPriceChart.yAxis().setLinearScale(0.95 * lowestPrice, 1.05 * highestPrice)
mainPriceChart.yAxis().setRounding(false, false)

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Feb-18-2009 01:25
..."Also, I am not exactly sure what is 5% mean in your message (5% of what?). If you mean 5% of the lowest and highest price, the code is:"...

Sorry,anyways you code looks good.

XYChart ????

I thought the chart was a Finance object ?? Does matter ?

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Feb-18-2009 11:11
Attachments:
So far.

MY CODE
***************************************
        Dim n As Integer = 0
        Dim m As Integer = Data.GetUpperBound(0)

        Dim Period(m) As DateTime
        Dim Open(0) As Double
        Dim High(m) As Double
        Dim Low(m) As Double
        Dim Close(m) As Double
        Dim Volume(m) As Double

        'LOAD Data into calc arrays
        For k As Integer = 0 To Data.GetUpperBound(0)
            Period(n) = Data(k).nDate
            'Open(n) = Data(k).nOpen
            High(n) = Data(k).nHigh
            Low(n) = Data(k).nLow
            Close(n) = Data(k).nClose
            Volume(n) = Data(k).nVolume
            n += 1
        Next

        'Setup chart
        Dim c As FinanceChart = New FinanceChart(750)
        c.setData(Period, High, Low, Open, Close, Volume, 50)
        c.addMainChart(250)
        c.addHLOC(&H0)
        c.addTitle("Chart of : " & Symbol.ToString)

        'Volume Indicator with Bands
        Dim indVolAve As XYChart = c.addIndicator(150)
        Dim AveVolBandUp() As Double = Calc_ExpAveVolumeBand(Volume, 18, 1.5)
        Dim AveVolBandLow() As Double = Calc_ExpAveVolumeBand(Volume, 18, 0.75)
        Dim line1 As LineLayer = c.addLineIndicator2(indVolAve, AveVolBandUp, &HFF0000, "Upper Band")
        Dim line2 As LineLayer = c.addLineIndicator2(indVolAve, AveVolBandLow, &HFF0000, "Lower Band")
        c.addBarIndicator2(indVolAve, Volume, &H6EFF, "Vol")


        ' output the chart
        WebChartViewer2.Image = c.makeWebImage(Chart.GIF)
***************************************

REQUEST1 : How can I shade color between Volume Average banks, say a shade of red or gray ?

YOU SAID .."You may add an InterLineLayer between the "Volume Average banks" (I assume you ema the "Volume average bands"). See the sample code "Line Comparison" for an example. It is like:

c.addInterLineLayer(line1.getLine(0), line2.getLine(1), &H8099ff99, &H8099ff99)"...

ME: I get error 'c.addInterLineLayer' is not part of finance chart object ????

REQUEST2: How do I increase the margin btw the last bar on right with the Y axis.?/
This didnt work in the finance chart object : c.xAxis().setMargin(10)
FinanceChart1001.jpg

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Feb-18-2009 13:41
Another question..

..."myChart.addLine(point1X, point1Y, point2X, point2Y, &H000000)

In the above, myChart is the XYChart object representing the chart to which you want to draw the line. (point1X, point1Y) and (point2X, point2Y) are the pixel (x, y) coordinates of the points relative to the chart. If you are using data coordinates instead, you may layout the chart first (BaseChart.layout) to auto-scale the axes, then use XYChart.getXCoor and XYChart.getYCoor to convert the data coordinates into pixel coordinates."...

YES I am ==> "If you are using data coordinates instead"

Q: How do do this ..."you may layout the chart first (BaseChart.layout) to auto-scale the axes, then use XYChart.getXCoor and XYChart.getYCoor to convert the data coordinates into pixel coordinates."...

MY code below failed...

        Dim StartDate As DateTime = CDate("10/01/2008")
        Dim EndDate As DateTime = CDate("02/02/2009")
        Dim StartPrice As Double = Calc_GetPriceForDate(Data, StartDate, 10)
        Dim EndPrice As Double = Calc_GetPriceForDate(Data, EndDate, 10)

       'NOTE: Calc_GetPriceForDate finds High or Low for the price bar on the date in question. 10 means High price ??

        c.addLine(StartDate, StartPrice, EndDate, EndPrice, &H0)
      ' fails as inputs are NOT Integers

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Feb-18-2009 16:22
Hi icm63,

For controlling the y-axis scale to be "5% of the lowest and highest price", you need to inform ChartDirector which y-axis you need to control, so you need to use XYChart.Axis. The XYChart is the chart that contains the y-axis.

(The FinanceChart is just a container for multiple charts. For example, in your current case, you have two XYCharts objects in the FinanceChart, one for the OHLC chart, and one for the volume bars.)

In your current code, you use:

c.addMainChart(250)

You need to save the returned XYChart object, so you may modify its y-axis:

Dim myPriceChart As XYChart = c.addMainChart(250)

myPriceChart.yAxis().setLinearScale(..........)
myPriceChart.yAxis().setRounding(..........)

For the addInterLineLayer problem, sorry the chart object should refer to the XYChart that you want to add the InterLineLayer. It is called "indVolAve" in your code (not called "c").

To increase the margin between the last bar and the y-axis, you may try:

myPriceChart.xAxis().setMargin(10)

You may want to set the same margin to other charts (eg. the chart for the volume bars) too.

For adding a line segment using data coordinates, the code is (assuming you want to add to the OHLC chart):

'should be called after you have set up the entire chart - this method auto-scaled the axis
myPriceChart.layout()

'Note: Like in any financial chart, the x-axis represents trading sessions. The trading
'session number for the first visible bar in your chart is 0, for the second bar it is 1,
'and so on. You may need to look up your dates in your timeStamps array to get the
'trading session number.
Dim x1 As Interger = myPriceChart.getXCoor(startTraditionSessionNumber)
Dim x2 As Interger = myPriceChart.getXCoor(endTraditionSessionNumber)

Dim y1 As Interger = myPriceChart.getYCoor(startPrice)
Dim y2 As Interger = myPriceChart.getYCoor(endPrice)

myPriceChart.addLine(x1, y1, x2, y2, &H000000)

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Feb-19-2009 00:59
Well we are haiving fun here..


        Dim n As Integer = 0
        Dim m As Integer = Data.GetUpperBound(0)

        Dim Period(m) As DateTime
        Dim Open(0) As Double
        Dim High(m) As Double
        Dim Low(m) As Double
        Dim Close(m) As Double
        Dim Volume(m) As Double

        'LOAD Data into calc arrays
        For k As Integer = 0 To Data.GetUpperBound(0)
            Period(n) = Data(k).nDate
            'Open(n) = Data(k).nOpen
            High(n) = Data(k).nHigh
            Low(n) = Data(k).nLow
            Close(n) = Data(k).nClose
            Volume(n) = Data(k).nVolume
            n += 1
        Next

        'Setup chart
        Dim c As FinanceChart = New FinanceChart(750)
        c.setData(Period, High, Low, Open, Close, Volume, 50)
        c.addMainChart(250)
        c.addHLOC(&H0)
        c.addTitle("Chart of : " & Symbol.ToString)


        'Volume Indicator with Bands
        Dim indVolAve As XYChart = c.addIndicator(150)
        Dim AveVolBandUp() As Double = Calc_ExpAveVolumeBand(Data, 18, 1.5)
        Dim AveVolBandLow() As Double = Calc_ExpAveVolumeBand(Data, 18, 0.75)
        Dim line1 As LineLayer = c.addLineIndicator2(indVolAve, AveVolBandUp, &HFF0000, "Upper Band")
        Dim line2 As LineLayer = c.addLineIndicator2(indVolAve, AveVolBandLow, &HFF0000, "Lower Band")
        c.addBarIndicator2(indVolAve, Volume, &H6EFF, "Vol")


        indVolAve.xAxis().setMargin(10)
        indVolAve.addInterLineLayer(line1.getLine(0), line2.getLine(1), &H8099FF99, &H8099FF99)




        ' output the chart
        WebChartViewer2.Image = c.makeWebImage(Chart.GIF)

**************************************************
ISSUE : Both of these lines do nothing on the chart

        indVolAve.xAxis().setMargin(10)
        indVolAve.addInterLineLayer(line1.getLine(0), line2.getLine(1), &H8099FF99, &H8099FF99)

Is this because "Dim indVolAve As XYChart = c.addIndicator(150)" is the volume indicator only and main chart is "c"

????

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Feb-19-2009 01:45
Hi icm63,

For setMargin, I think it is better to apply it to the first chart (the main price chart in your case). For safety, you may apply it to every chart too.

In your original code, you have:

c.addMainChart(250)

Please save the returned value:

Dim myMainChart As XYChart = c.addMainChart(250)

Now apply Axis.setMargin to it:

myMainChart.xAxis().setMargin(10)

For the interline layer, I think my original code has a mistake. It should be:

indVolAve.addInterLineLayer(line1.getLine(0), line2.getLine(0), &H8099FF99, &H8099FF99)

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Feb-19-2009 04:37
Attachments:
1) margin code not working
2) Dim myMainChart As XYChart = c.addMainChart(50) This line just added a block of empty between price and volume chart ( note I change 250 to 50 to fit)
3) Is 'myMainChart.layout()' correct, I guess I need this for trendlines, which I cant start yet until I get 1 and 2 sorted.

************************************************************
        'Setup chart
        Dim c As FinanceChart = New FinanceChart(750)



        c.setData(Period, High, Low, Open, Close, Volume, 50)
        c.addMainChart(250)
        c.addHLOC(&H0)
        c.addTitle("Chart of : " & Symbol.ToString)

        'Save Main Chart as XYChart
        Dim myMainChart As XYChart = c.addMainChart(50)
        'ISSUE TWO
        myMainChart.xAxis().setMargin(10)

        'ISSUE THREE
        myMainChart.layout()


        'Volume Indicator with Bands
        Dim indVolAve As XYChart = c.addIndicator(150)
        Dim AveVolBandUp() As Double = Calc_ExpAveVolumeBand(Data, 18, 1.5)
        Dim AveVolBandLow() As Double = Calc_ExpAveVolumeBand(Data, 18, 0.75)
        Dim line1 As LineLayer = c.addLineIndicator2(indVolAve, AveVolBandUp, &HFF0000, "Upper Band")
        Dim line2 As LineLayer = c.addLineIndicator2(indVolAve, AveVolBandLow, &HFF0000, "Lower Band")

        c.addBarIndicator2(indVolAve, Volume, &H6EFF, "Vol")

        indVolAve.addInterLineLayer(line1.getLine(0), line2.getLine(0), &H8099FF99, &H8099FF99)

        'ISSUE TWO
        indVolAve.xAxis().setMargin(10)

        ' output the chart
        WebChartViewer2.Image = c.makeWebImage(Chart.GIF)
***********************************************************
FinanceChart1001.jpg

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Feb-19-2009 04:40
Delete last post got  it working

cheers

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Feb-19-2009 06:56
Attachments:
Progress so far..Good

Trendlines:
1) how do I make them a ray - Extend out to the right all the way
2) how do I format them as dash and dot etc

Objects:
- How does one add a built in symbols from the example called "Built-in symbols" in demo pages
- The same above for custom symbols

For example I want to add a 'object' on date : 01/01/2009 at price $350.00

Also for single object on the layer I want a tooltip to be attached to the object above.

So there may be a star with a tooltip saying "Price is stong here !", and it shows up with mouse over action.
FinanceChart1001.jpg

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Feb-19-2009 09:14
Another Question

I am using this code extract the same format from example called : "javascript clickable chart"


        ' Client side Javascript to show detail information "onmouseover"
        Dim showText As String = "onmouseover='ShowChartDataVOL1(""{xLabel}"", {value|2});'"

        WebChartViewer2.ImageMap = c.getHTMLImageMap("", "", showText)

From the chart above this returns ONLY to the aspx page :
- Label Date
- Volume only

When I mouse over volume bars it works, however when I mouse over price bars, nothing happens. OHLC data is not visible.

I would like to see

02/13/2009 O:540.53 H:550.25 L:525.25 C:520.25 V:45656546

The label date is ok, but I much rather have MM/dd/yyyy

I have no idea how to get data from main chart into the passing function to see in main screen via javascript.

Please advise ( Please see my code in post above)...


Thanks

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Feb-19-2009 16:36
Hi icm63,

To extend a trend line, please just extend it normally. (This should be simple geometry. You can compute the rate of increase or decrease, and computer its value at any date, such as the last date on the far right. It can probably be achieved with 1 line of code using arithmatic.)

After you have extended the line, please pass the data point to ChartDirector to plot it.

To create "dash and dot etc", you may use "dash line colors" as the line colors. Please refer to the "Multi-Line Chart" sample code for an example of using dash line color.

For adding built-in symbols or custom symbols, you may refer to the sample code in "Symbol Line Chart" and "Custom Symbols". They demonstrates lines with built-in and custom symbols. If you do not need the line, please set the line color to transparent. If you do not need all symbols (just some symbol in some point), please put Chart.NoValue in the positions that do not need symbols.

To create tooltips for the symbols, please use Layer.setHTMLImageMap to set any tooltips you want. For example:

'layer = the line layer containing your symbols
layer.setHTMLImageMap("", "", "title='Price is stong here !'")

For the tooltip date format. you may try:

{xLabel|mm/dd/yyyy}

To include the high/low/open/close in your Javascript for the candlesticks or OHLC bars, please use {high}, {low}, {open}, {close}. If you need the volume as well, please add it as an extra field (like in the "Javascript Clickable Chart" sample code.)

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Feb-19-2009 23:50
.."To extend a trend line, please just extend it normally. (This should be simple geometry. You can compute the rate of increase or decrease, and computer its value at any date, such as the last date on the far right. It can probably be achieved with 1 line of code using arithmatic.)"..

Q: So I assume I can go beyond the last point on the right hand side of my chart then ?


.."'layer = the line layer containing your symbols
layer.setHTMLImageMap("", "", "title='Price is stong here !'")"..

Q: HOw does this code, link to an exact custom symbol ??, There are no coordinates ?

.."To include the high/low/open/close in your Javascript for the candlesticks or OHLC bars, please use {high}, {low}, {open}, {close}. If you need the volume as well, please add it as an extra field (like in the "Javascript Clickable Chart" sample code.)"..

Q: My current code is only giving me volume, from the addon xy chart for volume, how do I get OHLC from the main chart.

.."I am using this code extract the same format from example called : "javascript clickable chart

Current code....


        ' Client side Javascript to show detail information "onmouseover"
        Dim showText As String = "onmouseover='ShowChartDataVOL1(""{xLabel}"", {value|2});'"

        WebChartViewer2.ImageMap = c.getHTMLImageMap("", "", showText)

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Feb-20-2009 00:08
TYpo..

This is the correct question :
Q: So I assume I CANT go beyond the last point on the right hand side of my chart then ?

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Feb-20-2009 01:20
Hi icm63,

You can go beyond the last point of your chart. For example, you can compute the end point of your trend line at the 10000th trading session, and ask ChartDirector to plot that. (That point will likely be outside the chart, but ChartDirector will still draw the part of the trend line that is within the chart image.)

For the image map, the tooltip links to the "layer" object. If the layer contains 1 symbol, then only that symbol will have the tooltip. (This means if you want one symbol to have a special tooltip, you may put it in its own layer.)

You may use:

Dim showText As String = "onmouseover='myJavascriptFunction(""{xLabel}"", ""{value|2}"", ""{high}"", ""{low}"", ""{open}"", ""{close}"");'"

In the above, myJavaFunction is the javascript function you need to write, which handles the data. When your mouse is over the OHLC symbols, the {high}, {low}, {open}, {close} will be filled with valid values. Your myJavaFunction can then do whatever you like with those values. If the mouse is not over the OHLC symbols, the {high} will not become a valid value. Your myJavaFunction use this to detect that the mouse is not over the OHLC, and perform other actions.

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Feb-20-2009 01:37
..."You can go beyond the last point of your chart. For example, you can compute the end point of your trend line at the 10000th trading session, and ask ChartDirector to plot that. (That point will likely be outside the chart, but ChartDirector will still draw the part of the trend line that is within the chart image.)"...

1000th session, so X2 = 10000....

Ok then !

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Feb-20-2009 07:11
Attachments:
.."You may use:

Dim showText As String = "onmouseover='myJavascriptFunction(""{xLabel}"", ""{value|2}"", ""{high}"", ""{low}"", ""{open}"", ""{close}"");'"

In the above, myJavaFunction is the javascript function you need to write, which handles the data. When your mouse is over the OHLC symbols, the {high}, {low}, {open}, {close} will be filled with valid values. Your myJavaFunction can then do whatever you like with those values. If the mouse is not over the OHLC symbols, the {high} will not become a valid value. Your myJavaFunction use this to detect that the mouse is not over the OHLC, and perform other actions."..

THE ABOVE IS NOT WORKING

MY CODE_BEHIND........
        'Data Setup as to daily or weekly
        setChartData()
        Dim ExtraBars As Integer = 50
        Dim n As Integer = 0
        Dim m As Integer = Data.GetUpperBound(0)
        Dim LastPricePoint As String

        Dim Period(m) As DateTime
        Dim Open(m) As Double
        Dim High(m) As Double
        Dim Low(m) As Double
        Dim Close(m) As Double
        Dim Volume(m) As Double

        'LOAD Data into calc arrays
        For k As Integer = 0 To Data.GetUpperBound(0)
            Period(n) = Data(k).nDate
            Open(n) = Data(k).nOpen
            High(n) = Data(k).nHigh
            Low(n) = Data(k).nLow
            Close(n) = Data(k).nClose
            Volume(n) = Data(k).nVolume
            n += 1
        Next

        'Get last Price point in period range for infomation tag
        Dim chg As Double = Math.Round((Data(Data.GetUpperBound(0)).nClose - Data(Data.GetUpperBound(0) - 1).nClose), 2)
        Dim LClose As Double = Math.Round(Data(Data.GetUpperBound(0)).nClose, 2)
        Dim PercChg As Double = Util.GetSafePercentage(chg, Data(Data.GetUpperBound(0) - 1).nClose, 1)
        LastPricePoint = _
        Format(Data(Data.GetUpperBound(0)).nDate, "dd-MMM-yyyy").ToString + _
        "  Close: $" + Format(LClose, "#.#0").ToString & _
        "  Change: " + Util.getPlusMinusOnPrice(chg) + "$" + Format(Math.Abs(chg), "#.#0").ToString & _
        "  (" + Format(PercChg, "#.0").ToString + "%)"
        'Post to chart
        ' If st.Period = 20 Then
        'Me.labLastData_VOL1.Text = "WEEKLY" & Info & " " & LastPricePoint
        ' Else
        Me.labLastData_VOL1.Text = "DAILY" & Info & " " & LastPricePoint
        ' End If



        'Get high and low prices of data
        Dim HighPrice As Double = Util.MaxMinDBLArray(High, 1, ExtraBars)
        Dim LowPrice As Double = Util.MaxMinDBLArray(Low, 0, ExtraBars)

        'Setup Finance chart
        Dim c As FinanceChart = New FinanceChart(750)
        c.setData(Period, High, Low, Open, Close, Volume, ExtraBars)

        'Set Finance Chart as XYChart
        Dim d As XYChart = c.addMainChart(250)
        c.addHLOC(&H0)
        c.addTitle("Chart of : " & Symbol.ToString)

        'Set Chart to be 5% above and below data in chart
        Dim Temp As Double = LowPrice
        If (Temp - (HighPrice * (YAxisSpace / 100))) < 0 Then
            LowPrice = 0
        Else
            LowPrice = (Temp - (HighPrice * (YAxisSpace / 100)))
        End If

        d.yAxis().setLinearScale(LowPrice, (1 + (YAxisSpace / 100)) * HighPrice)
        d.yAxis().setRounding(False, False)

        'Set Margins and Layout
        d.xAxis().setMargin(10)
        d.layout()

        'Volume Indicator with Bands
        Dim indVolAve As XYChart = c.addIndicator(150)
        Dim AveVolBandUp() As Double = Calc_ExpAveVolumeBand(Data, 18, 1.2)
        Dim AveVolBandLow() As Double = Calc_ExpAveVolumeBand(Data, 18, 0.8)
        Dim line1 As LineLayer = c.addLineIndicator2(indVolAve, AveVolBandUp, &HFF0000, "Upper Band")
        Dim line2 As LineLayer = c.addLineIndicator2(indVolAve, AveVolBandLow, &HFF0000, "Lower Band")
        c.addBarIndicator2(indVolAve, Volume, &H6EFF, "Vol")
        indVolAve.addInterLineLayer(line1.getLine(0), line2.getLine(0), &HFFD8DC, &HFFD8DC)
        indVolAve.xAxis().setMargin(10)

        'Trendlines TEST
        Dim StartNumber0 As Double = Calc_GetBarNoForDate(Data, CDate("01/06/2009")) - ExtraBars
        Dim StartPrice0 As Double = Calc_GetPriceForDate(Data, CDate("01/06/2009"), 10)

        Dim EndNumber0 As Double = Calc_GetBarNoForDate(Data, CDate("02/09/2009")) - ExtraBars
        Dim EndPrice0 As Double = Calc_GetPriceForDate(Data, CDate("02/09/2009"), 10)

        Dim x1 As Integer = d.getXCoor(StartNumber0)
        Dim y1 As Integer = d.getYCoor(StartPrice0)

        Dim x2 As Integer = d.getXCoor(EndNumber0)
        Dim y2 As Integer = d.getYCoor(EndPrice0)

        d.addLine(x1, y1, x2, y2, &HFF0000, 1)


        ' output the chart
        WebChartViewer2.Image = c.makeWebImage(Chart.GIF)

        ' Client side Javascript to show detail information "onmouseover"
        Dim showText As String = "onmouseover='ShowChartDataVOL1(""{xLabel|mm-dd-yyyy}"",""{value|0}"",""{high}"", ""{low}"", ""{open}"", ""{close}"");'"



        WebChartViewer2.ImageMap = c.getHTMLImageMap("", "", showText)


MY JAVASCRIPT CODE...
function ShowChartDataVOL1(XLabel,Vol,High,Low,Open,Close)
{

    if(Vol != undefined)
    {
        var currHTML = document.getElementById('<%= divChartInfo_VOL1.ClientID %>').innerHTML;
        var k = currHTML.indexOf("Info:");
        if(k>-1)
        {
            var content = currHTML.substring(0,k) + "  Info: " +XLabel +" V:"+ Vol +" H:"+High;
            document.getElementById('<%= divChartInfo_VOL1.ClientID %>').innerHTML = content;
        }
        else
        {
            var content = currHTML + "  Info: "+XLabel +" V:"+ Vol +" H:"+ High;
            document.getElementById('<%= divChartInfo_VOL1.ClientID %>').innerHTML = content;
        }
    }
}
FinanceChart1001.jpg

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Feb-20-2009 10:48
Just to make it very clear about my intentions on objects and tooltips associated with them, if I cant do this please advise, thanks

I will have on the chart shown in the above post at different price bars (just below the low)
1- Green Box at X axis 10
2- Red Box at X axis 35
3- Red Circle at X axis 65
4- Blue Circle at X axis 150
5- Red Box at X axis 151

Each object will have a tooltip associated with it
1- Green Box: Tooltip = 'SOS'
2- Red Box: Tooltip = 'Strong day' ***Happened twice on chart***
3- Red Circle: Tooltip = 'BUY'
4- Blue Circle: Tooltip = 'Raise Stop'
5- Red Box: Tooltip = 'Strong day'     ***Happened twice on chart***

And Each time I place the mouse over the different objects, text tooltip pops up.

NOTE: This is as well as the OHLCV tooltip mouse over action when I place mouse over price and volume bars, that I am after in the post above.

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Feb-20-2009 18:49
Hi icm63,

I will provide an example for your Red Box. The others are the same.

Dim i As Integer
Dim margin As Double = (maxPrice - minPrice) * 0.05

'Two points "just below" the low price, and NoValue for all other points
Dim redBoxData(UBound(myTimeStamps)) As Double
For i = 0 To Ubound(redBoxData): redBoxData(i) = Chart.NoValue : Next
redBoxData(35 + extraPoints) = lowData(35 + extraPoints) - margin
redBoxData(151 + extraPoints) = lowData(35 + extraPoints) - margin

'This is the charting code.
Dim myLayer As ScatterLayer = myMainPriceChart.addScatterLayer(Nothing, redBoxData, "", Chart.SquareSymbol, 7, &Hff0000)
myLayer.setHTMLImageMap("", "", "title='Strong day'")

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Feb-20-2009 18:41
Hi icm63,

For the tooltip, in your original code, you have a line:

c.addHLOC(&H0)

May be you can try to replace it with:

Dim myHLOCLayer As HLOCLayer = c.addHLOC(&H0)

Then in the image map configuration, use:

myHLOCLayer.setHTMLImageMap("", "", showText)
WebChartViewer2.ImageMap = c.getHTMLImageMap("", "", showText)

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Feb-20-2009 22:37
.."myHLOCLayer.setHTMLImageMap("", "", showText)
WebChartViewer2.ImageMap = c.getHTMLImageMap("", "", showText)"...

So at first guess this will turn on OHLC, but turn off volume, is that correct ?

So I cant get both ???

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Feb-21-2009 02:09
Hi icm63,

In fact, both OHLC and Vol will be enabled.

The getHTMLImageMap line enables image map for all layers and all charts, including the volume bars. However, the exception is the OHLC layer, which uses it own tooltips, and need to be set with setHTMLImageMap. So the code suggested with have both OHLC or Vol (and any other indicators in your chart).

(The OHLC uses a different image map configuration because each OHLC symbol represents 4 values. So just using {value} will not work for OHLC.)

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Feb-22-2009 02:11
Error in code...

.."'This is the charting code.
Dim myLayer As ScatterLayer = myMainPriceChart.addScatterLayer(Nothing, redBoxData, "", Chart.SquareSymbol, 7, &Hff0000)
myLayer.setHTMLImageMap("", "", "title='Strong day'")"...

Error with "myMainPriceChart.addScatterLayer"

As my main chart is a Finance object ( the c variable), it does not allow 'addScatterLayer'

I did this below with no luck....

Dim temp as scatterlayer = c.addMainChart(250)

I have layers for OHLC data and for trendlines. Neither of these seam to work

Please advise ?




NOTE: tooltip to charts for volume and OHLC data world great, thanks.

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Feb-22-2009 02:17
also another question...

redBoxData(35 + extraPoints) = lowData(35 + extraPoints) - margin
redBoxData(151 + extraPoints) = lowData(35 + extraPoints) - margin

lowData for the scatter layer, like the trendline code, does that not have to be converted to d.getYCoor  ( ie d = is my XY Chart for trendlines), as the lowData for me is price like 450.45 for GOOG ???

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Feb-22-2009 02:21
Here is my current code :
I have changed some variables names for easier reading, scroll down to find OBJECT TEST for code to place objects on charts

        'Data Setup as to daily or weekly
        setChartData()
        Dim ExtraBars As Integer = 50
        Dim n As Integer = 0
        Dim m As Integer = Data.GetUpperBound(0)
        Dim LastPricePoint As String

        Dim Period(m) As DateTime
        Dim Open(m) As Double
        Dim High(m) As Double
        Dim Low(m) As Double
        Dim Close(m) As Double
        Dim Volume(m) As Double

        'LOAD Data into calc arrays
        For k As Integer = 0 To Data.GetUpperBound(0)
            Period(n) = Data(k).nDate
            Open(n) = Data(k).nOpen
            High(n) = Data(k).nHigh
            Low(n) = Data(k).nLow
            Close(n) = Data(k).nClose
            Volume(n) = Data(k).nVolume
            n += 1
        Next

        'Get last Price point in period range for infomation tag
        Dim chg As Double = Math.Round((Data(Data.GetUpperBound(0)).nClose - Data(Data.GetUpperBound(0) - 1).nClose), 2)
        Dim LClose As Double = Math.Round(Data(Data.GetUpperBound(0)).nClose, 2)
        Dim PercChg As Double = Util.GetSafePercentage(chg, Data(Data.GetUpperBound(0) - 1).nClose, 1)
        LastPricePoint = _
        Format(Data(Data.GetUpperBound(0)).nDate, "dd-MMM-yyyy").ToString + _
        "  Close: $" + Format(LClose, "#.#0").ToString & _
        "  Change: " + Util.getPlusMinusOnPrice(chg) + "$" + Format(Math.Abs(chg), "#.#0").ToString & _
        "  (" + Format(PercChg, "#.0").ToString + "%)<br/>"
        'Post to chart
        ' If st.Period = 20 Then
        'Me.labLastData_VOL1.Text = "WEEKLY" & Info & " " & LastPricePoint
        ' Else
        Me.labLastData_VOL1.Text = "DAILY" & Info & " " & LastPricePoint
        ' End If



        'Get high and low prices of data
        Dim HighPrice As Double = Util.MaxMinDBLArray(High, 1, ExtraBars)
        Dim LowPrice As Double = Util.MaxMinDBLArray(Low, 0, ExtraBars)

        'Setup Finance chart
        Dim mainChart As FinanceChart = New FinanceChart(750)
        mainChart.setData(Period, High, Low, Open, Close, Volume, ExtraBars)
        mainChart.addTitle("Chart of : " & Symbol.ToString)

        'Set Finance Chart as XYChart and OHLC layer
        Dim mainXYChart As XYChart = mainChart.addMainChart(250)
        Dim myOHLC As HLOCLayer = mainChart.addHLOC(&H0)

        'Set mainXYChart to be 5% above and below data in chart
        Dim Temp As Double = LowPrice
        If (Temp - (HighPrice * (YAxisSpace / 100))) < 0 Then
            LowPrice = 0
        Else
            LowPrice = (Temp - (HighPrice * (YAxisSpace / 100)))
        End If

        mainXYChart.yAxis().setLinearScale(LowPrice, (1 + (YAxisSpace / 100)) * HighPrice)
        mainXYChart.yAxis().setRounding(False, False)

        'Set Margins and Layout
        mainXYChart.xAxis().setMargin(10)
        mainXYChart.layout()


        'Volume Indicator with Bands
        Dim myXYChartVol As XYChart = mainChart.addIndicator(150)
        Dim AveVolBandUp() As Double = Calc_ExpAveVolumeBand(Data, 18, 1.2)
        Dim AveVolBandLow() As Double = Calc_ExpAveVolumeBand(Data, 18, 0.8)
        Dim line1 As LineLayer = mainChart.addLineIndicator2(myXYChartVol, AveVolBandUp, &HFF0000, "Upper Band")
        Dim line2 As LineLayer = mainChart.addLineIndicator2(myXYChartVol, AveVolBandLow, &HFF0000, "Lower Band")
        mainChart.addBarIndicator2(myXYChartVol, Volume, &H6EFF, "Vol")
        myXYChartVol.addInterLineLayer(line1.getLine(0), line2.getLine(0), &HFFD8DC, &HFFD8DC)
        myXYChartVol.xAxis().setMargin(10)

        'Trendlines TEST
        Dim StartNumber0 As Double = Calc_GetBarNoForDate(Data, CDate("01/06/2009")) - ExtraBars
        Dim StartPrice0 As Double = Calc_GetPriceForDate(Data, CDate("01/06/2009"), 10)
        Dim EndNumber0 As Double = Calc_GetBarNoForDate(Data, CDate("02/09/2009")) - ExtraBars
        Dim EndPrice0 As Double = Calc_GetPriceForDate(Data, CDate("02/09/2009"), 10)
        Dim x1 As Integer = mainXYChart.getXCoor(StartNumber0)
        Dim y1 As Integer = mainXYChart.getYCoor(StartPrice0)
        Dim x2 As Integer = mainXYChart.getXCoor(EndNumber0)
        Dim y2 As Integer = mainXYChart.getYCoor(EndPrice0)
        mainXYChart.addLine(x1, y1, x2, y2, &HFF0000, 1)


        'OBJECTS TEST
        Dim redBoxData(Period.GetUpperBound(0)) As Double
        'Empty point array
        For i As Integer = 0 To redBoxData.GetUpperBound(0)
            redBoxData(i) = Chart.NoValue
        Next
        'Load points (only 160 points in array, first 50 are extra bars)
        redBoxData(80) = Low(80)
        redBoxData(50) = Low(50)


        'This is the charting code.
        Dim myLayer As ScatterLayer = mainXYChart.addScatterLayer(Nothing, redBoxData, "", Chart.SquareSymbol, 7, &HFF0000)
        myLayer.setHTMLImageMap("", "", "title='Strong day'")




        ' output the chart
        WebChartViewer2.Image = mainChart.makeWebImage(Chart.GIF)

        ' Client side Javascript to show detail information "onmouseover"
        Dim showText As String = "onmouseover='ShowChartDataVOL1(""{xLabel|mm-dd-yyyy}"",""{value|0}"",""{high}"", ""{low}"", ""{open}"", ""{close}"");'"

        myOHLC.setHTMLImageMap("", "", showText)
        WebChartViewer2.ImageMap = mainChart.getHTMLImageMap("", "", showText)

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Feb-22-2009 02:23
NOTE: "mainXYChart.addScatterLayer" in above code does not return any results either.

mainXYChart is layer used for trendlines.

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Feb-22-2009 14:55
Hi icm63,

No more layers can be added after calling layout. For the addScatterLayer, please put the code before myXYChart.layout.

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Feb-22-2009 16:04
That was easy....it works now

This is the object code that places an inbuilt red square on the chart..before Layout()

        'Objects Test
        Dim redBoxData(Period.GetUpperBound(0)) As Double
        'Empty point array
        For i As Integer = 0 To redBoxData.GetUpperBound(0)
            redBoxData(i) = Chart.NoValue
        Next
        'Load points (only 160 points in array, first 50 are extra bars)
        redBoxData(80) = Low(80)
        redBoxData(50) = Low(50)

        'This is the charting code.
        Dim myLayer As ScatterLayer = mainXYChart.addScatterLayer(Nothing, redBoxData, "", Chart.SquareSymbol, 7, &HFF0000)
        myLayer.setHTMLImageMap("", "", "title='Strong day'")

QUESTIONS........
1) How does one add the own symbols ?
I have my own icons to use in: ../mywebsite/images2/myRedSquareFancy.gif

Yet your code requires a double variable where it says addscatterlayer ...Chart.SquareSymbol.

2) I wish to add a two separate exponential Moving average to the OHLC main chart. One of the expave is to be based on the HIGH, and the other is to be on the low [not the close]. Then I wish to add a 'addInterLineLayer' between the two expaves to color btw the two expave above. Your 'addexpaverage' does not allow the above selection. What function do I use, add another layer ???

3) Layout() must be before trendlines, but after layers,any other tricks ?

Thanks for all help so far, getting near done...

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Feb-23-2009 02:23
This code you gave me, is for the situation where I have many symbols with each symbol having the same tooltip each time.

************
Dim i As Integer
Dim margin As Double = (maxPrice - minPrice) * 0.05

'Two points "just below" the low price, and NoValue for all other points
Dim redBoxData(UBound(myTimeStamps)) As Double
For i = 0 To Ubound(redBoxData): redBoxData(i) = Chart.NoValue : Next
redBoxData(35 + extraPoints) = lowData(35 + extraPoints) - margin
redBoxData(151 + extraPoints) = lowData(35 + extraPoints) - margin

'This is the charting code.
Dim myLayer As ScatterLayer = myMainPriceChart.addScatterLayer(Nothing, redBoxData, "", Chart.SquareSymbol, 7, &Hff0000)
myLayer.setHTMLImageMap("", "", "title='Strong day'")
**************

Q1: I have 50 CUSTOM symbols, so that is a 50 layers, can I great a function that allows me to send the symbol, tootip and location points to the function and load them that way, this will of course mean that the 'myLayer' would be used 50 times, does that matter ?

Q2: Is there a limit to number of layers per chart ?

Q3: Or is it like this, if I have 50 symbols with each having there own unique tooltip that will require 50 unique layers , so thats a total purmutation of 50 ?

Is there any easier way to code this that does not require massive repitition of the same code 50 times ?

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Feb-23-2009 23:12
Hi icm63,

Q1: I am not exactly sure what is the nature of your 50 "custom symbols". In the most general case, it means 50 symbols, each with a different shape and color, and each with a different tooltips. In this general case, you need 50 layers. (The symbols in one layer can have different tooltips, but they must have the same color and shape.)

According to VB syntax, it does not matter how many times a VB variable (like myLayer, or any other VB varaibles) are used.

Q2: There is no built-in limit to the number of layers. 50 layers is considered a small number of layers in ChartDirector. ChartDirector should be able to handle thousands of layers.

Q3: If you symbols are all different (one a red box, one a blue circle), then you need 50 layers for 50 symbols of different shapes. If your symbols are the same, you only need one layer. The tooltips for each symbol can be different. (You may have noticed even for the volume bars and OHLC symbols, the tooltip for each symbol is different.) For custom tooltips, you may use extra fields (see Layer.addExtraField).

In most programming languages (include VB.NET), you do not need to repeat code. You can always use a loop (like a For/Next loop, or Do While loop, etc). Of course you would need to modify your code so that it works in a loop, instead of repeating the same or similar code all over. The exact code is up to your design.

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Feb-23-2009 23:20
thanks..dont  forget the post and question three up from here...

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Feb-24-2009 02:25
Hi icm63,


1) To use a custom image as the symbol, use:

myLayer.getDataSet(0).setDataSymbol2(myPath)

Note that myPath should be a file system path name, not a URL path. If you want to use URL path, please use Server.MapPath to change the URL path to file system path.


2) For custom indicators, your code would need to compute the indicator data series. It is because it is not possible to include built-in functions for all possible custom indicators our users can invent.

ChartDirector does have some utilities for computing arithmatic in the ArrayMath class, but using it is not mandatory.

After your code have computed the data series for your custom indicator (such as expAvg of the "highData"), you may add them to your chart, like:

Dim line1 As LineLayer = mainChart.addLineIndicator2(myXYChartVol, myCustmIndicator, &HFF0000, "Upper Band")

You can repeat the above to add another custom indicator and fill the region in between as usual.


3) Layout should be called after adding layers, because layout requires the data from the layers to auto-scale the axis. (The main purpose of layout is to auto-scale the axis.) You cannot move or add anything that can affect the axis scale after layout.

The getXCoor and getYCoor should be called after layout, because the pixel to data coordinates conversion can only be achieved after the axis has been auto-scaled.


Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Feb-25-2009 10:26
Still not getting the custom symbol methods correct..

This is the code for default chart symbol thats works
*****************************************
        'Objects Test
        Dim redBoxData(Period.GetUpperBound(0)) As Double
        'Empty point array
        For i As Integer = 0 To redBoxData.GetUpperBound(0)
            redBoxData(i) = Chart.NoValue
        Next
        'Load points (only 160 points in array, first 50 are extra bars)
        redBoxData(80) = Low(80)
        redBoxData(50) = Low(50)

        'This is the charting code.
        Dim myLayer As ScatterLayer = mainXYChart.addScatterLayer(Nothing, redBoxData, "", Chart.SquareSymbol, 7, &HFF0000)
        myLayer.setHTMLImageMap("", "", "title='Strong day'")
**********************************************

You said this code was for 'custom symbols' : myLayer.getDataSet(0).setDataSymbol2(myPath)

So I did this...
***************************************************
        'Objects Test
        Dim redBoxData(Period.GetUpperBound(0)) As Double
        'Empty point array
        For i As Integer = 0 To redBoxData.GetUpperBound(0)
            redBoxData(i) = Chart.NoValue
        Next
        'Load points (only 160 points in array, first 50 are extra bars)
        redBoxData(80) = Low(80)
        redBoxData(50) = Low(50)

        'This is the charting code.
        Dim SymPath As String = Replace(AppDomain.CurrentDomain.BaseDirectory, "/", "\") & "images1/MyFancy.gif"
        Dim myLayer As ScatterLayer = mainXYChart.addScatterLayer(Nothing, redBoxData, "", myLayer.getDataSet(0).setDataSymbol2(SymPath), 7, &HFF0000)
        myLayer.setHTMLImageMap("", "", "title='Strong day'")
**************************************

Error: This code does not return a value : "myLayer.getDataSet(0).setDataSymbol2(SymPath)"

So what am I missing...

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Feb-25-2009 20:30
Hi icm63,

Just add the line "myLayer.getDataSet(0).setDataSymbol2(SymPath)" to the code that works. The code should be like:

**********************************************
       'Objects Test
        Dim redBoxData(Period.GetUpperBound(0)) As Double
        'Empty point array
        For i As Integer = 0 To redBoxData.GetUpperBound(0)
            redBoxData(i) = Chart.NoValue
        Next
        'Load points (only 160 points in array, first 50 are extra bars)
        redBoxData(80) = Low(80)
        redBoxData(50) = Low(50)

        'This is the charting code.
        Dim myLayer As ScatterLayer = mainXYChart.addScatterLayer(Nothing, redBoxData, "", Chart.SquareSymbol, 7, &HFF0000)
        myLayer.setHTMLImageMap("", "", "title='Strong day'")

        'Add the line here to use the custom symbol
        Dim SymPath As String = Replace(AppDomain.CurrentDomain.BaseDirectory, "/", "\") & "images1/MyFancy.gif"
        myLayer.getDataSet(0).setDataSymbol2(SymPath)

**********************************************

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Feb-27-2009 12:38
Attachments:
I have posted 2 question on the chart image

1) How to get Vol Ind 2 the same Yaxis levels as the Vol Ind 1 ?
2) How to get Vol Ind 2 with solid bars, no gaps, ie Blue is solid blue and magenta is solid magenta ?
FinanceChart1001.jpg

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Feb-27-2009 22:40
Hi icm63,

1) You can use Axis.syncAxis to synchronize the axis. For example:

mySecondVolBarChart.yAxis().syncAxis(myFirstVolumeBarChart.yAxis())

2) You may use BarLayer.setBarGap. For example:

myBarLayer.setBarGap(Chart.TouchBar)

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Mar-01-2009 14:37
This is code for adding a trendline to a XYChart ..

        Dim nColor As Integer = &HFF0000
        TLLay.addLine(x1, y1, x2, y2, nColor, 1).setWidth(TLWidth)



From the help files ..
*****************************

A dash line color is a dynamic color that switches on and off periodically. When it is used to draw a line, the line will appear as a dash line.

The style of the dash line is defined by a pattern code, which is a 4-byte integer. A value of PPQQRRSS (in hex) means the first PP pixels are turned on, followed by QQ pixels turned off, followed by RR pixels turned on, followed by SS pixels turned off, and then restart from PP again.

ChartDirector comes from several predefined constants for common dash line patterns.

Constant Value (in Hex) Dash Line Style
DashLine 00000505
DotLine 00000202
DotDashLine 05050205
AltDashLine 0A050505
*********************************

Q: How do I adjust the COLOR variable for the line formats (DashLine, DotLine) etc ?
Q: How do I get a RED DASH line ? Please give example, thanks.
Q: I assume I have the width part of the code correct ?

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Mar-02-2009 01:39
Cancel the above I cracked it

here is the correct code

        TLLay.dashLineColor(TLColor, Chart.DashLine)

        TLLay.addLine(x1, y1, x2, y2, TLLay.dashLineColor(TLColor, Chart.DashLine), TLWidth)

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Mar-03-2009 10:52
Attachments:
Q: How do I place a indicator chart title in the top left hand corner of the indicator layer ?
Indicator layers are XYcharts see picture
FinanceChart1001.jpg

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Mar-03-2009 18:33
Hi icm63,

You may add the title as a custom text (using BaseChart.addText). For example:

$myIndicatorChartObj->addText(50, 20, "Title Line 1\nTitle Line 2", "arialbd.ttf", 20, 0x888888);

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by Zannie on Mar-07-2009 08:44
RTFM.

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Mar-07-2009 09:16
RTFM "Read The Fooking Manual".

Do you mind, I do as much as I can...so MYOB, thanks !

  Re: Next Chart Project - OHLC chart with the works
Posted by Dave on Mar-07-2009 14:41
I just want to say thanks to Peter for answering all these questions. True, a lot could be
gained from the manual, but and "real life" example gives a good new view and is
sometimes easier to swallow AND it's GREAT to see this kind of dedication in help support.

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Mar-09-2009 14:04
yes, thanks peter for your help.

Question : I am using custom symbols on my chart, I know I can load unique tooltips for each symbol, from the example called 'Custom Clickable objects' is see code like

       ' Obtain the image map for the copyright message
       Dim copyRightImageMap As String = "<area " + copyRight.getImageCoor() + _
        " href='javascript:popMsg(""the copyright message"");' title='The " & _
        "copyright text is clickable!'>"


So can I also do unique comments when as user double clicks each individual custom symbol?

So with each unique symbol on the chart...i should be able to do this...
- Mouse over - tooltip pop up
- double click  - comments via javascript message box

Note: With the javascript code I could use any asp.net custom control to show the comments message from double clicking the custom symbol on the chart, that would be correct, do you concur !

Please advise !

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Mar-10-2009 04:09
Hi icm63,

I think you just need to use a javascript event handler in your image map.

For example, in previous message, I suggested using the following to create a tooltip for a scatter symbol:

       Dim myLayer As ScatterLayer = mainXYChart.addScatterLayer(Nothing, redBoxData, "", Chart.SquareSymbol, 7, &HFF0000)
        myLayer.setHTMLImageMap("", "", "title='Strong day'")

You can add the URL to the above code, like:

       Dim myLayer As ScatterLayer = mainXYChart.addScatterLayer(Nothing, redBoxData, "", Chart.SquareSymbol, 7, &HFF0000)
        myLayer.setHTMLImageMap("javascript:myFunction('any data you like')", "", "title='Strong day'")


In the above, myFunction is your Javascript function suitable as a URL click handler. It can perform anything you like, such as to pop up a message box.

(Note: URL is for single click. If you want "double click", you need to handle the ondblclick event, like:

        myLayer.setHTMLImageMap("", "", "title='Strong day' ondblclick='myFunction(.....)'")

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Mar-23-2009 10:07
Attachments:
How do I fix this line over reach at the top of my chart. There seams to be no issue at the bottom of the chart.

I calculate extended line by finding the last date of data and added a line step per date to the start point to end data point ( ie X axis)

Is there an eay way with out any code to calc the point/date of upper breach ???
LineError001.jpg

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Mar-24-2009 00:38
Hi icm63,

The line extends under the bottom of the chart too, but it will then covered by the chart under it.

In your case, you may use XYChart.setClipping to ask ChartDirector to clip the line to the plot area. The code is:

mainXYChart.setClipping()

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Mar-24-2009 04:18
.setClipping() had NO effect on the trendlines extension.

I placed the code before and after mainXYChart.layout()

However it did have an effect on the other non trendlnes drawing.

Any ideas how to curb the extended trendlines ???

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Mar-24-2009 08:13
Attachments:
Another question, as with the unresolved clipping() issue above.

I wish to draw this PINK ARC on my XYchart, I will have the high price, the low price and the price distance between the two (radius). So I need to get X and Y points for the ARC or do you have an 'bubble chart that can do this as well ?

NOTE: Price can be converted into XY co ordinates easy enough, I know how thats done, no worries there.

Any ideas how to approach this ?
ArcRequest001.jpg

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Mar-25-2009 00:50
Hi icm63,

Sorry. I forgot how your trend line is drawn. The setClipping only applies to lines drawn using data values (using addLineLayer, addTrendLayer, etc). It is because with data values, it is hard to known where are the end points (they depends on how the axis is auto-scaled), so a special API setClipping is invented.

If the line is drawn using pixel coordinates, your code can always adjust the pixel coordinates to fit the line in any bounding box you like. So if the end points are outside the plot area, ChartDirector assumes your code intentionally draw the line outside of the plot area.

If you want the line to be within the plot area, please adjust your coordinates so it stays within the plot area using elementary geometry.

For example, if you want the second end point the line (assuming it is (x2, y2)) not to exceed the top of the plot area, you can always check if yourself, like:

If y2 < topOfThePlotArea Then
   x2 = (x2 - x1) * (topOfThePlotArea - y1) / (y2 - y1) + x1
   y2 = topOfThePlotArea
End If

The topOfThePlotArea by default is 30, unless you change it using FinanceChart.setMargins.

For the quarter circle, I would suggest to use pixel coordinates. It is because the radius of the circle in your case does not entirely depend on your data. It also depends on the axis scale ratio of your chart.

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Mar-25-2009 04:24
Thanks that bit of code worked a treat.

How do I fix bottom line penetrations, say if plot area of XY was 250.
Just to keep code tidy !

Is the formula the same.

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Mar-26-2009 04:53
Hi icm63,

It is the same. Just replace "topOfThePlotArea" with "bottomOfThePlotArea" and replace "y2 < topOfThePlotArea" with "y2 > bottomOfThePlotArea".

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Mar-26-2009 06:28
What would this be : bottomOfThePlotArea

Is that the plot area I loaded into like:
Dim mainXYChart As XYChart = mainChart.addMainChart(400)

So is this bottomOfThePlotArea = 400, or is it a chart default like 30 as for the top of the chart ?

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Mar-26-2009 10:29
Hi icm63,

If you use mainChart.addMainChart(400), the bottom of the plot area is 430 (the top margin + the height).

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Apr-10-2009 12:05
All my colors are stored as #FFOOOO string

yet the colors you use are integer or &HO

How do I convert between the two ???

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Apr-10-2009 16:18
Hi icm63,

You may refer to your .NET documentation on how to parse a hex text string into a number. In particular, see the .NET documentation on Int32.Parse.

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Apr-14-2009 01:36
from a post made by Peter On Mar - 9 - 2009
.."In the above, myFunction is your Javascript function suitable as a URL click handler. It can perform anything you like, such as to pop up a message box.

(Note: URL is for single click. If you want "double click", you need to handle the ondblclick event, like:

        myLayer.setHTMLImageMap("", "", "title='Strong day' ondblclick='myFunction(.....)'")

Hope this can help.

Regards
Peter Kwan"...

**********************************
I want to add a tooltip and a comments via javascript to the custom symbol on the Chart..

This function puts the symbol and the tooltip on the chart, BUT fails with the comments via javascript !

VB.net...

Fire the function
DrawSymbols(TLL, 10, "01/06/2009", 98, "Trade_S_Buy_Blue", "Go long baby!", "This is a test!")

The function

    Private Sub DrawSymbols(ByVal TLLay() As TLLayers, ByVal LayerLevel As Integer, ByVal XDate As String, ByVal YLevel As Double, ByVal ObjectName As String, ByVal ObjectToolTip As String, ByVal Comments As String)
        Dim SymPath As String = Replace(AppDomain.CurrentDomain.BaseDirectory, "\", "/") & "images2/" & ObjectName & ".gif"
        Dim TTData(Data.GetUpperBound(0)) As Double

        'Load empty data array
        For i As Integer = 0 To TTData.GetUpperBound(0)
            TTData(i) = Chart.NoValue
        Next

        Dim SymNumber As Double = Calc_GetBarNoForDate(Data, CDate(XDate))
        TTData(CInt(SymNumber)) = YLevel

        For k As Integer = 0 To TLLay.GetUpperBound(0)
            Dim myLayer As ScatterLayer
            If LayerLevel = ((k + 1) * 10) Then
                myLayer = TLLay(k).TLLay.addScatterLayer(Nothing, TTData, "", Chart.SquareSymbol, 7, &HFF0000)
                myLayer.getDataSet(0).setDataSymbol2(SymPath)
                myLayer.setHTMLImageMap("", "", "title='" & ObjectToolTip & "' ondblclick='TEST1('" & Comments & "')'")
            End If
            myLayer = Nothing
        Next

    End Sub

Javascript....
//Function for comments from Symbol on chart
function TEST1(val)
{
alert(val);
}

This is how it renders at source code care of FireFox
<area shape="rect" coords="347,112,361,119" title='Go long baby!' ondblclick='TEST1('This is a test!')' />

So to conclude
1) symbol draws - good
2) tooltip works - good
3) double click on tooltip to fire javascript function fails - bad !

Any ideas ??

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Apr-14-2009 02:19
Correction..
WRONG : double click on tooltip to fire javascript function fails - bad !
CORRECT : double click on SYMBOL to fire javascript function fails - bad !

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Apr-14-2009 06:30
I got it working on ONE click...doing this..

myLayer.setHTMLImageMap("", "", " href = 'javascript:TEST1(""" & Comments & """);' title='" & ObjectToolTip & "'")

Q: So how do I do double click ??

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Apr-15-2009 00:26
Hi icm63,

You may refer to the HTML/Javascript documentation on how to handle double click. (According to the Javascript documentation, the double click event handler is called ondblclick.)

If the code does not work, it is probably because there is a bug in the Javascript or HTML code. You may consider to use your HTML and Javascript debugger to trouble-shoot the problem. It should instantly find the cause of the problem.

In fact, it is easy to see that the following is invalid in HTML/Javascript:

<area shape="rect" coords="347,112,361,119" title='Go long baby!' ondblclick='TEST1('This is a test!')' />

If you use single quote to delimit the ondblclick attribute, you cannot use single quote again to delimit your text string. You need to either escape the single quote, or use double quote in the text string, or you may use double quote to delimit the ondblclick attribute.

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Apr-17-2009 09:07
Using vb.net how do I get this effect with the data.

Currently my data looks like this within the chart
Period, Open, High, Low, Close, Volume
08/19/2004,100,104.06,95.96,100.34,22351900
08/20/2004,101.01,109.08,100.5,108.31,11428600
08/23/2004,110.75,113.48,109.05,109.4,9137200
08/24/2004,111.24,111.6,103.57,104.87,7631300

from code like :
        'LOAD Data into calc arrays
        For k As Integer = 0 To Data.GetUpperBound(0)
            Period(n) = Data(k).nDate
            Open(n) = Data(k).nOpen
            High(n) = Data(k).nHigh
            Low(n) = Data(k).nLow
            Close(n) = Data(k).nClose
            Volume(n) = Data(k).nVolume
            n += 1
        Next

I wish to expand the X axis like this, so my data array looks like this

Period, Open, High, Low, Close, Volume
08/19/2004,100,104.06,95.96,100.34,22351900
08/20/2004,101.01,109.08,100.5,108.31,11428600
08/23/2004,110.75,113.48,109.05,109.4,9137200
08/24/2004,111.24,111.6,103.57,104.87,7631300
08/25/2004
08/26/2004
08/27/2004
08/30/2004
08/31/2004
09/01/2004
09/02/2004
09/03/2004


The X axis expansion allows me to draw an object at between '08/25/2004' and '09/03/2004', and also have the mouseover tooltip over this date (X,Y) if I have any XYChart lines extend beyond '08/24/2004'. I will load dummy dates into the Period array to get the effect, but what do I do about open, high, low, close. Do I just leave them as is, will it stuff any thing up.

Please advise.

Thanks

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Apr-17-2009 10:25
Attachments:
I had a go and just added 10 more days to period, and it seamed to work fine.

Unless you have any warnings, please advise.

Another issue, see chart.

You gave me code to fix a line that started low and ended high, going thru top of chart. And code for line that start high and end low, that went thru bottom of chart.

like this..
        'Fix trendlines shooting thru top of chart
        'TOPCHARTMARGIN : default margin is 30, adjusted tp 43 for better fit
        If y2 < TOPCHARTMARGIN Then
            x2 = CInt((x2 - x1) * (TOPCHARTMARGIN - y1) / (y2 - y1) + x1)
            y2 = TOPCHARTMARGIN
        End If

        'Fix Trendlines shooting thru bottom of chart
        If y2 > (ChartHeight + 30) Then
            x2 = CInt((x2 - x1) * ((ChartHeight + 30) - y1) / (y2 - y1) + x1)
            y2 = (ChartHeight + 30)
        End If

Q: BUt how do I fix a trendline that starts high (above chart) and comes back into the chart as in picture ??
ChannelError001.jpg

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Apr-17-2009 16:46
Hi icm63,

I think it is exactly the same code. You just need to change the names of the variables to fit your requirements.

        If y1 < TOPCHARTMARGIN Then
            x1 = CInt((x1 - x2) * (TOPCHARTMARGIN - y2) / (y1 - y2) + x2)
            y1 = TOPCHARTMARGIN
        End If

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Apr-18-2009 08:54
Attachments:
Thanks trendline error fixed.

BUT I have just notices a LINE layer error, as that penetrates the upper chart area as well. See the very light green line breaking in top left hand corner of chart. Red arrows.

QUESTION : So hows this fixed on a LINE layer situation. (I have no upper margin on the chart) ????

This is my code to generate the array and add the line layer to the mainXYChart on the Finance chart..
'RAINBOW BANDS
        'Add High and Low ExpAverage bands.
        Dim ExpAveHigh() As Double = Calc_ExpAvePrice(High, 10)
        Dim ExpAveLow() As Double = Calc_ExpAvePrice(Low, 10)
        Dim ExpAveHigh2() As Double = Calc_BandsLevel2("H", ExpAveHigh, ExpAveLow, 1)
        Dim ExpAveLow2() As Double = Calc_BandsLevel2("L", ExpAveHigh, ExpAveLow, 1)
        Dim ExpAveHigh3() As Double = Calc_BandsLevel2("H", ExpAveHigh, ExpAveLow, 2)
        Dim ExpAveLow3() As Double = Calc_BandsLevel2("L", ExpAveHigh, ExpAveLow, 2)
        Dim line3 As LineLayer = mainChart.addLineIndicator2(mainXYChart, ExpAveHigh, &HBBFFB5, "")
        Dim line5 As LineLayer = mainChart.addLineIndicator2(mainXYChart, ExpAveHigh2, &HBBFFB5, "")
        Dim line4 As LineLayer = mainChart.addLineIndicator2(mainXYChart, ExpAveLow, &HFFBCC4, "")
        Dim line6 As LineLayer = mainChart.addLineIndicator2(mainXYChart, ExpAveLow2, &HFFBCC4, "")
        Dim line9 As LineLayer = mainChart.addLineIndicator2(mainXYChart, ExpAveHigh3, &HBBFFB5, "")
        Dim line10 As LineLayer = mainChart.addLineIndicator2(mainXYChart, ExpAveLow3, &HFFBCC4, "")
        mainXYChart.addInterLineLayer(line3.getLine(0), line4.getLine(0), &HFFF7C6, &HFFF7C6)
        mainXYChart.addInterLineLayer(line3.getLine(0), line5.getLine(0), &HEDFFE2, &HEDFFE2)
        mainXYChart.addInterLineLayer(line4.getLine(0), line6.getLine(0), &HFFE8E8, &HFFE8E8)

The Chart..
XYLinesError001.jpg

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Apr-18-2009 14:01
Also if you notice the above chart volume blue bars. The right Y axis starts at 0,then 200,000. Which is fine.

Yet when I select only 40 records the ZERO was automatically replaced with 200,000. How do I set Yaxis on volume to always start at ZERO no matter the data  loaded with the XYchart ? So NO automaticall scalling from the bottom, of course I would the upper Yaxis value to be auto determined by the data in the XYchart...

Please advise thanks...

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Apr-18-2009 16:47
Hi icm63,

Normally, there cannot be any line layer that can go outside the plot area if the axis is auto-scaled by ChartDirector. If the axis is not auto-scaled, and your code choose a scale so that it is possible the line can go outside the plot area, you may use XYChart.setClipping to ask ChartDirector to clip the line.

mainXYChart.setClipping()

For the auto-scaling of the y-axis, if you want the axis to always start from 0, you may use Axis.setAutoScale. For example:

myIndicatorChart.yAxis().setAutoScale(0.05, 0.05, 1)

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Apr-20-2009 04:14
Attachments:
Thanks, looks good now.

I must say your software has allowed me to do all I need, very happy with the product.

Question : how can I fix this title up in an XY chart. This chart is the Point and Figure chart from your code long ago ??
TitleError001.jpg

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Apr-20-2009 08:07
Attachments:
I wish to add indicators to my chart (RSI, MACD, stock etc)

I wish to have all the indicators above the OHLC price chart in all cases.

I find that depending where I place this code below, determines there location on the chart render.
        'Indicators
        mainChart.addSlowStochastic(100, 14, 3, &HFF0E0A, &HFF0E0A)
        mainChart.addRSI(100, 14, &HFF0E0A, 750, &HFF0E0A, &HFF0E0A)

If I place code early, indicators appear on top as desired, however all the trendlines and layers that I custom draw on the chart go all strange (see picture). If I place them late in the code (near the end), the indicators appear under the OHLC and Custom volume chart, but this is not my preferred display as said above.

Q: how do I get indicators above OHLC chart with no problems ?
IndicatorsAboveError001.jpg

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Apr-21-2009 00:45
Hi icm63,

For putting the legend box on the top of the plot area, you can just put the legend box there with your code. For example:

Dim box As LegendBox = c.addLegend(plotAreaLeftX, plotAreaTopY, False, "Arial", 8)
box.setMargin2(5, 0, 2, 1)
box.setSize(plotAreaWidth + 1, 0)

For the chart drawn when the mainChart is not the top chart, likely, it is not possible for me to debug the code at its current state. The code you provided may be incompete, and I cannot run or try the code. Also, just by looking at your code, it is not obvious to if the chart is in error or not. We need to know your intention before we can know if the chart meets your intention.

To diagnose the problem, I suggest you start from the "Finance Chart (2)" sample code. In this sample code, the main price chart is not the first chart, and it is using random numbers as data, so I can try to run it. You may then add some code to draw your "custom drawing" (just one custom line or band is sufficient - you can hard code everything). Then please send me the code, so I can try them.

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Apr-21-2009 01:41


To diagnose the problem, I suggest you start from the "Finance Chart (2)" sample code. In this sample code, the main price chart is not the first chart, and it is using random numbers as data, so I can try to run it. You may then add some code to draw your "custom drawing" (just one custom line or band is sufficient - you can hard code everything). Then please send me the code, so I can try them.


Q: WHere or how in "Finance Chart (2)" code, does the code make the determination to place indicators above or below the main price chart ???

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Apr-21-2009 03:33
Hi icm63,

The "Finance Chart (2)" sample code is sample code that comes with ChartDirector. You may look for "Finance Chart (2)" from the ChartDirector documentation index.

The "Finance Chart (2)" adds the indicators to the chart similar to your code. First, it adds a slow stochastic, then it adds the main price chart, then it adds a MACD indicator.

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Apr-21-2009 04:02
Sorry you didnt answer my question..

.."The "Finance Chart (2)" adds the indicators to the chart similar to your code. First, it adds a slow stochastic, then it adds the main price chart, then it adds a MACD indicator."...


Q: How does the slow stochastic end up above price chart in Finance Chart (2), when the MACD does not, whats the rule that makes this happen??

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Apr-21-2009 04:03
OOPs I got it now ..

cheers

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Apr-23-2009 10:52
Attachments:
Vertical Line question, I wish to extend a vertical line over the indicator charts. I can extend V line over price and two custom XY charts. But how do I do this for 'standard' indicator box areas ???
VerticalLineError001.jpg

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Apr-23-2009 23:44
A couple of other questions

1) The background of all the chart (no matter the panel) is a musty or off white, how can I change the back ground of the chart color ?

2) Plus how can I turn the grid off and on (both vertical and horizontal) ?

Thanks..

Neary done with this chart...thanks for help !

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Apr-24-2009 03:18
Hi icm63,

The "vertical line" you are using seems to be a bar in a bar chart. It does not go all the way to the top of the chart.

Instead of using a bar layer, I suggest you may add a vertical mark line using Axis.addMark. It is like:

c.xAxis().addMark(40, &H00aa00)

In the above, the "c" can be your main price chart, your custom charts, or your indicator charts.

For the background color and the grid line color, please use FinanceChart.setPlotAreaStyle. For example:

'white background with grey grid lines
c.setPlotAreaStyle(&Hffffff, &Hcccccc, &Hcccccc, &Hcccccc, &Hccccc)

If your existing code already have a line that uses setPlotAreaStyle, please change that line inside of adding another line with setPlotAreaStyle.

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Apr-24-2009 04:35
The vertical line issue
you said : c.xAxis().addMark(40, &H00aa00)


I am currently using

myXYChart.addLine(x1, y1, x2, y2, TLColorForm, TLWidth).setZOrder(z)

I tried addMark is does got to the full vertical length of the main price chart, but I cant change the front/back visual order.

As I asked before, how do I get a verical line over the MACD chart as well, as I dont have a XYChart object name for it, with either addMark or addLine ???
My object layers names are
mainChart >> Finance chart
mainXYChart >> Finance chart XY chart
VolXYChart >> Custom volume chart
VolOrdXYchart >>> another custom volume chart

What do I use for MACD indicator sub chart ???

Please show an example with either addMark or addLine or both, thanks.

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Apr-24-2009 05:46
Also, I have been studing the ZOOM code, esp this file 'zoomscrolldemo2.aspx'.

This example only includes one XY viewing layer (maybe many on top), but how does one do the zoom for a multi layer finance chart that can be changed with user selections and is not fixed. Like 'financedemo.aspx' when the user can add or remove the MACD indicator at will ??

Would the zoom only cover the price chart or the whole chart with indicators included ???

any examples out there  of zoom on multi layer finance chart ????

please advise >>

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Apr-25-2009 01:40
Hi icm63,

For the vertical line for a MACD chart, you can use:

myMACDChart.addLine(x1, y1, x2, y2, TLColorForm, TLWidth).setZOrder(z)

It is actually the same as your code, except you use the chart object that represents your indicator chart.

If you currently do not assign a variable to hold the indicator chart, please use a variable to hold the indicator chart. For example, if you are using:

c.addMACD(.........)

Please change the above to:

Dim myMACDChart As XYChart = c.addMACD(..........)

For the addMark, there are only two z-order supported - either on top of all layers, or under all layers. The default is to draw the mark on top of all layers. You may use Mark.setDrawOnTop to configure that. The BaseChart.addLine method allows for more flexibility for the z ordering.

For the Zooming and Scrolling Demonstration (2), when the user selects a region on the chart, a "ViewPortChanged" event will be fired. Your code can do anything you like in the event handler. In the sample code, it redraws the chart and adjusts the x and y axes to the scale as selected by the user, so it is a "zoom to the selected rectangle".

In your finance chart, you can do the same thing - redraw the chart to the range selected by the user.

The "selectable region" for a FinanceChart is the main price chart. So I would suggest you only allow the user to zooming on the x-axis scale (the time range). Then in the ViewPortChanged event handler, you can redraw the entire financial chart using the time range selected by the user.

Unluckily, I do not have an example for financial charts. You would need to develop it yourself.

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Apr-26-2009 06:29
Attachments:
Thanks for the above all sorted on vertical line, however ZOOM is for another day.

Issue drawing trendline on indicator Slow Stochastic

Inputs
X1 = 08/12/2008
X2 = 84.94
X2 = 09/22/2008
Y2 = 49.73

The trendline is supposed to touch the stochastic indicator exactly on the highs of the dates inputted, I selected the dates and values exactly so this would be so.

ISSUE: Depending upon the chart height the line draws where it wants to and not anywhere near the indicator line as requested by the input into the function.

This is the output from the debug code in the script attached
INPUTS 08/12/2008 / 84.94 / 09/22/2008 / 49.73
COODS 192 / 81 / 747 / 199

Any ideas ???
IndicatorLineError001.jpg
IndicatorLineError002.jpg

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Apr-26-2009 08:23
Further to the above, My indicators XY chart height are set at a 25% of the height of the chart.

I have no idea why the setting is lost when a line is added???

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Apr-27-2009 13:07
Hi icm63,

Have you call BaseChart.layout first before using getXCoor/getYCoor?

I suggest in the first line of your DrawTrendline, you add the line:

TLLay.layout()

In the last line of your function, you may add the line:

Debug.Write("DATA " & StartNumber & " / " & startPrice & " / " & endNumber & " / " & endPrice & vbNewLine)
Debug.Write("COODS " & x1 & " / " & y1 & " / " & x2 & " / " & y2 & vbNewLine)
Debug.Write("SIZE " & TLLay.getDrawArea().getWidth() & " / " & TLLay.getDrawArea().getHeight() & vbNewLine)
Debug.Write("Scale " & TLLay.xAxis().getMinValue() & " / " & TLLay.xAxis().getMaxValue( & " / " & TLLay.yAxis().getMinValue() & " / " & TLLay.yAxis().getMaxValue() & vbNewLine)

In ChartDirector, the chart size is always specified by your code. Without seeing your code, it is not cleary why the chart size changes. You may use Debug.Write to print out the chart size immediately after creating the chart for verification.

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Apr-27-2009 14:08
Yes I forgot the .layout() for each layer I want to draw trendlines on, thanks !

I new it would be a quickie !

Thanks...

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Apr-29-2009 04:56
Hi , when addText to the chart, how does one cater for linebreaks or <br/> 's So that say 150 characters of comments can be loaded the same why they were created in a multiline asp:textbox, with system line breaks ( or \n or <br/>).

How is that done in this code ???

mainXYChart.addText(75, 100, "This is an example of some text. This text I would like on the next line.", "Arial", 8, &H0)

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Apr-29-2009 04:59
I see this function here in PHP...for text wrapping...

http://www.chartdir.com/forum/download_thread.php?bn=chartdir_support&pattern=addtext+line+breaks&thread=1238807470#N1239042003

Is there a version in C# or vb.net, or is this outdated.

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Apr-29-2009 21:57
Hi icm63,

The code in the link in your message is for a "special line wrapping" method. This special line wrapping method is not implemented in HTML, or in common word processing programs, and not in ChartDirector, but is invented by the person writing that code.

If you would like to use that special line wrapping method, you would need to translate that code for your own use.

If you would like to use line wrapping like how the browser or word processor wraps text, you just need to set a maximum width for the text box. ChartDirector will wrap the text automatically.

mainXYChart.addText(75, 100, "This is an example of some text. This text I would like on the next line.", "Arial", 8, &H0).setMaxWidth(300)

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Apr-29-2009 21:54
Hi icm63,

You can add a linebreak to the text in exactly the same way as you would add linebreaks in any VB text. You just need to insert a linebreak character in the text. In VB, the linebreak character is vbLF.

The "<br/>" is not VB code. It is for a completely different programming langauge HTML.
It is only used if the text is rendered on the browser side. If the text is rendered on the server side, you would need to use VB. (HTML runs on the browser side, while VB runs on the servers side.)

For example:

mainXYChart.addText(75, 100, "This is an example of some text." & vbLF & " This text I would like on the next line.", "Arial", 8, &H0)

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-06-2009 02:07
Attachments:
Next feature

I wish to add square box price labels on pivots on the price chart (OHLClayer, Candles layer, Close linelayer).

I can calculate the array of date, position and price of each label. Add use the .addText method. But that approach wont allow me to put a square box around the price as in image.

I reviewed the example called 'Custom Scatter Labels', but I could see how I would handle the no value entries.

This is what I am after...please advise best approach..
PriceLabels001.jpg

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-06-2009 14:08
Attachments:
another question ...please see question above

Here I have a trendline starting within the bounds of the extrabars of a finance chart, that is off to the left. The Trendline breaches the boundaries of the left hand side of the finance chart..

You gave me code like this to fix TL on the other borders of chart, so how do I fix a line as you see in the image.


        'Fix trendlines shooting upper and lower boundaries of finance chart
        'default margin is 30, adjusted tp 43 for better fit
        'Lines Starting low ending high above top of chart
        If y2 < TOPCHARTMARGIN Then
            x2 = CInt((x2 - x1) * (TOPCHARTMARGIN - y1) / (y2 - y1) + x1)
            y2 = TOPCHARTMARGIN
        End If

        'Lines starting high than top of chart and ending low
        If y1 < TOPCHARTMARGIN Then
            x1 = CInt((x1 - x2) * (TOPCHARTMARGIN - y2) / (y1 - y2) + x2)
            y1 = TOPCHARTMARGIN
        End If

        'Fix Trendlines shooting thru bottom of chart
        If y2 > (ChartHeight + 30) Then
            x2 = CInt((x2 - x1) * ((ChartHeight + 30) - y1) / (y2 - y1) + x1)
            y2 = (ChartHeight + 30)
        End If

        'Lines starting high and ending low below bottom of chart
        If y1 > (ChartHeight + 30) Then
            x1 = CInt((x1 - x2) * (ChartHeight + 30) / (y1 - y2) + x2)
            y1 = (ChartHeight + 30)
        End If
X1Issue001.jpg

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on May-07-2009 01:47
Hi icm63,

For the text labels on the pivots on the price chart, personally, I would prefer to use a scatter layer. However, if you have already done that using addText, you can add the square box by just setting the border color to non-transparent:

Dim t As ChartDirector.TextBox = c.addText(..........)
t.setBackground(Chart.Transparent, &Hcccccc)

There are some benefit with the addText method though. If you want to draw the special polygonal shape (instead of a rectangle box) as shown in your attached image, you can do so using BaseChart.addLine (you can draw an arbitrary polygon by using multiple straight lines), or using DrawArea.polygon.

For the bounds, the code to clip the line in the x-direction is exactly the same as that in the y-direction. You just need to change the names of the variables (change x to y, and change y to x):


        If x1 < LEFTCHARTMARGIN Then
            y1 = CInt((y1 - y2) * (TOPCHARTMARGIN - x2) / (x1 - x2) + y2)
            x1 = LEFTCHARTMARGIN
        End If

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-07-2009 02:17
Thanks..

How would one do this with a 'scatter layer' ?? (price labels). That would also seam more economicaly with chartdir... addtext is adding at every point..., I guess scatter layer is using an array.

I assume the LEFTCHARTMARGIN default is ZERO... I have not made any changes there.

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on May-08-2009 01:31
Hi icm63,

To use a scatter layer, I will probably use two scatter layers:

'These are your data series for your scatter layers - this is in addition to the normal
'high/low/open/close/vol/timeStamps series.
Dim myHighScatterData(Ubound(myTimeStamps)) As Double
Dim myLowScatterData(Ubound(myTimeStamps)) As Double

'Initialize to NoValue
Dim i As Integer
For i = 0 To Ubound(myHighScatterData)
    myHighScatterData(i) = Chart.NoValue
    myLowScatterData(i) = Chart.NoValue
Next

'Fill the values you want to show (eg. index 50 is a high point, index 75 is a low point)
myHighScatterData(50) = myHighData(50)
myLowScatterData(75) = myLowData(75)
........... add more points if necessary - in real code, you would probably use a loop ...........

'add the scatter layers
Dim layer As Layer
layer = myMainPriceChart.addScatterLayer(Nothing, myHighScatterLayer, "", cd.SquareShape, 1, cd.Transparent, cd.Transparent)
layer.setDataLabelStyle("Arial", 8).setBackground(cd.Transparent, &Hccccccc)
layer = myMainPriceChart.addScatterLayer(Nothing, myLowScatterLayer, "", cd.SquareShape, 1, cd.Transparent, cd.Transparent)
layer.setDataLabelStyle("Arial", 8).setBackground(cd.Transparent, &Hccccccc)


The left margin is controlled by FinanceChart.setMargins. If you have not set the left margin, according to the documentation on FinanceChart.setMargins, the default is 40.

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-08-2009 07:09
Attachments:
Thanks, got them working fine.

The labels on the highs sat exactly on the top of the high, and so did the labels on the lows pivots , as seen in the image.

Is there an offset function to lower the label so that the top just sits under the low of the bar, or do I need to make adjustments in the scatterlayer symbol array ( ie like value *0.98)

Please advise ...
Labeloffset001.jpg

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-08-2009 11:37
Peter, After testing I cant do  this..."or do I need to make adjustments in the scatterlayer symbol array ( ie like value *0.98)"..

As the value of Y in the (X,Y) is also the label, so if I change the Y for presentation needs, is changes the Y value, thus the pivot price information become incorrect ..

So how do I lower the lower pivot label , below the low of the bar ??

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-08-2009 12:28
cancel the above, i got it working like this...

Dim HPiv() As Double
Dim LPiv() As Double
HPiv = Calc_Pivots(Period, HPrice, 1)
LPiv = Calc_Pivots(Period, LPrice, 0)

Dim HLayer As Layer = myXYChart.addScatterLayer(Nothing, HPiv, "", Chart.SquareShape, 1, Chart.Transparent, Chart.Transparent)
HLayer.setDataLabelStyle("Arial", 8).setBackground(Chart.Transparent, &HCCCCCCC)
HLayer.setDataLabelStyle("Arial", 8).setAlignment(2)
HLayer.setDataLabelFormat("{value|2}")

Dim LLayer As Layer = myXYChart.addScatterLayer(Nothing, LPiv, "", Chart.SquareShape, 1, Chart.Transparent, Chart.Transparent)
LLayer.setDataLabelStyle("Arial", 8).setBackground(Chart.Transparent, &HCCCCCCC)
LLayer.setDataLabelStyle("Arial", 8).setAlignment(8)
LLayer.setDataLabelFormat("{value|2}")

BUT if you cant improve it, let me know ?

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on May-08-2009 15:31
Hi icm63,

The only change I can think of is instead of using:

LLayer.setDataLabelStyle("Arial", 8).setBackground(Chart.Transparent, &HCCCCCCC)
LLayer.setDataLabelStyle("Arial", 8).setAlignment(8)

You may use:

Dim t As ChartDirector.TextBox = LLayer.setDataLabelStyle("Arial", 8)
t.setBackground(Chart.Transparent, &HCCCCCCC)
t.setAlignment(Chart.Top)

The code becomes longer (so you may not consider this an "improvement"), but you only need to enter ("Arial", 8) once. So if you want to change the font, you just need to change it once.

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-09-2009 03:06
Attachments:
Thanks for the above..

I have written 5000 lines code behind my finance chart chart director engine and I think its running out juice..

for example the first image, shows a rainbow band in full color green, yellow, red.

the second image shows the rainbow band with missing colors, and this occurs when I select a wide period with lots of extra features ( other indicators, trendlines, labels)
. This missing color happens with out any structured sequence like 'happens only after I add trendlines '(nope, happens whenever). Just when I add a lot of stuff. This same chart works ok with a small period selection, below the chart is 350 periods, it works fine at 125 periods.

Note: the line layers are fine, its the shading between the lines that goes 'missing'.

The effect is the same in IE 7 or FireFox 9

Any ideas
CGJuice1001.jpg
CGJuice1002.jpg

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-09-2009 03:09
This is the code that adds the line and interline layers for the rainbow bands....

            Dim line53 As LineLayer = FnChart.addLineIndicator2(inXYChart, ExpAveHigh, &HAFEFAA, "")
            Dim line55 As LineLayer = FnChart.addLineIndicator2(inXYChart, ExpAveHigh2, &HAFEFAA, "")
            Dim line54 As LineLayer = FnChart.addLineIndicator2(inXYChart, ExpAveLow, &HFFBCC4, "")
            Dim line56 As LineLayer = FnChart.addLineIndicator2(inXYChart, ExpAveLow2, &HFFBCC4, "")
            Dim line59 As LineLayer = FnChart.addLineIndicator2(inXYChart, ExpAveHigh3, &HAFEFAA, "")
            Dim line60 As LineLayer = FnChart.addLineIndicator2(inXYChart, ExpAveLow3, &HFFBCC4, "")
            inXYChart.addInterLineLayer(line53.getLine(0), line54.getLine(0), &HFFF7C6, &HFFF7C6)
            inXYChart.addInterLineLayer(line53.getLine(0), line55.getLine(0), &HEDFFE2, &HEDFFE2)
            inXYChart.addInterLineLayer(line54.getLine(0), line56.getLine(0), &HFFE8E8, &HFFE8E8)

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-09-2009 03:25
This is the sequence of events drawing the chart..


1) draw main chart with  finance chart with main XY chart
2) draw standard volume XYchart layer below (1) above
3) draw a second volume XYchart
4) draw standard moving averages on finance chart .addExpMovAve
5) draw on price indictors .addbollinger
6) draw pivots with price labels via addScatter layer
7) DRAW RAINBOW BANDS on mainXYchart
8) Draw below price chart, addMACD, addRSI etc
9) Draw objects 'custom symbols' via scatter layer pre layout call
10) Layout called on XYcharts used above
11) Draw trendlines and addtext

I find that I must run 7 after 4,5,6 other wise the rainbow .addinterlayer is on top of the other indicators and they cant be seen, so I rainbows after I run  4,5,6, then the rainbow bands layers seam to be underneath the moving averages, bollinger and pivot labels. And all can be seen.

Hope thats enough for you to get an idea..how to fix this..

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-09-2009 03:37
Also I note this..

1) inXYChart.addInterLineLayer(line53.getLine(0), line54.getLine(0), &HFFF7C6, &HFFF7C6)
2) inXYChart.addInterLineLayer(line53.getLine(0), line55.getLine(0), &HEDFFE2, &HEDFFE2)
3) inXYChart.addInterLineLayer(line54.getLine(0), line56.getLine(0), &HFFE8E8, &HFFE8E8)

(1) works all the time, this is the yellow interlinelayer, yet the other (2) and (3) go missing.

Also I am using ver 5 of Chart Director.

This situation happen to me when I was adding the moving average indicator code ( ie addExpMovAvg) , I found that I changed the color of the average then (2) and (3) above worked fine. So could it be a color conflict somewhere...

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-10-2009 06:07
ANOTHER question different topic from the above color and painting issues

I do this

Public area of vb.net module
Dim myInd1 as XYChart
Dim myInd2 as XYChart
Dim myInd3 as XYChart


Then in code I do this

private sub SomeFunction()
Dim tempXYChart as XYChart

i f X = 1 then
   tempXYChart = myInd1
else if x = 2 then
   tempXYChart = myInd2
else if x = 3 then
   tempXYChart = myInd3
end if

""""THIS NEXT LINE FAILS*****
if tempXYChart = nothing then Exit sub


'then run some drawing function
   Draw(tempXYChart, other parameters, etc)
end sub



Question.....this part

if tempXYChart = nothing then Exit sub

This allows me to check to see if the XYChart actual exists before I draw on it , the above code fails in vb.net as the error message says that 'nothing' is not part of the ChartDirector.XYChart methods or something....

So how can I TEST an 'tempXYChart' (which is one of these passed 'myInd1') to see if its exists as a object ????

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on May-11-2009 02:55
Hi icm63,

The color effects you are seeing seems to be due to insufficient colors. Are you using GIF (which supports only 256 colors) or PNG with transparency (for IE 6 compatibility, by default, ChartDirector will use 256 color format for any PNG image with transparency)?

If you ask ChartDirector to use a 256 color image format (such as GIF), and your chart has more than 256 colors, ChartDirector will be forced to remove some colors.

Like most color reduction algorithm, if ChartDirector finds two colors that are very similar, they may be combined together into a single color (the average of the two colors).

In your case, may be your fill color are too close to white, so they are merged with white to become an "average color". You can see in the chart that is without the bands, the background is not white. (It is very very pale grey - as if the white background color is merged with some non-white color.)

If the above is the cause of the problem, to solve the problem, I suggest not to use GIF or PNG with transparency. They are 256 color formats and are not suitable for complex charts.

For checking if an object is Nothing, please use "Is Nothing". It is the syntax of VB, and is described in the VB documentation. For example:

If aaa Is Nothing Then
   ... do something
End If

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-11-2009 03:45
oooh..

This worked...
If tempXYChart IsNot Nothing Then

end if

If I cantt use GIF or PNG for website image, what then has more than 256 colors ???

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-11-2009 03:47
Are the other choices JPG, WMP, BMP..which one will handle my demand, and whats the down side ???? Or choosing btw these options...

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-11-2009 03:58
PNG seamed to work (in IE 7+ and Firefox 9+), is JPG the best choice for color display, is there a downside to use JPG ?? Slower to upload chart to browser maybe ??

Thanks, that was easy !

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on May-11-2009 08:10
Hi icm63,

My suggestion is to use PNG. It has the best compression ratio and the highest quality image.

My previous message says you should not use "PNG with transparency". As long as you do not use transparency in the final output (your code have not called BaseChart.setTransparentColor), it is OK to use PNG.

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-12-2009 05:02
Any chance of removing the TXT attachments in this thread, as it has made my secret super dooper code public and other can dupilcate my work. Cheers

  Re: Next Chart Project - OHLC chart with the works
Posted by System Administrator on May-12-2009 19:15
Hi icm63,

I have just deleted some TXT attachments in your thread. If there are any further attachments you want to delete, would you mind to inform me where are the attachments?

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-13-2009 05:49
Thanks, you can delete these ones TXT attachments

Feb-18-2009 17:56   - MyCode.txt

Feb-17-2009 10:52   - GOOG.txt

On this thread..
http://www.chartdir.com/forum/download_thread.php?site=chartdir&bn=chartdir_support&thread=1231864171

Here
Feb-15-2009 16:18  - PFRunCode.txt

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-13-2009 06:51
Attachments:
I am still getting Trend line misbehaving and it driving me nuts...

Chart type : Finance Chart.

Two Charts, the first is a wide view showing how they should look. The second chart shows how they look on a zoomed in period. The trendlines draw as I have made the ExtraBars in the finance chart accommodate  the startdate of the earliest trendlines.

In the second chart: (Zoomed in period). Please focus on the X1, nd Y1 for each line.
The Red line is starting from beyond the Left hand side boarder and works fine, the green line starts from above the top border and works fine. HOWEVER the blue line starts underneath the bottom border and draws with a shift to the left by a degree, from where it should be?????? I thought my code fixed this.

This is the output from the debug code within the txt file (Function that draws lines for me) attached for the blue line..
DATA         29 / 60 / 79 / 100.32
COODS       315 / 405 / 833 / 43
SIZE          900 / 435
SCALE       0 / 79 / 62.439 / 97.881

Any ideas... where the donation button, I owe you heaps !
TrendlineTEST001.jpg
TrendlineTEST002.jpg

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on May-14-2009 02:27
Hi icm63,

I have already removed the 3 text files as per your request.

For the trend line, I think there is an error in your code:

x1 = CInt((x1 - x2) * (ChartHeight + 30) / (y1 - y2) + x2)

I cannot understand what is the function of the above code. Should it be:

x1 = CInt((x1 - x2) * ((ChartHeight + 30) - y2) / (y1 - y2) + x2)

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-14-2009 05:15
Thanks to deletions and the fix..

Question

When I draw a trendline on a Linear finance chart its easy as peasy..
X1 = Date
X2 = Date
Y1 = 60
Y2  = 100

Both Y1 and Y2 match up with the Close() array I send to the finance chart.

BUT, when I turn on LOG Scale the data in the chart no longer matches the data in the Close Array, and when the drawing of the trendline goes thru .getYcoor it does not get the new logscale Y1/Y2 numbers which result in trendline not drawn to the log scale close. The same trend line co-ordinates work fine in linear but not in logscale.

shouldnt they ??? NOTE: Layout() is called before trendlines are drawn.
Whats the trick in drawing in logscale with linear co-ordinates ???

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-14-2009 07:07
This is not part of chardir: But have you seen any code that allows the png image to be selected and printed via browser ?

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on May-15-2009 01:59
Hi icm63.

Sorry. I am not too sure what do you mean. Sometimes it is difficult to describe graphical things by words. Is it possible to attach an image to help me understand what you mean?

In short, if you use:

X1 = Date1
X2 = Date2
Y1 = 60
Y2  = 100

and if you code is correct (use getXCoor and getYCoor to translate the data coordinate to mouse coordinates), then ChartDirector will plot a straight line that joins (X1, Y1) to (X2, Y2). The axis scaling method (log or linear scale) does not matter.

For printing the PNG, when the user clicks on the image, you can create a web page (eg. pop up a window) that contains just an <IMG> tag with your image, then use the Javascript method "window.print" to print that web page.

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-15-2009 03:33
Sorry I didnt explain myself well enough.

Say on a linear axis for a trendline for a stock like AAPL (Apple Inc), assume chart is .addCloseLine on a FinanceChart

Start Date:01/01/2009
End Date:03/31/2009
Start Value: 120.50
End Value: 135.50

>>GET BAR NUMBERS
StartNumber  = Calc_GetBarNoForDate(CDate(TLStartDate)) - ExtraBars
EndNumber = Calc_GetBarNoForDate(CDate(TLEndDate)) - ExtraBars

>> GET COOR
Dim x1 As Integer = TLLay.getXCoor(StartNumber)
Dim y1 As Integer = TLLay.getYCoor(StartPrice)
Dim x2 As Integer = TLLay.getXCoor(EndNumber)
Dim y2 As Integer = TLLay.getYCoor(EndPrice)


When I draw this on a linear chart the trendline Y1 and Y2 values matches the data in the close() array I sent to the finance chart via .setData.

BUT consider the LOG scale axis. I now have no idea what the Y1 and Y2 will be until after the chart is drawn. As the Y1 and Y2 no longer match the data in the Close() array.

So I need a function that converts my 'Start' and 'End' value 120.50/135.50 (linear) to ???? (Log) so I can draw on the chart. Otherwise I must draw the chart in log, then get the values.

My website stores the trendline data in a database in linear mode (Not log), but I allow users to switch between linear and log chart axis at will, but as the trendline data is stored in linear when ever the trendline data draws on the log scale chart it looks wrong, for the reason that the linear 'StartValue' and 'EndValue' have not been converted to the log scale values. Otherwise, do  I have to store two sets of trendline data one for linear and one for log for the same AAPL chart, just because the Yaxis is a different scale. I dont want to do that ! Is there a function that can convert the linear value to log value so that the correct getYCoor can be found.

Hope this is clear...

I assume I have this correct, I assume .getYCoor function cant convert a linear number to a log number ????

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-15-2009 04:16
Attachments:
Sorry mate I am talking dribble..

The value of close on a chart at any date is still the same value on a linear or a log scale chart, its just that the spaceing between the Y's has changed. And that makes my trend lines look weird.

I have code that draws a channel from three data points.
The first chart is linear, you notice the dash lines are calulated as even divisions between the solid lines. I get the Y1 of high line and Y2 of low line, divide by 3, that gives equal divisions for a linear scale chart. Doing this in log does work as log scale is not linear any more...see the dash lines in the second chart...all gone crazy..as the code use to draw them was based on a linear scale..
Linear001.jpg
Log001.jpg

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-15-2009 06:58
I re-calc the channels using X and Y data and not price..all happy thanks...no need for a response.

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-15-2009 13:51
Attachments:
all the above is sorted !

My goal is to have the date MM/dd/yyyy as a tool tip over the price pivot label in the chart. See yellow image in chart.

the code below gives me the pivots...(for the highs pivots)

        Dim HPiv() As Double
        HPiv = Calc_Pivots(Period, HPrice)

        Dim HLayer As Layer = myXYChart.addScatterLayer(Nothing, HPiv, "", Chart.SquareShape, 1, Chart.Transparent, Chart.Transparent)
        Dim HBox As ChartDirector.TextBox = HLayer.setDataLabelStyle("Arial", 8)
        HBox.setBackground(Chart.Transparent, &HCCCCCCC)
        HBox.setAlignment(2)
        HLayer.setDataLabelFormat("{value|2}")

      ''THE NEXT LINE DID NOT PRODUCE anything
        HLayer.getHTMLImageMap("", "", "title='{x}'")

I know I have nothing loaded in X in .addScatterLayer , but it is a double variable and I want to load a date or string as a date. The scatter layer is on the myXychart on the mainFinance chart.

How do I get the Date in the tooltip in this situation...???
Pivots001.jpg

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on May-16-2009 00:18
Hi icm63,

In your code, you may use {xLabel|mm/dd/yyyy} instead of {x}. The {xLabel} refers to the x-axis label at that point.

Also, you may want to make your scatter symbol bigger. If the symbol is small, the hot spot is small too, so it is hard to catch the mouse.

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-16-2009 01:09
Well still nothing coming thru on the tooltip, no matter what size I make the chartdir.textbox..

My code

        Dim HPiv() As Double
        HPiv = Calc_Pivots(Period, HPrice, 1)


        Dim HLayer As Layer = myXYChart.addScatterLayer(Nothing, HPiv, "", Chart.SquareShape, 1, Chart.Transparent, Chart.Transparent)
        Dim HBox As ChartDirector.TextBox = HLayer.setDataLabelStyle("Arial", 8)
        HBox.setBackground(Chart.Transparent, &HCCCCCCC)
        HBox.setAlignment(2)
        HLayer.setDataLabelFormat("{value|2}")
        HLayer.getHTMLImageMap("", "", "title='{xLabel|mm/dd/yyyy}'")


is it because of this : myXYChart.addScatterLayer(NOTHING...

if so how do I get mm/dd/yyyy into a double array ???

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-16-2009 01:21
I draw the pivots the same time I draw my symbols, before the .layout call. The code is the same for symbols, yet the tooltip works fine on the symbols...what am I missing ?

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-16-2009 02:05
This works, putting the date in the label..

HLayer.setDataLabelFormat("{value|2}  {xLabel|mm/dd/yyyy}")

But this did not work putting a line break in the label.

HLayer.setDataLabelFormat("{value|2} \n  {xLabel|mm/dd/yyyy}")

Q: How does one put a line break in a label ??

NOTE: prefer the tooltip option above. Thanks

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on May-16-2009 02:07
Hi icm63,

Is it possible your symbols are too small, so the hot spot is too small and you cannot position the mouse over the small and invisible hot spot? Please use a bigger symbol. For debugging, please make your symbol visible, so you can be sure where it is.

Dim HLayer As Layer = myXYChart.addScatterLayer(Nothing, HPiv, "", Chart.SquareShape, 20, &Hff0000, &H000000)

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on May-16-2009 02:10
Hi icm63,

Note that you are using the VB.NET programming language, not C# or C++ or Java. The syntax for a linebreak in VB.NET is vbLF. For example:

"aaa" & vbLF & "bbb"

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-16-2009 02:17
Attachments:
Still nothing with the tool tip


        Dim HLayer As Layer = myXYChart.addScatterLayer(Nothing, HPiv, "", Chart.SquareShape, 20, &HFF0000, &H0)
        Dim HBox As ChartDirector.TextBox = HLayer.setDataLabelStyle("Arial", 8)
        HBox.setBackground(Chart.Transparent, &HCCCCCCC)
        HBox.setAlignment(2)
        HLayer.setDataLabelFormat("{xLabel|mm/dd/yy}" & vbNewLine & "{value|2} ")
        HLayer.getHTMLImageMap("", "", " title='{xLabel|mm/dd/yyyy}'")
Pivots1002.jpg

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on May-16-2009 02:31
Hi icm63,

Note that getHTMLImageMap should be setHTMLImageMap instead.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-16-2009 02:11
This is how I place a line break in the label : vb.net

HLayer.setDataLabelFormat("{xLabel|mm/dd/yy}" & vbNewLine & "{value|2} ")

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-16-2009 02:46
all works..thanks...heaps.. have a good weekend !

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-18-2009 05:37
Attachments:
Ok next challenge...pushing the boundaries here I guess..

The image shows two chart layers within a finance chart.
Both Chart1 and Chart2 have the same XAxis, that has been lead from Char1 : Daily bars.

Want I would like to do is have the CHART2 on a different X axis , that is weekly or monthly, while Chart1 is on Daily. See second image.

I tried to run weekly data to the Chart2 XYlayer while chart1 was still on daily data, but nothing game through. Can this be done in a finance chart ??
What are the logic steps to achieve this ???
NextIdea001.jpg
NextIdea002.jpg

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-18-2009 05:40
Also I assume the javascript mouse over ({Xlabel} etc) information to client browser would still work on the weekly data ???

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on May-19-2009 01:38
Hi icm63,

For the weekly/daily data, I think you can draw two separate charts, one with weekly data, and another with daily data. Then you can put one chart on top of the other chart.

For the Javascript mouse over {xLabel}, it works the same way no matter what type of data you are using (both weekly and daily works the same way).

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-19-2009 02:56
Thats what I do with the daily data...

I go ..

DrawLayer = mainChart.addMainChart(IndHeight)
>> mainChart ( is the Finance Chart), DrawLayer is another XYChart
Dim myOHLC As HLOCLayer  = DrawLayer.addHLOCLayer(High, Low, Open, Close, OHLCColor, OHLCColor)

And when I put weekly data into the drawlayer above it does not come through.

So what do I different, to get Weekly data in a separate XY chart layer or is it another separate finance chart layer ???


But hang on I am after this effect..same as the first image on posting May-08-2009 15:06

Main Finance chart OHLC (Daily data)
Indicator RSI underneath..based on main chart
Price chart OHLC WEEKLY data underneath..
Indicator MACD underneath....based on main chart

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-19-2009 03:41
also another question..

In the addOHLC layer,
1) can the distance between the OHLC bars be made wider ?
2) can the actual bar making up the OHLC be made wider

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-19-2009 03:56
Also ..please delete text file on the above posting dated :  May-12-2009 18:51
All fixed there thanks..

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on May-20-2009 01:44
Hi icm63,

To draw 2 charts, one with daily data, and one with weekly data, you need to use two FinanceChart objects.

To configure the distance between the bars or the size of the bars, you may:

(a) Use a larger or smaller chart. A larger chart will have larger distance between the bars, and larger bar size.

(b) Use BaseBoxLayer.setDataGap to configure the gap size.

(c) Use BaseBoxLayer.setDataWidth to configure the bar width. (If the bar is wider, the distance between the bars will be smaller.)

For example, for (b), the code is like:

Dim myLayer As HLOCLayer = myFinanceChartObj.addHLOC(.......)
myLayer.setDataGap(0.5)  '50% gap

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-20-2009 14:55
Do you have this functionality in Chartd

Color opacity

That's when I draw two barlayers/Areas, and the back one is covered over by the front one, but due to the front barlayer opacity I can see the back barlayers formation.

Like see through bar/area layers ??

Please advise ??

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on May-20-2009 17:22
Hi icm63,

Yes. Anything color in ChartDirector can be translucent. For example, &Hff0000 is the red color, and &H80ff0000 is the translucent red (80 is the alpha channel, while ff0000 are the red, green and blue channels). There are some a few examples in ChartDirector that uses translucent colors.

In your case, if you use translucent colors for your bars, they will be translucent.

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-21-2009 03:07
Cool..jes you guys can do it all..

The translucent effect, is it one level or are there different degrees of translucency...like on a scale of 1 to 10

I found the examples of the area and bar, I assume I can make a HLOC layer color translucent as well...

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on May-21-2009 03:40
Hi icm63,

There are 255 levels of transparency, from 0 to 254 (or 00 to FE in hex). For example, in 0x80FF0000, the transparency is 80 (in hex), which is 128, or semi-transparent. If you use 0x20FF0000, the transparency is 20 (in hex), and so it is less transparent than 80, but still slightly transparent. If you use 0x00FF0000 (equivalent to 0xff0000), the transparency is 0, which means the color is not transparent.

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-21-2009 07:02
As far as I can tell form testing, transparency works within the linelayer, arealayer and barlayer BUT NOT the HLOClayer and candlesticklayer in an XYchart structure..is this correct?

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on May-21-2009 18:43
Hi icm63,

That is not correct. Anything that can be colored in ChartDirector can use semi-transparent colors.

Anyway, I do not suggest you to use a semi-transparent color for candlesticks. You can try, and it will work. But then you can see what is actually inside the candlestick.

(Due to the way ChartDirector draws the candlestick, the internal of the candlestick is not exactly empty. Normally, the candlestick is painted by a non-transparent color so you cannot see the internal structure, and it looks like it is empty.)

As an example, you can use the "Simple HLOC Chart" sample code, and change the OHLC symbol colors in the sample code (which are &H008000 and &Hff0000) to &H80008000 and &H80ff0000. You can see the OHLC symbols become semi-transparent.

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-22-2009 02:40
Attachments:
Thanks, yes does help as always..

Question on the meter..

I added the words 'Extreme' using this ..

Dim mt As LinearMeter = New LinearMeter(cWidth, cHeight)

mt.addZone(0, 25, &HFFFFFF, "Extreme")

Q: How does one change the color/style of these labels

I tried mt.setlabelstyle with no luck ??

Or do I have switch to the addtext function ??
Meter001.jpg

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-22-2009 12:17
Attachments:
Missing legend box...this code is not poping it up anywhere !!!!

        Dim AreaWidth As Integer = st.PlotWidth - (Math.Min(CInt(750 * 0.11), 100) + RHSAxisZone)
        Dim AreaHeight As Integer = 450 - 60


    Dim mainXYChart As XYChart = New XYChart(750, 450)
        mainXYChart.setPlotArea(Math.Min(CInt(st.PlotWidth * 0.11), 45), 25, AreaWidth, AreaHeight).setGridColor(GridColor, &HFF000000)
        mainXYChart.setBackground(&HFFFFFF)


        Dim legendBox As LegendBox = mainXYChart.addLegend(350, 20, False, "Arial Bold", 8)
        legendBox.setAlignment(Chart.BottomCenter)
        legendBox.setBackground(Chart.Transparent, Chart.Transparent)
MissingLegendbox001.jpg

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on May-22-2009 18:10
Hi icm63,

For the labels in the zone, as according to the ChartDirector documentation on LinearMeter.addZone, the method will return a TextBox object, and you can use it to fine-tune the appearance of the label.

For example:

Dim t As ChartDirector.TextBox = mt.addZone(0, 25, &HFFFFFF, "Extreme")
t.setFontColor(&HFF0000)

For the legend box, it is hard to know if there is really a legend box in the chart, as you have set the background and the border to transparent. If you do not put anything in the legend box, then you cannot see anything at all, even if the box is there. Have your other charting code put anything in the legend box? (Exactly what do you expect to see in the legend box?)

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-23-2009 01:19
To place items in the legend box manually, I thought the legend box was loaded automatically, the example called "other XY chart Features: Multiple Axes", uses the same code as I have..

' Add a legend box with the bottom center anchored at (300, 80) (top center of
    ' the plot area). Use horizontal layout, and 8 points Arial Bold font. Set
    ' background and border to transparent.
    Dim legendBox As LegendBox = c.addLegend(300, 80, False, "Arial Bold", 8)
    legendBox.setAlignment(Chart.BottomCenter)
    legendBox.setBackground(Chart.Transparent, Chart.Transparent)

But I will have a play with it, thanks.

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-23-2009 03:12
Attachments:
I have built a XYchart that compares stock prices.

I send daily, Weekly and monthly data to it..

I wish to view an X axis that can hold 1000+ records well...

The daily data works fine in small and large data sets ( to a degree), yet the weekly and monthly data goes all nutty..

My code
       'X Axis
        mainXYChart.xAxis().setLabels(Period)
        mainXYChart.xAxis().setMultiFormat(Chart.StartOfYearFilter(), "<*font=Arial Bold*>{value|yyyy}", Chart.StartOfMonthFilter(), "{value|mmm}", 3)
        mainXYChart.xAxis().setMultiFormat(Chart.AllPassFilter(), "-")
        mainXYChart.xAxis().setLabelStyle("Arial", 8, 0, 90)
        mainXYChart.xAxis().setTickLength(2, 0)
        mainXYChart.xAxis().setMargin(MinMargin)


It seams I need more flexible XAxis filters....how does one approach this.. ( this is not in the manual, I thank you for your help).
XAxixFilterIssue001.jpg
XAxixFilterIssue002.jpg

  Re: Next Chart Project - OHLC chart with the works
Posted by albruno on May-28-2009 23:52
Attachments:
ref: x labels

the approach i took was
to by variable determine the scale or view of the chart

i.e. 5 min 30 min 60 min day and so on

and create simple routines for each

where I find the modulo (arithmetic division to determine a remainder)

and make decisions


this is python
using this concept I can skip intervals and print the date or time when i choose


        if Show_DatesOnly == False:  5 min sample
            x = round(abs(int(float(data[1])*.01) -(float(data[1])*.01))*100)

            if (x % bartime_divisor) ==0: #modulo
                if int(data[1]) == 0:
                    labels.append((mm)+ (dd)) # print date instead
                else:
                    labels.append(str(int(data[1]))) # print time
            else:
                labels.append('')

        if Show_DatesOnly:  # 60 min sample
            if int(data[1]) == 0:
                labels.append(str(int(mm))+"/"+ str(int(dd))) # print date instead
            else:
                labels.append('')
cd_5.png

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on May-23-2009 10:49
Hi icm63,

You can say ChartDirector can place the items in the legend box "automatically" (depending on exactly what you mean by "automatically"). However, you still need to include in your code what you want to display in the legend box.

For example, if the three lines are called "Price of Apple", "Price of Oranges" and "Price of Pears", then you must at least tell ChartDirector somewhere in your code that these are the names. If you do not inform ChartDirector the names, ChartDirector cannot "automatically" know what are the names of the lines. (When you add the data set using addLineLayer or addDataSet, have you included the names of the data sets?)

So in programming, even if the feature is "automatic", you may still need to enter the data in your code, configure the automatic features in your code, etc.. Without seeing your other code, it is hard for me to know if you have already entered the data in your code or not.

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-23-2009 10:54
Any ideas how best to filter the X axis...

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on May-23-2009 11:01
Hi icm63,

The usual method is use If/Then statements to test for all possible cases you want to have, and configure all of them. For example, if the date range is longer than a certain time frame, then use yearly labels with stepping. I think there are only a few cases to consider.

You may refer to the FinanceChart source code (included in the ChartDirector download) as a reference. The FinanceChart object can handle intra-day data, to data spanning hundred of years. To configure the x-axis, the total number of cases to consider is only 4.

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-23-2009 11:04
Thanks will do...

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-23-2009 11:19
if ((secondsBetweenTicks > 360 * 86400) || ((secondsBetweenTicks > 90 * 86400) && (
                    timeRangeInSeconds >= 720 * 86400))) {
                    //yearly ticks
                    a.setMultiFormat2(Chart.StartOfYearFilter(), m_yearFormat, tickStep);
                } else if ((secondsBetweenTicks >= 30 * 86400) || ((secondsBetweenTicks > 7 * 86400)
                     && (timeRangeInSeconds >= 60 * 86400))) {
                    //monthly ticks
                    int monthBetweenTicks = (int)(secondsBetweenTicks / 31 / 86400) + 1;
                    a.setMultiFormat(Chart.StartOfYearFilter(), m_firstMonthFormat,
                        Chart.StartOfMonthFilter(monthBetweenTicks), m_otherMonthFormat);
                    a.setMultiFormat2(Chart.StartOfMonthFilter(), "-", 1, false);
                } else if ((secondsBetweenTicks >= 86400) || ((secondsBetweenTicks > 6 * 3600) && (
                    timeRangeInSeconds >= 86400))) {
                    //daily ticks
                    a.setMultiFormat(Chart.StartOfMonthFilter(), m_firstDayFormat,
                        Chart.StartOfDayFilter(1, 0.5), m_otherDayFormat, tickStep);
                } else {
                    //hourly ticks
                    a.setMultiFormat(Chart.StartOfDayFilter(1, 0.5), m_firstHourFormat,
                        Chart.StartOfHourFilter(1, 0.5), m_otherHourFormat, tickStep);
                }
            }
        }

Is this the code you refer to, me thinks !! Ha

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on May-23-2009 22:20
Hi icm63,

Yes. The code (and the associated code that defines what is "secondsBetweenTicks", etc) are designed to handle an intraday chart up to a chart spanning thousands of years, in a plot area that can be as small as 300 pixels wide to thousands of pixels wide, with everything (the date format used in each case) configurable using API.

I believe you can simplify the code if you do not need to handle all these cases.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-26-2009 07:09
Attachments:
ERROR : Negating the minimum value of a twos complement number is invalid.

As you can see this is within Chart director....v5.

I am going to have send you a mock up of my project so you can debug it, please advise of email address to send it to. I can load the mock project on a sharing site called screencast.com where you can download from, and I send you the download sharing link. I cant place the link on this forum as it is public. Please email me via the address on this posting, with an email address I can set the link to.

NOTE: I tried to run the project with showtext removed, and replaced with "", no difference the same error.
Error001.jpg

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on May-26-2009 20:54
Hi icm63,

You may email to pkwan@advsofteng.net.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-27-2009 05:58
I have email you...

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on May-27-2009 22:02
Hi icm63,

I have not actually trying to run your code in our development computer (so we can debug at source code level), because our company does not allow us to install the third party software you are using on it (without going through a review process).

Anyway, by reading the code and the error message again and again, and look through our source code, our developers think for some reason a "non-plottable point" is included in generating the image map, and this cause the error. A "non-plottable point" is a point that cannot have a coordinate, such as a NoValue point, or a negative or zero value point in a log scale axis, etc.. ChartDirector should have removed those points before producing the image map, but it is possible some of them slip through the checking code.

We have tried to artifically insert some non-plottable point into the code, and it does result in the same error your see in the .NET platform (while no error is produced in other languages).

We have then created a patch that we hope should catch all non-plottable points. The patch is an updated "netchartdir.dll" and is at:

http://www.advsofteng.com/netchartdir501p1.zip

Please kindly try the above patch to see if this can solve the problem.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-28-2009 01:48
Thanks, not yet fixed, I have emailed you a zip file

cheers

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on May-28-2009 03:47
Thanks all fixed...my code and a little patch by ChartD fixed it all up !

Thanks Peter, once again !

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Jun-02-2009 14:19
Attachments:
HI,

I add symbols to my chart via a scatter layer for each symbol added...I have multiple symbols added.

I also have an indicator that has linelayers and interlinelayers.

I do know that if I draw the symbols (scatterlayer) first, before the indicator (linelayer/interlinelayer) the symbols will be ontop of the indicator. But my code is such that it is not, and it would take some work to swap it around.

Is there a Zorder or something that I can make sure the symbols are always on top, no matter the code order of how the symbols and indicators are drawn??

see this effect I am trying to fix
SymbolEffect001.jpg

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Jun-02-2009 19:27
Hi icm63,

In ChartDirector 5.0, you may use Layer.moveFront to move a layer to the front.

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Jun-04-2009 06:33
Attachments:
Is it possible from this code to include the X, Y coord of the mouse over action

Dim showText As String = "onmouseover='ShowChartDataVOL1(""{xLabel|mm/dd/yyyy}"",""{value|2}"",""{high|2}"", ""{low|2}"", ""{open|2}"", ""{close|2}"");'"

So the info in the image reads  like ( without having to do javascript excersise oustide the function above, but if you do, do you have this code ?)

Data (X:45,Y:105): H:$78.27.....etc
XYcoords001.jpg

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Jun-04-2009 22:07
Hi icm63,

It is not possible for ChartDirector, which works on the server side, to know the mouse positions, which are on the browser side. You would need to use browser side code (that is, Javascript), to get the mouse positions.

The exact code depends on what type of mouse coordinates you are referring to (relative to the chart, or to the chart's container such as a <DIV> block, or to the browser window, or to the web page, or to the screen, etc), and depends on the browser brand and version. You would need to refer to your Javascript and HTML documentation for details.

In any case, I think you should pass the Javascript event object to ShowChartDataVOL1, otherwise all mouse information is lost.

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Jun-10-2009 08:35
Attachments:
You supply a file called FinChartC#.txt with ChartDir.

I Converted this file to vb.net via this converter:

http://www.developerfusion.com/tools/convert/csharp-to-vb/

However there errors thru it, when I run with indicators etc

DO you have a vb.net finance chart version somewhere, if not can you create one or convert the one I supplied into a working format ?

I assume I can use this code for :
1) add my own custom like addMyCustomIndicator, so I dont have to build a whole new xychart for each new indicator
2) does exactly the same as addFinanceChart in the base dll.

Please advise ...
FinChartC#.txt
FinChartC#.txt

109.21 Kb
FinChartVB.txt
FinChartVB.txt

115.27 Kb

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Jun-10-2009 08:44
also vb.net code with these two turned on

Option Strict On
Option Explicit On

Gives more errors

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Jun-10-2009 20:56
Hi icm63,

We cannot support code that is not written by us. I am worry you would need to debug the code created by "csharp-to-vb" yourself.

The FinanceChart source code is written in C# because ChartDirector is written in C#. We do not have a version of FinanceChart written in VB.NET.

If you want to modify the FinanceChart source code, you may modify the C# source code. It does not matter whether your own code is written in VB.NET or C# or any other language. For example, the entire ChartDirector is written in C#, and it still works perfectly fine with your VB.NET program. As long as the code is CLR compliant (which ChartDirector is), it can interoperate with any CLR compilant languages. However, it does mean you need to know how to write C#.

(In general, if you need to modify the source code of another library, you would need to know the programming language that is used to write the library.)

If you like, you can add a "addMyCustomIndicator" method to the source code, or any other method you like.

There is no "addFinanceChart" method in the base dll. However, there are many other methods. If you copy the code in those methods to your own code, it would do "exactly the same" in your own code.

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Jun-11-2009 01:45
Ok...

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Jun-12-2009 04:09
Attachments:
In this chart I have

Dim mainChart As FinanceChart = New FinanceChart(st.PlotWidth)
Dim mainXYChart As XYChatr = mainChart.addMainChart(FinHeight)
mainXYChart.setClipping()

As you see in the image the moving averages still draw in the area they should not !

Of course I draw the moving average like this .addSimpleMovingAvg from within the Finance Chart class, not XYChart class (XYchart does not have the indicator functions).

NOTE: FnChart As FinanceChart

FnChart.addSimpleMovingAvg(nd.iMAPeriod1, adjColorMA1)

But as the FinanceChart does not have .setClipping() function how can I tidy up the moving averages overlap...
MovAve001.jpg

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Jun-12-2009 07:34
Hi icm63,

The function of setClipping is to clip the moving average lines to the plot area. The lines are in fact well within the plot area, so setClipping is working normally.

Note that the moving average lines can overlap with other objects that are also inside the plot area. The legend box is inside the plot area, so they can overlap with the legend box.

ChartDirector will put the legend box on top, so the lines are under the legend box. They are still visible because your legend box is configured with a semi-transparent background color. If you want to hide them, you can use a non-transparent background color.

mainChart.getLegend().setBackground(&Hdddddd, &Hdddddd)

Hope this can help.

Regards
Peter Kwan

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Jun-12-2009 08:18
ChartD rocks !

This worked for me !

mainXYChart.getLegend().setBackground(&HDDDDDD, &HDDDDDD)

Thanks

  Re: Next Chart Project - OHLC chart with the works
Posted by icm63 on Jun-23-2009 11:16
Attachments:
HI,

Issue with linear scale on an custome indicators on XYCharts


'Top indicator looks fine, ranges from 0 to 100 - GOOD !
c.yAxis().setLinearScale(0, 100)

'Bottom indicator ranges from -50 to 150, when -5 to 105 was required only.
c.yAxis().setLinearScale(-5, 105)

QUESTION : How do I make the bottom indicator tidy, like the top indicator ?

Thanks
LinearScale001.jpg

  Re: Next Chart Project - OHLC chart with the works
Posted by Peter Kwan on Jun-23-2009 21:50
Hi icm63,

As explained in the ChartDirector documentation on Axis.setLinearScale, if you only specific two parameters in setLinearScale, ChartDirector may adjust the scale. By default, ChartDirector will extend the scale if necessary to make sure the axis end points is at a label position. For example, if you specify the scale to be 1.35702 to 98.3998, ChartDirector may adjust the scale to 0 - 100.

In your case, if you want the scale to be absolute at the value you specified, you may use:

//specify all 3 parameters
c.yAxis().setLinearScale(-5, 105, 22)

or

//do not extend the scale to ensure the axis end points is at a label position
c.yAxis().setRounding(false, false)

Hope this can help.

Regards
Peter Kwan