Syntax
public static bool GetMode(WealthScript obj)
public static RunMode GetMode2(WealthScript obj)
public enum RunMode { SSB, MSB, SM, Error }
Parameter Description
obj | An instance of the WealthScript object |
Description
Returns the mode the Strategy is being executed. There are two methods, a simpler and legacy
GetMode which returns
false for single-symbol backtest and
true for multi-symbol backtests, and
GetMode2 which returns a
RunMode which can take four values:
SSB, MSB, SM, Error - single symbol backtest, multi-symbol backtest, running in Strategy Monitor and state of error.
Example
Here's a short snippet illustrating how to call the method in your Strategy code:
Example using C# extension methods:
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
/*** Requires installation of Community.Components Extension from www.wealth-lab.com > Extensions ***/
namespace WealthLab.Strategies
{
public class MyStrategy : WealthScript
{
protected override void Execute()
{
var mode = this.GetMode();
var mode2 = this.GetMode2();
var text = "";
PrintDebug( "GetMode: " + ( mode ? "Multi-symbol backtest" : "Single-symbol backtest") );
switch (mode2)
{
case RunMode.SSB: text = "Single-symbol backtest"; break;
case RunMode.MSB: text = "Multi-symbol backtest"; break;
case RunMode.SM: text = "Strategy Monitor"; break;
case RunMode.Error: text = "Error"; break;
default: break;
}
PrintDebug( "GetMode2: " + text );
}
}
}