API Support Forum
OEC API > Market Data > Does any one have a example of using the excel .com sample SubscribeBars?
Author Topic: Does any one have a example of using the excel .com sample SubscribeBars?
(1 messages, Page 1 of 1)
Moderators: VPfau
LMaher457
Posts: 1
Joined: Mar 10, 2015


Posted: Mar 16, 2015 @ 03:12 PM             Msg. 1 of 1
This is as far as I got:

Sub UpdateQuotes(newContract As OECAPICOM.contract)

If Not (CurrentContract Is Nothing) Then
api.UnsubscribeBars CurrentContract
End If
Set CurrentContract = newContract
If Not (CurrentContract Is Nothing) Then

api.SubscribeBars CurrentContract, TimeValue(Hour(Now) & ":" & Minute(Now) & ":00") - TimeSerial(2, 0, 0), 1

Dim i As Integer
Dim Bars() As OECAPICOM.Bar

Set Bars() = api.Subscriptions.??

Range("A16:D2895").ClearContents

i = 16
For Each OECAPICOM.Bar In Bars

Range("B" & i) = CurrentContract.StringToPrice(Bar.High)
Range("C" & i) = CurrentContract.StringToPrice(Bar.Low)
Range("D" & i) = CurrentContract.StringToPrice(Bar.Close)
i = i + 1

Next Bar
End If


End Sub

Leonard Maher