[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] OnStartUp() {[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (Historical) {[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].myAccountSize = 50000;[/SIZE]
[SIZE=2]Print([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].Format([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"OnStartUp: {0},{1}"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], Time[0].ToShortDateString(), [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].myAccountSize));[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] OnExecution([/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]IExecution[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] iexec) {[/SIZE]
[SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// if backtesting keep track of account size by hand, [/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]// otherwise use GetAccountValue(AccountItem.CashValue)[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (Historical) {[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]lock[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].lockObj) {[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff] int[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Qty = iexec.Quantity;[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff] double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Price = iexec.Price;[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff] string[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] BuyOrSell = [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Sell"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff] if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (iexec.MarketPosition == [/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]MarketPosition[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].Long) {[/SIZE]
[SIZE=2] Price *= -1;[/SIZE]
[SIZE=2] BuyOrSell = [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Buy"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];[/SIZE]
[SIZE=2] }[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff] this[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].myAccountSize += (Qty * Price);[/SIZE]
[SIZE=2] Print([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].Format([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"{0},{1},{2},{3},{4}"[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2] , Time[0].ToShortDateString(), Instrument.FullName, BuyOrSell, (Qty * Price), [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]this[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].myAccountSize));[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]}[/SIZE]
[SIZE=2]}[/SIZE]
Thanks,
Erik

Comment