Page 1 of 1

Candle problem.

Posted: Fri Jul 02, 2004 1:40 pm
by 9082121
Hello All!
I was faced with some problem using candle series - when candle style is line, there is some kind of clipping while drawing line segments.
Looks like TChart draws candle line segment only if begin and end points of line segment are visible. It does not looks good. When I scroll or zoom candle-line, sometimes I get void graphic areas instead of candle line.
Is there any solution to my problem?

Best regards. Yushchenko Y.A.

Posted: Fri Jul 02, 2004 7:16 pm
by Pep
Hi Yuri,

this is as designed. As I know there's no way to change this. I'll add on our wish list (the ability to change this) to be considered for the next releases.

Posted: Tue Jul 13, 2004 7:20 pm
by 9082121
Oki... Maybe I can fix this using another series when I wish to display tick graphic. That not a big problem.
But I have some other problem with candle series.
I develop financical chart using TChart. It is necessary for me to hide `weekends`(lot of white space) -- So I used solution similar to recommended in `Tchart5 feature demo->new features->series->Candle->Axis no weekends`. I was just setted Buttom Axis DateTime propepty to false, increment to 1, and style to Mark. So, when I add a new point to graphic, I just do like this:
int count = Series(0).GetCount()
AddCandle(count+1, high,low,open,close)

