I want achieve that strategy will not enter position in first 20 bars after last order made before it was enabled.
I am using something like:
Initialize()
foreach (Account acct in Cbi.Globals.Accounts) {
if(acct.Name == Account.Name) {
PositionCollection positions = acct.Positions;
if (acct.Positions != null) {
foreach (Position pos in positions) {
if(pos.MarketPosition == MarketPosition.Long && pos.Instrument.FullName == Instrument.FullName && pos.Account.Name == Account.Name) {
isLongAccountPosition = 1;
}
}
}
if (acct.Orders != null) {
OrderCollection orders = acct.Orders;
foreach (Order ord in orders) {
if(ord.Instrument.FullName == Instrument.FullName && ord.Account.Name == Account.Name) {
lastLongAccountOrderBar = ord.Time.Ticks;
}
}
}
}
}
Thanks.

Comment