Hi,
I am using a global which corresponds to a boolean value in C#.
I find that I am not able to use the statement:
SetGlobal("inside1MRunGlobal", inside1MRunPrevious);
In the defs section. i use such statements in the init section.
But there is one corner case (start a stream run in middle of a market session) that is left out.
For this case (which will not happen often) I need to rely on the value of the global at strategy load. Can I assume that it will correspond to a false?
Thanks!
I am using a global which corresponds to a boolean value in C#.
I find that I am not able to use the statement:
SetGlobal("inside1MRunGlobal", inside1MRunPrevious);
In the defs section. i use such statements in the init section.
But there is one corner case (start a stream run in middle of a market session) that is left out.
For this case (which will not happen often) I need to rely on the value of the global at strategy load. Can I assume that it will correspond to a false?
Thanks!
Rename
QUOTE:
I need to rely on the value of the global at strategy load. Can I assume that it will correspond to a false?
No you cannot. SetGlobal(...) is a run-time UserStrategyBase function, not a declaration. You may use it in the MyStrategy constructor or the MyStrategy.Initalize{block} as a run-time call, but not as a compile-time declaration.
However, variables within SetGlobal are shared between strategies, so I would create a special strategy called StartUp that sets that global to "false" in its constructor. Then be sure you run that StartUp strategy before any others so that global has a defined value.
Hmm. I suppose declaring inside1MRunPrevious as static in MyStrategy would "partially" work in certain circumstances. That would depend on your use case. Using the StartUp approach would be better.
CODE:
static boolean inside1MRunPrevious = false; //a compile-time declaration
Thank you!
I have a strategy that uses daily quotes that I run first to setup EMAs and SMAs.
I then pass them to the minute strategy using globals.
In there I will setup this global as false.
I have a strategy that uses daily quotes that I run first to setup EMAs and SMAs.
I then pass them to the minute strategy using globals.
In there I will setup this global as false.
Your Response
Post
Edit Post
Login is required