Code:
---------
protected override void Initialize() {
CalculateOnBarClose = true;
TraceOrders = true;
Unmanaged = true;
}
protected override void OnBarUpdate() {
double hi = High[1] + (50*TickSize);
double lo = Low [1] - (50*TickSize);
Print("");Print("Bar " +CurrentBar +" Buy "+lo +" Sell " +hi);
//### Buy Limit Below
if (buyOrder != null) ChangeOrder(buyOrder, 1, lo, 0); else //### Comment out this line for orders to work
buyOrder = SubmitOrder(0, OrderAction.Buy, OrderType.Limit, 1, lo, 0, "", "Buy Below");
//### Sell Limit Above
if (sellOrder != null) ChangeOrder(sellOrder, 1, hi, 0); else //### Comment out this line for orders to work
sellOrder = SubmitOrder(0, OrderAction.Sell, OrderType.Limit, 1, hi, 0, "", "Short Above");
}
Output window
-------------------
**NT** Enabling NinjaScript strategy 'xxxBlah/66c51e0df95746a18c355e92dc3d58dd' : On starting a real-time strategy - StrategySync=WaitUntilFlat SyncAccountPosition=False EntryHandling=AllEntries EntriesPerDirection=1 StopTargetHandling=PerEntryExecution ErrorHandling=StopStrategyCancelOrdersClosePositio ns ExitOnClose=True/ triggering 30 before close Set order quantity by=Strategy ConnectionLossHandling=KeepRunning DisconnectDelaySeconds=10 CancelEntryOrdersOnDisable=False CancelExitOrdersOnDisable=True MaxRestarts=4 in 5 minutes
Bar 20 Buy 1.4364 Sell 1.447
5/22/2010 9:34:00 AM Entered internal SubmitOrder() method at 5/22/2010 9:34:00 AM: Action=Buy OrderType=Limit Quantity=1 LimitPrice=1.4364 StopPrice=0 OcoId='' Name='Buy Below'
5/22/2010 9:34:00 AM Entered internal SubmitOrder() method at 5/22/2010 9:34:00 AM: Action=Sell OrderType=Limit Quantity=1 LimitPrice=1.4470 StopPrice=0 OcoId='' Name='Short Above'
Bar 21 Buy 1.4363 Sell 1.4469
Changing unmanaged order at 5/22/2010 9:34:30 AM: Order='NT-00000/Sim101' Name='Buy Below' State=Working Instrument='6B 06-10' Action=Buy Limit price=1.4363 Stop price=0 Quantity=1 Strategy='xxxBlah' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='ac712be7b02f4216a5926e71da6489e4' Gtd='12/1/2099 12:00:00 AM'
Changing unmanaged order at 5/22/2010 9:34:30 AM: Order='NT-00001/Sim101' Name='Short Above' State=Working Instrument='6B 06-10' Action=Sell Limit price=1.4469 Stop price=0 Quantity=1 Strategy='xxxBlah' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='56ad9da0ae344b79bd6810f13a6efe42' Gtd='12/1/2099 12:00:00 AM'
5/22/2010 9:34:30 AM Entered internal SubmitOrder() method at 5/22/2010 9:34:30 AM: Action=Sell OrderType=Limit Quantity=1 LimitPrice=1.4469 StopPrice=0 OcoId='' Name='Short Above'
Bar 22 Buy 1.4361 Sell 1.4464
Changing unmanaged order at 5/22/2010 9:35:00 AM: Order='NT-00000/Sim101' Name='Buy Below' State=Working Instrument='6B 06-10' Action=Buy Limit price=1.4361 Stop price=0 Quantity=1 Strategy='xxxBlah' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='ac712be7b02f4216a5926e71da6489e4' Gtd='12/1/2099 12:00:00 AM'
Changing unmanaged order at 5/22/2010 9:35:00 AM: Order='NT-00002/Sim101' Name='Short Above' State=Working Instrument='6B 06-10' Action=Sell Limit price=1.4464 Stop price=0 Quantity=1 Strategy='xxxBlah' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='817042e03cf0491fae6537f117245437' Gtd='12/1/2099 12:00:00 AM'
5/22/2010 9:35:00 AM Entered internal SubmitOrder() method at 5/22/2010 9:35:00 AM: Action=Sell OrderType=Limit Quantity=1 LimitPrice=1.4464 StopPrice=0 OcoId='' Name='Short Above'
Bar 23 Buy 1.4355 Sell 1.4463
Changing unmanaged order at 5/22/2010 9:35:30 AM: Order='NT-00000/Sim101' Name='Buy Below' State=Working Instrument='6B 06-10' Action=Buy Limit price=1.4355 Stop price=0 Quantity=1 Strategy='xxxBlah' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='ac712be7b02f4216a5926e71da6489e4' Gtd='12/1/2099 12:00:00 AM'
Changing unmanaged order at 5/22/2010 9:35:30 AM: Order='NT-00003/Sim101' Name='Short Above' State=Working Instrument='6B 06-10' Action=Sell Limit price=1.4463 Stop price=0 Quantity=1 Strategy='xxxBlah' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='a538788e6a5447bfa6314b758e24e7fd' Gtd='12/1/2099 12:00:00 AM'
5/22/2010 9:35:30 AM Entered internal SubmitOrder() method at 5/22/2010 9:35:30 AM: Action=Sell OrderType=Limit Quantity=1 LimitPrice=1.4463 StopPrice=0 OcoId='' Name='Short Above'

Comment