API Support Forum
OEC API > API Support > OnPriceChanged Event
Author Topic: OnPriceChanged Event
(8 messages, Page 1 of 1)
Moderators: VPfau
estrader
Posts: 55
Joined: May 04, 2007


Posted: May 09, 2007 @ 08:43 AM             Msg. 1 of 8
I want to update a list window under certain conditions. However even though the 'if' condition works, I get repetitive displays because the event is run on any change. Is there anyway to make the event run only on a Total Volume change? I noticed this was a problem with the volume displayed in charts on a tick. That seems to be fixed.

Here is my code:

private void oecClient1_OnPriceChanged(OEC.API.Contract Contract, OEC.API.Price Price)
{
if( Contract == cbContract.SelectedItem )
UpdatePrice( Contract );


float volume = float.Parse(textVolume.Text);




if ((Contract.CurrentPrice.LastVol) >= volume)
{
lbOrders.Items.Add(Contract.CurrentPrice.LastVol);

lbOrders.Items.Add(string.Format("Last Price: {0}",
Contract.PriceToString(Contract.CurrentPrice.LastPrice)));

lbOrders.Items.Add(string.Format("Last Time {0}",
Contract.CurrentPrice.LastDateTime));


}


}
SergeK
-Developer-
Posts: 475
Joined: Jan 26, 2007


Posted: May 09, 2007 @ 08:56 AM             Msg. 2 of 8
There is no option to change behavior of the OnPriceChanged event in the OEC API - you have to check whether volume is changed by yourself.
estrader
Posts: 55
Joined: May 04, 2007


Posted: May 09, 2007 @ 03:47 PM             Msg. 3 of 8
Can you offer any suggestions on how this is done?
SergeK
-Developer-
Posts: 475
Joined: Jan 26, 2007


Posted: May 09, 2007 @ 03:53 PM             Msg. 4 of 8
For example, you can store old TotalVolume and compare updated value with stored value.
estrader
Posts: 55
Joined: May 04, 2007


Posted: May 09, 2007 @ 04:22 PM             Msg. 5 of 8
Thanks. I have been trying to do this but I am still having trouble with the syntax.

I have tried the following but get a compile error "The name 'preVolume' does not exist in the current context"



private void oecClient1_OnPriceChanged(OEC.API.Contract Contract, OEC.API.Price Price)
{
if( Contract == cbContract.SelectedItem )
UpdatePrice( Contract );

int volume = int.Parse(textVolume.Text);

//display

if (prevVolume != (Contract.CurrentPrice.TotalVol))
{

if ((Contract.CurrentPrice.LastVol) >= volume)
{

lbOrders.Items.Add((string.Format("Time {0}",
Contract.CurrentPrice.LastDateTime.ToLocalTime())) + " " +

(Contract.CurrentPrice.LastVol) + " " +

(string.Format("Price: {0}",
Contract.PriceToString(Contract.CurrentPrice.LastPrice))) + " " +


(Contract.CurrentPrice.TotalVol));

//display

int prevVolume = (Contract.CurrentPrice.TotalVol);
}

}
}
SergeK
-Developer-
Posts: 475
Joined: Jan 26, 2007


Posted: May 30, 2007 @ 02:00 PM             Msg. 6 of 8
I am sorry, but this forum is intended for API-related issues, not compile or syntax errors.
alberte
Posts: 1
Joined: Jun 02, 2007


Posted: Jun 02, 2007 @ 11:38 AM             Msg. 7 of 8
estrader,

I see your compile problem. If you haven't solved your "non-forum" issue yet, I can help you solve it in a different venue.
estrader
Posts: 55
Joined: May 04, 2007


Posted: Jun 04, 2007 @ 04:55 PM             Msg. 8 of 8
Thanks, but I eventually solved it. I needed to do a few C# tutorials but I got there in the end. Next task is working out how to send cancel and modify orders.