Support Board
Date/Time: Tue, 26 Nov 2024 08:43:07 +0000
Post From: [shared] persistent variables vs study inputs vs direct sc methods (for 2+ studies)
[2023-12-20 22:06:15] |
User133994 - Posts: 80 |
Support, The goal: share state between 2 bots each on it's own chart and own account. For example: chart 1: bot1study, trading on account1 chart 2: bot2study, trading on account2 Currently I'm using various combinations (whatever I can get to work) to share state between bot1/bot2 studies. Bot1 needs to know about bot2's position, phase (custom logic), and other variable. Similarly, Bot2 also depends on Bot1's account position status, phase (custom logic), and other variables. Right now I'm having issues sharing bot1's account positiondata (i.e. just an integer) with bot2. The update is 3 bars behind reality? It took about 2 minutes for 3 bars to complete...so there was plenty of price updates to allow for the persistent shared variables to update. I use autoloop=1 on both studies. I can see the position on the top chart, but the bottom chart wouldn't register it until 3 bars/2 minutes later. I was using Chart Study Persistent Variable Functions and had to switch to Automated Trading From an Advanced Custom Study: sc.GetTradePositionForSymbolAndAccount() to get "real-time" responsiveness that the persistent variables approach didn't have. Don't know why the direct method worked better? There is a 3rd method to share data between the 2 studies: sc.GetStudyArraysFromChartUsingID() (or one of the variants). From my experience this method seems most reliable--works as expected most of the time. All 3 seem to accomplish the same task in various ways, however, I'd prefer persistent shared variables, except the performance is lacking. Has anyone else has the same problem? It seems like I'll have to revert back to using sc.GetStudyArraysFromChartUsingID() as this method seems to "always" work as expected. And, since bot1 refers to bot2 and bot2 refers to bot1 to make decisions there can be the appearance of an endless loop that never catches up; however, I've not designed it that way. There are discrete phases that interact with each other and do not cause any race conditions. Nonetheless, perhaps someone has another idea/method that would better suited for this goal of sharing state across 2 different charts/accounts/studies. Would someone please share your ideas on why persistent shared variables work sometimes as expected; and, other times appear to be underperformant? Also, would someone recommend the proper context for each method (a) shared persistent variables vs (b) shared study arrays vs (c) direct sc methods--or should they all work equally well when sharing states of variables (i.e. float/int, etc.) between 2 different studies on 2 different charts using 2 different trading accounts? Thanks in advance. Date Time Of Last Edit: 2023-12-20 23:19:08
|