Author |
Topic: OnPriceChanged Event (8 messages, Page 1 of 1) |
||||
---|---|---|---|---|---|
Moderators: VPfau | |||||
estrader Posts: 55 Joined: May 04, 2007 |
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 |
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 |
Can you offer any suggestions on how this is done?
|
||||
SergeK -Developer- Posts: 475 Joined: Jan 26, 2007 |
For example, you can store old TotalVolume and compare updated value with stored value.
|
||||
estrader Posts: 55 Joined: May 04, 2007 |
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 |
I am sorry, but this forum is intended for API-related issues, not compile or syntax errors.
|
||||
alberte Posts: 1 Joined: Jun 02, 2007 |
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 |
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.
|
||||