Code:
public class PrintingStrategy : Strategy
{
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Just used to print stuff";
Name = "PrintingStrategy";
Calculate = Calculate.OnBarClose;
EntriesPerDirection = 1;
EntryHandling = EntryHandling.AllEntries;
IsExitOnSessionCloseStrategy = true;
ExitOnSessionCloseSeconds = 30;
IsFillLimitOnTouch = false;
MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
OrderFillResolution = OrderFillResolution.Standard;
Slippage = 0;
StartBehavior = StartBehavior.WaitUntilFlat;
TimeInForce = TimeInForce.Gtc;
TraceOrders = false;
RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
StopTargetHandling = StopTargetHandling.PerEntryExecution;
BarsRequiredToTrade = 20;
// Disable this property for performance gains in Strategy Analyzer optimizations
// See the Help Guide for additional information
IsInstantiatedOnEachOptimizationIteration = true;
}
else if (State == State.Configure) {
try {
Print("Account Info:");
foreach (Account Acct in Account.All) {
Print("Account: " + Acct.DisplayName.ToString());
if (Acct.Name != "xxxxxxxx") continue;
var enumValues = Enum.GetValues((typeof(AccountItem)));
foreach (AccountItem enumValue in (AccountItem[])enumValues) {
var Name = Enum.GetName(typeof(AccountItem), enumValue);
var Value = Acct.GetAccountItem(enumValue, Currency.UsDollar).Value;
Print(Name + ": " + Value);
}
}
}
catch {
}
}
}
protected override void OnBarUpdate()
{
Print(Time[0].ToShortDateString() + "," + Instrument.FullName);
}
}
Account Info:
Account: Backtest
Account: Playback101
Account: Sim101
Account: xxxxxxxx
BuyingPower: 100000
CashValue: 100000
Commission: 0
ExcessIntradayMargin: 100000
ExcessInitialMargin: 0
ExcessMaintenanceMargin: 0
ExcessPositionMargin: 0
Fee: 0
GrossRealizedProfitLoss: 0
InitialMargin: 0
IntradayMargin: 0
LongOptionValue: 0
LookAheadMaintenanceMargin: 0
LongStockValue: 0
MaintenanceMargin: 0
NetLiquidation: 1000
NetLiquidationByCurrency: 100000
PositionMargin: 0
RealizedProfitLoss: 0
ShortOptionValue: 0
ShortStockValue: 0
SodCashValue: 0
SodLiquidatingValue: 0
UnrealizedProfitLoss: 0
TotalCashBalance: 100000

Comment