A piece of code somewhere from the net , just let you have an idea of the basic framework of OP autotrading. code: -------------------------------------------------------------- public override void OnBar(Bar bar) { if (bbl.Contains(bar.DateTime)) { if (!HasPosition) { // cancel previos buy limit if (buyLimit != null) buyLimit.Cancel(); // calculate limit price double buyPrice = bbl.Last * (1 - Percent / 100); // place new limit orders buyLimit = BuyLimitOrder(Qty, buyPrice, "Entry"); buyLimit.Send(); } else { barsFromEntry++; // close position at the second bar after entry if (barsFromEntry == 2) { barsFromEntry = 0; sellLimit.Cancel(); Sell(Qty, "Exit (Second Bar After Entry)"); } } } }