I am coding a sophisticated strategy that depends on data from indicators. The reason why I've set things up this way is so that my custom indicators can draw their many curves onto their own chart pane instead of being overlaid on the main chart.
Many times I have run into what I think are threading issues between my custom indicators and my custom strategy. For example if my strategy is at bar 1234 (CurrentBars[0] == 1234) and requests the data from the indicator it owns for its data, that indicator may or may not be at the right bar... many times it's at bar 1, and sometimes some bar behind. (I see this when I print my strategy and indicator's CurrentBars[0] and they are frequently out of sync.
I assume that my strategy and indicators run on different threads and that I need thread synchronization techniques for my strategy to access indicator data safely...
Perhaps it is inappropriate for my strategy to instantiate my custom indicators and call its public functions?
Could you steer me toward the proper way for a strategy to instantiate a slave indicator and how to safely access its public data?
Many thanks!
Comment