Login Page - Create Account

Support Board


Date/Time: Fri, 29 Nov 2024 08:25:12 +0000



Post From: persistent variables simultaneous assignments between charts? (across 2+ chart threads..)

[2023-03-02 05:41:08]
User133994 - Posts: 80
Support,

I assume each chart has its own thread...so that means there is a possibility of simultaneous assignments to persistent variables using a sc.SetPersistent*ForChartStudy function on 2 different charts which reference the same persistent variable (i.e. shared variables).

From here:
Chart Study Persistent Variable Functions

Your documentation says:
If setting or getting a persistent variable in another chart (Source chart), then when that Source chart is updated for any reason, the chart that made the reference to it (Destination chart), will have its studies calculated. In this way your study on the Destination chart will be aware of the changes to the persistent variable in a Source chart. When running a multiple chart Back Test, charts will be calculated in the proper order as well.

Can you please elaborate how, for example, these simultaneous assignment operations won't collide:

source chart #1 with source persistent variable A:
@1:00:00 uses sc.SetPersistent*ForChartStudy on variable A to set it to 34

destination chart #2 with reference to source's persistent variable A:
@1:00:00 uses sc.SetPersistent*ForChartStudy on variable A to set it to 100

which SetPersistent will win? 34 or 100? what will be persistent variable A's value @1:00:01? will it be the same on chart #1 and #2 @1:00:01? what if chart #1 is an 88 trades (tick) chart and #2 is a 5 min chart, and it just so happens they both want to set persistent variable A at the same time, does that change anything?

Maybe I am misunderstanding how the chart threading works or persistent variable assignments work across charts?

An example explaining how/why this will never occur would also be helpful--if that is the case.

Perhaps you have an internal locking mechanism that avoid these scenarios; or, you have designed around it. Please let me know the design or locking mechanism so I can use it properly. Maybe it is built-in to the ACSIL system and I'm missing it.

Thanks in advance..