5. Compilation. Modules and assembly handling

From MultiCharts
Jump to navigation Jump to search

PL.NET supports studies written on 2 programming languages, C# and VB.NET. It is well known that the .NET Framework contains the compilers for both of these languages. But it is also known that it is impossible to compile source codes written on two different languages into a single assembly. That’s why all C# studies should be compiled into a single .netmodule, and all VB.NET studies should be compiled into a separate .netmodule, only then can these two netmodules be linked into a single assembly.

Below are some advantages that can be gained with the implementation described above:

  1. It is possible to organize data transfer between several separate studies within a single MultiCharts .NET process by using static fields.
  2. It is possible to create source code storage with common types. To do that:
    1. Create a new function with any name.
    2. Delete the WHOLE code (this function will always be colored in red (not compiled), but it will be required for code storage only)
    3. Fill this function with any info that can be necessary common classes including basic classes of indicators, signals, methods, etc.
    4. This common code can be used further in any other signals and indicators

When the compilation of a study is initialized, either after pressing the “Compile” button or because of changes to a study, it will check to see if this study is already applied to a chart or a scanner window. If it is already being used, after compilation has been completed successfully, MultiCharts .NET will be informed that these exemplars should be re-created from a new assembly, re-initialize their inputs with the values set by user, and recalculate.

IMPORTANT NOTE: After such a partial re-compilation (Compile->Compile (F7)), the studies with modified code will be already from another assembly (with a different name), and unmodified studies will be still from the previous assembly. It should be noted if the same static variables with several classes are used (for example for data transfer). The workaround for this is to re-compile the studies completely (Compile->Recompile All (Ctrl+F7)). In this case, ALL the studies will be re-compiled and re-created. This compilation mode is useful for development but can lead to undesirable results, such as disabling of automated trading performed by an unmodified signal.