The entry order is correctly named "Entry", and the saved-template workflow is operational.
We now need to calculate the initial stop and profit-target prices dynamically before submitting the entry. For example:
Long stop: selected structural bar low minus one tick
Short stop: selected structural bar high plus one tick
Profit target: calculated from the resulting risk distance, such as 0.5R, 1R, or 2R
The Guardian risk service must validate the exact initial stop and target values before allowing submission.
Could the development team please clarify the following:
The API exposes this overload:
StartAtmStrategy(
AtmStrategy atmStrategyTemplate,
Order entryOrder);
Is there a supported public API for obtaining or constructing an AtmStrategy object and changing its initial stop-loss and profit-target values before passing it to this overload?
If this is supported, what are the documented public methods or properties for:
Loading an existing native ATM template into an AtmStrategy object
Creating a separate instance or clone
Accessing its brackets
Setting initial stop-loss prices or distances
Setting initial profit-target prices or distances
Starting that configured instance without changing the saved ATM XML template
A minimal supported code example would be greatly appreciated.
If the AtmStrategy object overload does not support modifying protection before submission, what is its intended use compared with the template-name overload?
From an Add-On or custom NTWindow context, is there a supported way to start a native ATM with dynamically calculated initial stop and target prices without creating or modifying an XML template file?
Can AtmStrategyChangeStopTarget() be used from an Add-On for an ATM started with StartAtmStrategy()?
If so:
How does the Add-On obtain the active ATM strategy ID?
Can the stop and target be changed before the entry fills?
Is there any interval in which the original template protection could become active before the dynamic prices are applied?
Is temporary runtime creation or modification of ATM XML templates supported?
If it is technically possible but unsupported, cached, or vulnerable to file-access races, please confirm that so we can exclude it from the design.
If none of these approaches are supported, is the recommended Add-On architecture to submit and manage the dynamic protective stop and target as native account orders with an OCO ID rather than using a native ATM?
Our primary requirement is that an entry must never become exposed while its dynamically calculated protection is being configured. We therefore need the exact stop and target validated and ready before the entry can fill.
I wasn’t aware of any official method of creating a dynamic ATM so ended up using a blank xml as a template and then manually inserting the custom profit/stop nodes:
Bootup scan to delete dynamic files > 20hrs old keeps the folder from becoming overloaded.
Been working perfectly for years, but may not be an eye pleasing ‘professional’ solution, since these new ATMs will all appear in the ATM dropdown menu.
Curious to see whether there’s been a proper way to do this all along.
You cannot change the stop/target of an ATM before submission, what would be the point? you may as well just submit a regular order and decide your stop/target.
If you insist on submitting an ATM order, you can know before submission the SL/TP you desire and check it however you like. Just submit the ATM with some arbitrary values and then as soon as the order fills, you can immediately modify the SL/TP in code in a split second.
1: If you just make a regular order it won’t have any of the trade automatic management features of an ATM like trail / breakeven settings. It’s nice to have that managed by NT rather than coding your own order tracking and modification logic.
2: if submitting with ‘arbitrary values’ then the ATM won’t have the correct tick trigger values it uses for calculating when to activate breakeven and trail modifications.
Thanks for the several replies. For the AtmStrategy returned by StartAtmStrategy(), can its numeric Id be converted to a string and supplied to AtmStrategyChangeStopTarget()? If not, what identifier or Add-On method should be used to change that ATM’s Stop1 and Target1 orders?
I did a. lot of work on a script that Merges Stops/Targets from automated ATM orders a while ago. I have to refresh my memory though and some of my notes aren’t great and it’s quite confusing but you may find this useful:
AtmStrategyChangeStopTarget(). AFAIK this is only available to Strategies.
You have to group together the stop/target orders and modify them
You can use GetOwnerStrategy() to get the ATM Instance ID of orders belonging to ATM strategies. This is available in OnOrderUpdate
if (e.Order.OrderEntry == OrderEntry.Automated) var ownerAtm = e.Order.GetOwnerStrategy() as AtmStrategy;
Depending on your use case, the instance ID is maybe not a reliable way to modify orders because you can have multiple instances belong to the same strategy. (see notes below)
Using StartATMStrategy interacts in a weird way with the ATM Selector, here’s what I wrote:
// NOTES
// Ordering with StartATMStrategy
// If ATMSelector is unchanged, subsequent orders will use the same ATM instance ID.
// But you get multiple instances in the selector(confusing)
// If you change the selector to the base template, THEN you will get a new instance.
// Thus you can have a variety of instances listed in the selector, but it's impossible know which ones are belonging to the same real instance.
// Therefore, it only makes sense to group by template name.
The base ATM Strategy has an ID of -1, it only changes until an order is submitted.
StartATMStrategy doesn’t behave like clicking “Buy Market” if you already have an ATM open. It ALWAYS starts a new bracket. Where as Buy Market will merge into whichever ATM you have running/selected.
So using StartATMStrategy.
Assume “MyAtm” is my base ATM template and it’s in the selector in ChartTrader also. SubmitATMStragegy() runs, submitting an order with MyAtm:
Selector changes to “MyAtm-1”, orders get assigned ATM instance ID of “1111” (for example).
If you then run SubmitATMStragegy() immediately again , the selector changes to MyATM-2, but the orders retain the same instance ID of “1111”. These orders do not get merged with the previous brackets, so you will have 2 separate Stop/Targets on the chart that cannot be merged, even manually.
If you then change the selector back to the base “MyAtm” and run SubmitATMStragegy() again. The selector changes to “MyATM-3” and the orders get assigned a new ID of “2222”. You will now have:
3 brackets on chart
3 instances of the ATM in the ATM Selector (MyAtm-1, MyAtm-2, MyAtm-3) listed along side the base “MyAtm”.
But only 2 different ATM instances in code (1111 and 2222)
We got the dynamic ATM working by locating a saved native ATM template, cloning it in memory, and changing the stop and target values on the clone. We then submitted the cloned ATM with StartAtmStrategy(clonedAtm, entryOrder). The original template and the ATM selected in Chart Trader remain unchanged.
Never noticed StartAtmStrategy() had an overload that takes an object… certainly simplifies things. I’ll be converting my code to use this method istead.