Dresden + Germany
Posts: 21 since Feb 2018
Thanks Given: 11
Thanks Received: 5
|
Hello LukePoga,
Thanks for the hint.
In the meantime, I've learned that threadsafe is probably the wrong name.
I calculate values in periods whose beginning and end are indefinite. At the end of the period I would like to do another calculation;
because the condition is wrong at this time, I need to access the predecessor value.
In real-time operation, this condition is true for one bar, but the condition should only be true for a tick to execute the calculation once.
These 5 calculations are performed with different values and periods and all five should access one method.
I understand that I can initialize variables and series outside the method.
Then both the counter and the return of the previous value will work.
In my example barCounterF () and barCounterThread () I increase the same variable barCounterFuncIn once by 1 and once by 2 and return it.
Although I assign a different variable (functionValue1 and functionValue2) to the respective return value, the methods influence each other.
If I change the barCounterThread () method to another variable e.g. assigning barCounterFuncIn1, both methods provide the correct result.
I added the code for verification.
If I want to simplify my code, this must not happen. It also makes no sense to use exactly the variables and series that I would have to use without any method.
Where is my mistake?
Best
user10
|