Adding logging into an indicator/strategy

In order to use the standard mechanism of logging of the platform, the Utils.Common.dll file (which is in the program folder) and using Utils.Common.Logging should be added to the indicator/strategy project.

After this, the extensions of this library (LogDebug, LogInfo, LogWarn and LogError) could be used.

Each extension creates a log with a certain significance level (Debug, Info,Warning and Error). These logs are recorded in the application logs are displayed in the application log window.

Example of use:

public class SampleTick:Indicator
    {
        protected override void OnCalculate(int bar, decimal value)
        {
            this.LogDebug("Debug message");
            this.LogInfo("Info message");
            this.LogWarn("Warn message");

            try
            {
                //your code
            }
            catch (Exception e)
            {
                this.LogError("Error message",e);
            }
        }
    }

Is this article helpful for you?