Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Attached is a strategy that shows a conundrum (for me).
I have a List of Struct....
If the elements of the List Struct are Private I cannot access them inside the strategy..."inaccessible due to its protection level" compiler error. Not sure why.
When the code is as is, it will compile.
BUT when I load multiple instruments in Strategy Analyzer with this strategy, the list acts like it is global...i.e. public.
If you run this strategy against multiple instruments at the same time in Strategy Analyzer, for every 10 bar it will print (for each instance) the List.
As you would see, the list for any instrument shows the data loaded by the last strategy to execute. In other words, it is acting like a public list...
Probably the answer is to have the Struct elements Private...but then it won't compile...
It is the same if I change the Struct to a Class.
There must be some simple nuance I'm missing...can anyone tell me how to fix this?
Many thanks!
Can you help answer these questions from other members on NexusFi?
Your problem is due to the fact you create it as a static, static means it has no instantiation
and it's shared across multiple, making different strategies overwrite the same object.
If you create the list as a static, you are referring to the same memory in all
indicators/strategies that call it.. (google c# static for class, members .. it will
be explained in more detail
Without the static, the new creates a new object, that is different for every
invokation