Quote from vladisld:
So if I understand you right - all the calls from the engine to the custom code are parameterless ...
Almost. At least in C# (maybe not Java) you can pass a structure by value. So there's no need to "marshall" it to the GC. (Sorry if getting too technical.)
So to be more precise, all the methods from the engine to the custom code are
either parameterless like Initialize() or have one parameter.
Here's an example:
The engine will call custom code with (if you implement this method)
IntervalOpen()
This one means the default interval for the specific model. That way you can have EasyLanguage like code which works on any interval you configure.
And the engine also calls (if you implement this method)...
IntervalOpen(Interval interval)
The engine calls this one for every interval that the model requested in the Initialize() method.
So in this version of method you can do this:
if( interval == Intervals.Hour1) {
}
if( interval == Intervals.Second10) {
}
So again, all methods are either parameterless or have one parameter, the interval.
There's also IntervalClose(), StartHistorical() EndHistorical() etc.
Most are just events.
and all the data access from the custom code to the data structured maintained by the engine ( like tick/bars and others ) are also unsafe.
Unsafe, why? They will be available through the COM interface and in this case all the data is returned as ints. So they are based by value on the stack.
That means they are inherently "safe" if you're refering to C# "unsafe" concept or thread safety.
In other words, when you call Data.Hours.Open[5] it will call the Bars object in C++ and return an int which will be on the stack.
The same is true of Data.Hours.Time[5] or Data.Hours.EndTime[5] which return a TimeStamp struct which is only helper struct wrapping a double also on the stack.
Frankly, it will be seamless. So you won't have to worry about safety or threading.
Except, it will be unwise to use any static variable, singletons, etc in your custom code. But I can't think why that would ever be necessary. Member variables work fine.
Wayne