Login Page - Create Account

Support Board


Date/Time: Mon, 06 May 2024 01:45:09 +0000



Post From: strange behaviour of sc.GetTradeListSize() call

[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