It doesn't work.. the output file says the following:
**NT** GetAtmStrategyUnrealizedProfitLoss() method error: AtmStrategyId '3d7c7987ce394ab3b2c34ca1fc119bf6' does not exist
The current ATM Strategy Unrealized PnL is: 0
2/16/2016 10:20:24 AM CancelAllOrders: BarsInProgress=0
**NT** Disabling NinjaScript strategy 'RGESATM/fc32935ead4842cb927e2d357022cb96'
**NT** Enabling NinjaScript strategy 'RGESATM/fc32935ead4842cb927e2d357022cb96' : 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 CalculateOnBarClose=True MaxRestarts=4 in 5 minutes
**NT** ATM Strategies can't be created on historical data
**NT** GetAtmStrategyEntryOrderStatus() method error: orderId 'fc906912a689433ea52a3fdd7d114306' does not exist
**NT** GetAtmStrategyMarketPosition() method error: AtmStrategyId 'f10d5b9c06354a3d91f6c751c8a1bf98' does not exist
**NT** GetAtmStrategyMarketPosition() method error: AtmStrategyId 'f10d5b9c06354a3d91f6c751c8a1bf98' does not exist
The current ATM Strategy market position is: Flat
**NT** GetAtmStrategyPositionQuantity() method error: AtmStrategyId 'f10d5b9c06354a3d91f6c751c8a1bf98' does not exist
The current ATM Strategy position quantity is: 0
**NT** GetAtmStrategyPositionAveragePrice() method error: AtmStrategyId 'f10d5b9c06354a3d91f6c751c8a1bf98' does not exist
The current ATM Strategy average price is: 0
**NT** GetAtmStrategyUnrealizedProfitLoss() method error: AtmStrategyId 'f10d5b9c06354a3d91f6c751c8a1bf98' does not exist
The current ATM Strategy Unrealized PnL is: 0
the strategy text follows as well:
{
// Condition set 1 short
if (orderId.Length == 0 && atmStrategyId.Length == 0
&& Close[0] < Open[0] )
{
DrawDot("" + CurrentBar, false, 0, High[0] + 2 * TickSize, Color.Red);
// Submits an entry limit order at the current low price to initiate an ATM Strategy if both order id and strategy id are in a reset state
// **** YOU MUST HAVE AN ATM STRATEGY TEMPLATE NAMED 'AtmStrategyTemplate' CREATED IN NINJATRADER (SUPERDOM FOR EXAMPLE) FOR THIS TO WORK ****
atmStrategyId = GetAtmStrategyUniqueId();
orderId = GetAtmStrategyUniqueId();
AtmStrategyCreate(Cbi.OrderAction.Sell, OrderType.Market, Close[0], 0, TimeInForce.Day, orderId, "ES2ctr", atmStrategyId);
// Check for a pending entry order
if (orderId.Length > 0)
{
string[] status = GetAtmStrategyEntryOrderStatus(orderId);
// If the status call can't find the order specified, the return array length will be zero otherwise it will hold elements
if (status.GetLength(0) > 0)
{
// Print out some information about the order to the output window
Print("The entry order average fill price is: " + status[0]);
Print("The entry order filled amount is: " + status[1]);
Print("The entry order order state is: " + status[2]);
// If the order state is terminal, reset the order id value
if (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
orderId = string.Empty;
}
} // If the strategy has terminated reset the strategy id
else if (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat)
atmStrategyId = string.Empty;
if (atmStrategyId.Length > 0)
{
// You can change the stop price
if (GetAtmStrategyMarketPosition(atmStrategyId) != MarketPosition.Flat)
AtmStrategyChangeStopTarget(0, Low[0] - 2 * TickSize, "STOP1", atmStrategyId);
// Print some information about the strategy to the output window
Print("The current ATM Strategy market position is: " + GetAtmStrategyMarketPosition(atmStrategyId));
Print("The current ATM Strategy position quantity is: " + GetAtmStrategyPositionQuantity(atmStrategyId));
Print("The current ATM Strategy average price is: " + GetAtmStrategyPositionAveragePrice(atmStrategyId)) ;
Print("The current ATM Strategy Unrealized PnL is: " + GetAtmStrategyUnrealizedProfitLoss(atmStrategyId)) ;
}
}
Comment