Login Page - Create Account

Support Board


Date/Time: Wed, 24 Apr 2024 16:02:02 +0000



[Programming Help] - strange behaviour of sc.GetTradeListSize() call

View Count: 774

[2018-01-13 13:57:40]
User436155 - Posts: 16
hi there,

in my study i am sending information about trades to external server. i expect following scenario: i turn on platform and load chart with study which should send information about trades i will place to the server.

the script is working fine but in some cases i get not relevant data about trades from past. i did not know why and how but i found out following statement one day.

source code:
log_info.Format("Last trade: %d List size: %d", last_trade, sc.GetTradeListSize());

provided this output:
Chart: F.US.ENQH18 2 Min #5 | Study: Important Zones | Last trade: 0 List size: 0 | 2018-01-12 09:29:19
Chart: F.US.ENQH18 2 Min #5 | Study: Important Zones | Last trade: 0 List size: 0 | 2018-01-12 09:30:07
Chart: F.US.ENQH18 2 Min #5 | Study: Important Zones | Last trade: 0 List size: 0 | 2018-01-12 09:31:11
Chart: F.US.ENQH18 2 Min #5 | Study: Important Zones | Last trade: 0 List size: 0 | 2018-01-12 09:32:15
Chart: F.US.ENQH18 2 Min #5 | Study: Important Zones | Last trade: 0 List size: 0 | 2018-01-12 09:33:03
Chart: F.US.ENQH18 2 Min #5 | Study: Important Zones | Last trade: 0 List size: 2 | 2018-01-12 09:33:35
Chart: F.US.ENQH18 2 Min #5 | Study: Important Zones | Trades to process: 2 | 2018-01-12 09:33:35
Chart: F.US.ENQH18 2 Min #5 | Study: Important Zones | Last trade: 0 List size: 2 | 2018-01-12 09:34:07
Chart: F.US.ENQH18 2 Min #5 | Study: Important Zones | SKIP index: 0 | 2018-01-12 09:34:07
Chart: F.US.ENQH18 2 Min #5 | Study: Important Zones | SKIP index: 1 | 2018-01-12 09:34:07
Chart: F.US.ENQH18 1 Min #5 | Study: Important Zones | Last trade: 0 List size: 2 | 2018-01-12 09:34:23
Chart: F.US.ENQH18 1 Min #5 | Study: Important Zones | SKIP index: 0 | 2018-01-12 09:34:23
Chart: F.US.ENQH18 1 Min #5 | Study: Important Zones | SKIP index: 1 | 2018-01-12 09:34:23

variable 'last_trade' is persistent variable which has index of sc.GetTradeListSize() call at the beginning (initialization of study). its value is OK all the time.

'sc.GetTradeListSize()' call is 0 at the beginning. i check it for a change to get information about new trades to send. if there is a new trade the result will be a positive number and i will process new indices of trades and remember indices to skip (already processed trades).

but after few minutes the result of 'sc.GetTradeListSize()' call somehow changed its value to 2. but there were NO trades at all. my study processed those 2 trades and sent the data to server. but those data were irrelevant.

am i doing anything wrong? because i have no idea what is the reason of spontaneous change of the result of 'sc.GetTradeListSize()' call and how i can avoid it. the occurrence of this behaviour is rare but exists.

thank you for your help. have a nice day.

best regards
Jan
[2018-01-14 00:34:46]
Sierra Chart Engineering - Posts: 104368
We added this to the documentation:
The size returned by this function can change upon the following conditions: A fill for the Symbol and Trade Account of the chart the study instance is on, occurs in real time. The Symbol of the chart changes. The Trade Account of the chart changes. After connected to the data feed, new order fills are received for the Symbol and Trade Account of the chart. Historical order fills are received during the connection to the trading server at some other time.

Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account