Series(0).SetPointLabel(count,stringmark);
where stringmark is encoded date-time value string like `10.6.2004'

But what can I do with functions using that candle series as datasource????
I mean ..... using of financical functions are not correct with such series as datasource.
Ofcourse, I can create another `regular` Candle series with regular Date-time x-values and use it as datasource. But my financical chart must support multiple chart windows with corresponding zoom and scroll. It will be possible only if there is some `visible-relation` between points in all chart windows. But there is no visible relation between regular-candle series function and no-weekends candle series.

I think the only way to solution is somehow to `move` points of regular candle series function to hide points corresponding to white spaces .
So.... I need help.
How can I make my financical indicators correctly displayed?

PS:
Sorry for bad english.
Best regards Yuri.

Posted: Wed Jul 14, 2004 7:51 am
by Chris
Hi Yuri,
How can I make my financical indicators correctly displayed?
Have you tried adding a financial indicator to the example you mention? The following code works as expected here:

Code: Select all

Dim NotDateTime As Boolean

Private Sub Check1_Click()
  If Check1.Value = 1 Then
    AddAsNoWeekend
    AddFunction
  Else
    AddAsDatetime
    AddFunction
  End If
End Sub

Private Sub Form_Load()
  TChart1.Aspect.View3D = False
  AddAsNoWeekend
  AddFunction
End Sub

Private Sub TChart1_OnAfterDraw()
Dim i

  If NotDateTime = True Then
    With TChart1
      ' Contain output within Chart rectangle
      .Canvas.ClipRectangle .Axis.Left.Position, _
                            .Axis.Top.Position, _
                            .Axis.Right.Position, _
                            .Axis.Bottom.Position
      '.Canvas.Font.Bold = True
      .Canvas.Font.Color = vbYellow
      For i = 0 To .Series(0).Count - 1
        If Weekday(DateValue(.Series(0).PointLabel(i))) = 2 Then
          .Canvas.RotateLabel .Series(0).CalcXPos(i - 1) + ((.Series(0).CalcXPos(i) - .Series(0).CalcXPos(i - 1)) / 2) - 5, .Axis.Bottom.Position - 10, "eg. Weekend", 90
        End If
      Next i
    End With
  End If
End Sub

Private Sub AddFunction()
With TChart1
    .Axis.RemoveAllCustom
    .Axis.Left.EndPosition = 60
    .AddSeries scLine
    
    .Series(1).VerticalAxisCustom = .Axis.AddCustom(False)
    .Axis.Custom(0).Otherside = True
    .Axis.Custom(0).StartPosition = 60
    
    .Series(1).SetFunction tfMACD
    .Series(1).DataSource = .Series(0)
    .Series(1).FunctionType.asMACD.Histogram.Active = True
    .Series(1).FunctionType.asMACD.MACDExp.Active = True
    .Series(1).FunctionType.Period = 26
    .Series(1).FunctionType.asMACD.Period2 = 12
    .Series(1).CheckDataSource
End With
End Sub

Private Sub AddAsDatetime()
Dim tmpopen, tmp As Integer
  ' This option simulates a sequential datetime Axis
  ' Candle Series
  NotDateTime = False
  TChart1.RemoveAllSeries
  TChart1.AddSeries (scCandle)
  TChart1.Axis.Bottom.Labels.Angle = 90

  With TChart1.Series(0)
    .Clear
    tmpopen = 1000 + Rnd(100)
    For t = 0 To 14
      tmp = Int(100 * Rnd - 50)
      .asCandle.AddCandle Format(Now - 15, "000000") + t, tmpopen, tmpopen + 20, tmpopen - 20, tmpopen + tmp
      tmpopen = tmpopen + tmp
    Next t
  End With
End Sub

Private Sub AddAsNoWeekend()
  'Create an array of example dates
Dim myDates(14) As Variant
Dim StartDate As Date
  ' If this were to have a database datasource it would be simpler
  ' as you could use Series(xx).LabelsSource
  ' If using ADO Recordset the following principle would apply, replacing the
  ' Array with a step-through the Recordset
  NotDateTime = True
  StartDate = Now - 15
  For i = 0 To 13
    While (Weekday(StartDate) = 1) Or (Weekday(StartDate) = 7)
      StartDate = StartDate + 1
    Wend
    myDates(i) = Format(StartDate, "d-mmm-yyyy")
    StartDate = StartDate + 1
  Next i
  TChart1.RemoveAllSeries
  TChart1.AddSeries scCandle
  With TChart1.Series(0)
    .XValues.DateTime = False
    .Clear
    tmpopen = 1000 + Rnd(100)
    For t = 0 To 8
      tmp = Int(100 * Rnd - 50)
      .asCandle.AddCandle 1 + t, tmpopen, tmpopen + 20, tmpopen - 20, tmpopen + tmp
      .PointLabel(t) = myDates(t)
      tmpopen = tmpopen + tmp
    Next t
  End With
End Sub
You will find that all of TeeChart's financial functions make calculations on the OHLC values only. The date values are not used in calculations unless the ITeeFunction.PeriodStyle property is set to psRange (see Help files for details).

Posted: Thu Jul 15, 2004 8:01 pm
by 9082121
Thanks, Christopher. Your example solves my problem.
But.. I want to ask you one more little thing...
When I add function, I set labels for each point and I set bottom axis style to `Text`.
Well, it works fine. Labels are shown. But when I try to change some function property (i.e. period or style for RSI function),labels dissapears and appears only after zoom-scroll.
In other hand when I work with MACD function, MACD period 1 change causes hides labels, but change of period 2 causes labels appear again.
Why so?
How can I make my labels always shown? I tried to use Repaint() and it works fine, but too slow. Is there any other way ?

Best regards, Yuri.
PS: Thanks for your attention - Steema support works just great!

Posted: Fri Jul 16, 2004 7:48 am
by Chris
Hi Yuri,
But.. I want to ask you one more little thing...
When I add function, I set labels for each point and I set bottom axis style to `Text`.
Well, it works fine. Labels are shown. But when I try to change some function property (i.e. period or style for RSI function),labels dissapears and appears only after zoom-scroll.
In other hand when I work with MACD function, MACD period 1 change causes hides labels, but change of period 2 causes labels appear again.
Why so?
How can I make my labels always shown? I tried to use Repaint() and it works fine, but too slow. Is there any other way ?
Would you be so kind as to send me a simple project which I can run "as-is" to reproduce your problem here?
You can post your project to:
news://www.berneda.com/steema.public.attachments
PS: Thanks for your attention - Steema support works just great!
You're welcome :)