Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
ATM strategy place an order on a secondary data series
Collapse
X
-
ATM strategy place an order on a secondary data series
Can I have an ATM strategy place an order on a secondary data series in a ninjascript strategy?
Tags: None
-
Hello Lance El Camino,
I've moved your new inquiry that is not related to forum thread this was posted in to a new forum thread.
Atm Strategy methods are completely outside of a NinjaScript Strategy. These are not attached to the bars or series. These will not affect the position, and will not trigger any strategy order methods like OnOrderUpdate().
Using ATM Strategies - https://ninjatrader.com/support/help...strategies.htm
ATM Strategy Methods - https://ninjatrader.com/support/help...gy_methods.htm
Meaning, you can call an AtmStrategy method at any time, in any series, because the two are not related.
If instead, you mean placing entry and exit orders using strategy order methods, yes, you can place orders to a secondary series.
Below is a link to the reference sample that demonstrates.
Chelsea B.NinjaTrader Customer Service
-
I'm trying to place an order on a secondary series using ATM:
if (longOrderId.Length == 0 && longAtmId.Length == 0 && !isLongAtmStrategyCreated)
{
longOrderId = GetAtmStrategyUniqueId();
longAtmId = GetAtmStrategyUniqueId();
AtmStrategyCreate(OrderAction.Buy, OrderType.Market, 0, 0, TimeInForce.Gtc, longOrderId, "ES Tick", longAtmId, (atmCallbackErrorCode, atmCallBackId) => {
//check that the atm strategy create did not result in error, and that the requested atm strategy matches the id in callback
if (atmCallbackErrorCode == ErrorCode.NoError && atmCallBackId == longAtmId)
isLongAtmStrategyCreated = true;
});
AtmStrategyCreate() doesn't have an option to place order on certain Bars In Progress index so is the default the primary BIP? Is there a way to assign AtmStrategyCreate to another BIP?
Comment
-
-
Here's what I have
// Set 1
if ((TICKPercent1.PercentUp[0] >= (TICKPercent1.PercentUp[1] + TICKPctChangeLong) && (TICKPercent1.PercentUp[0] >= TICKPercentLevelLong)))
{
Print("ATM Long condition at : " + Time[0]);
// If there is a short ATM Strategy running close it.
if(shortAtmId.Length != 0 && isShortAtmStrategyCreated)
{
AtmStrategyClose(shortAtmId);
isShortAtmStrategyCreated = false;
}
// Ensure no other long ATM Strategy is running.
if (longOrderId.Length == 0 && longAtmId.Length == 0 && !isLongAtmStrategyCreated)
{
longOrderId = GetAtmStrategyUniqueId();
longAtmId = GetAtmStrategyUniqueId();
AtmStrategyCreate(OrderAction.Buy, OrderType.Market, 0, 0, TimeInForce.Gtc, longOrderId, "ES Tick", longAtmId, (atmCallbackErrorCode, atmCallBackId) => {
//check that the atm strategy create did not result in error, and that the requested atm strategy matches the id in callback
if (atmCallbackErrorCode == ErrorCode.NoError && atmCallBackId == longAtmId)
isLongAtmStrategyCreated = true;
});
}
}
Comment
-
-
Here's what I have. Nothing prints to output and no entrances. BIP 2 is the ES where I want orders placed. The primary data series is ^TICK where I prefer the OnBarUpdates to take place.
if (BarsInProgress == 2)
{
Print(TICKPercent1.PercentUp[0]);
Print(TICKPercent1.PercentDown[0]);
Print("tick count:" + Bars.TickCount.ToString() + Time[0]);
// Check any pending long or short orders by their Order Id and if the ATM has terminated.
// Check for a pending long order.
if (longOrderId.Length > 0)
{
// If the status call can't find the order specified, the return array length will be zero otherwise it will hold elements.
string[] status = GetAtmStrategyEntryOrderStatus(longOrderId);
if (status.GetLength(0) > 0)
{
// If the order state is terminal, reset the order id value.
if (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
longOrderId = string.Empty;
}
} // If the strategy has terminated reset the strategy id.
else if (longAtmId.Length > 0 && GetAtmStrategyMarketPosition(longAtmId) == Cbi.MarketPosition.Flat)
{
longAtmId = string.Empty;
isLongAtmStrategyCreated = false;
}
// Check for a pending short order.
if (shortOrderId.Length > 0)
{
// If the status call can't find the order specified, the return array length will be zero otherwise it will hold elements.
string[] status = GetAtmStrategyEntryOrderStatus(shortOrderId);
if (status.GetLength(0) > 0)
{
// If the order state is terminal, reset the order id value.
if (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
shortOrderId = string.Empty;
}
} // If the strategy has terminated reset the strategy id.
else if (shortAtmId.Length > 0 && GetAtmStrategyMarketPosition(shortAtmId) == Cbi.MarketPosition.Flat)
{
shortAtmId = string.Empty;
isShortAtmStrategyCreated = false;
}
// End check.
// Set 1
if ((TICKPercent1.PercentUp[0] >= (TICKPercent1.PercentUp[1] + TICKPctChangeLong) && (TICKPercent1.PercentUp[0] >= TICKPercentLevelLong)))
{
Print("ATM Long condition at : " + Time[0]);
// If there is a short ATM Strategy running close it.
if(shortAtmId.Length != 0 && isShortAtmStrategyCreated)
{
AtmStrategyClose(shortAtmId);
isShortAtmStrategyCreated = false;
}
// Ensure no other long ATM Strategy is running.
if (longOrderId.Length == 0 && longAtmId.Length == 0 && !isLongAtmStrategyCreated)
{
longOrderId = GetAtmStrategyUniqueId();
longAtmId = GetAtmStrategyUniqueId();
AtmStrategyCreate(OrderAction.Buy, OrderType.Market, 0, 0, TimeInForce.Gtc, longOrderId, "ES Tick", longAtmId, (atmCallbackErrorCode, atmCallBackId) => {
//check that the atm strategy create did not result in error, and that the requested atm strategy matches the id in callback
if (atmCallbackErrorCode == ErrorCode.NoError && atmCallBackId == longAtmId)
isLongAtmStrategyCreated = true;
});
}
}
// Set 2
if ((TICKPercent1.PercentDown[0] <= (TICKPercent1.PercentDown[1] + TICKPctChangeShort) && (TICKPercent1.PercentDown[0] <= TICKPercentLevelShort)))
{
Print("Short condition at " + Time[0]);
// If there is a long ATM Strategy running close it.
if(longAtmId.Length != 0 && isLongAtmStrategyCreated)
{
AtmStrategyClose(longAtmId);
isLongAtmStrategyCreated = false;
}
// Ensure no other short ATM Strategy is running.
if(shortOrderId.Length == 0 && shortAtmId.Length == 0 && !isShortAtmStrategyCreated)
{
shortOrderId = GetAtmStrategyUniqueId();
shortAtmId = GetAtmStrategyUniqueId();
AtmStrategyCreate(OrderAction.SellShort, OrderType.Market, 0, 0, TimeInForce.Gtc, shortOrderId, "ES Tick", shortAtmId, (atmCallbackErrorCode, atmCallBackId) => {
//check that the atm strategy create did not result in error, and that the requested atm strategy matches the id in callback
if (atmCallbackErrorCode == ErrorCode.NoError && atmCallBackId == shortAtmId)
isShortAtmStrategyCreated = true;
});
}
}
}
Comment
-
Hi Lance, please make sure your prints are coming through when the strategy is processing within if (BarsInProgress == 2) {}, The time I can spend reviewing and debugging custom code will be limited, please use the example that I posted earlier as this one is working fine. The best way to debug and see where the code is reaching is to use Prints and also watch the Log tab of the Control Center for any errors.
Kind regards,
-ChrisL
Comment
-
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
54 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
130 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
72 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
44 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
49 views
0 likes
|
Last Post
|

Comment