I've got a question regarding the ways of exchanging data between a strategy and an indicator. The indicator is processing things and storing potential signals in a global variable. I've checked the few posts to be found on the net and here as well, also of course the PDF containing little documentation regarding the GV. I know that Global Variables are not part of Multicharts but important for some things when developing indicators and strategies and many user are interested in using them. So I hope I can address the problem here. I will start explaining what I did followed by the actual problem.
Since a few years I use global variables and it works quite well. At the moment I use the methods and the similar methods for Int (which has no impact on the problem)
Code: Select all
GVSetNamedDouble(tpGlobalVar, tpPrice); GVGetNamedDouble("S8_M5_TP", -1);
Now I wanted to add GV to my strategies storing signals in GV in order to fetch them later on in my strategy. I came upon strange behavior looking like a binding or threading problem. The code in the indicator is like this and the problem occurs already on this side where I store the value.
Code: Select all
variables: signalVal ( 0 ), hasLongSignal ( false );
if hasLongSignal = true then signalVal = 5
else signalVal = 8;
// GVSetNamedInt(signalName, _Bool2Int(hasLongSignal)); // Original idea but always stores 0
// GVSetNamedInt("SignalX", signalVal);
AccuracySetNamedInt("SignalX", signalVal); // all variants I've tried store a value where hasLongSignal is false, even if hasLongSignal is true, so here always 8, never 5
// Shows always the correct value, sometimes 1 and sometimes 0 depending on hasLongSignal
Commentary("# Signal=" + NumToStr(_Bool2Int(hasLongSignal), 0));
I wanted to avoid storing the signals into a time series or using my interop-lib to change data between code but I have no clue what is wrong here or whether I missed some important piece when using the GV or Accuracy-Methods.