Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
atm with auto trail
Collapse
X
-
Me code:
if (atmStrategyId.Length > 0)
{
string[] status = GetAtmStrategyEntryOrderStatus(atmStrategyId);
// 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"){
Print("borro la id");
Print("PnL is " + GetAtmStrategyRealizedProfitLoss(atmStrategyId).To String());
Print("GetAtmStrategyUnrealizedProfitLoss " + GetAtmStrategyRealizedProfitLoss(atmStrategyId).To String());
atmStrategyId = string.Empty;
} else if (status[2] == "PartiallyFilled") {
// Manejar específicamente el caso de cierre parcial
return; // Detener la ejecución para evitar nuevas órdenes
} else {
return; // Si la orden no está terminada, detener la ejecución
}
}
} // If the strategy has terminated reset the strategy id
else if (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat){
atmStrategyId = string.Empty;
}
-
Hello dcriador,
Have you tried using a print to check which parts of your logic are happening when you see that occur?
We suggest modeling your logic after the SampleATMStrategy which only places a single ATM at a time. It uses the strings you generate to know the order is active and only clears those strings when the order is not active. if you tried to do that in your own script but it is not working you would need to use prints to see where the problem is happening at.
Comment
-
Hello dcriador,
can you show how you are trying to check the status of the order? In the sample that is the following logic:
Code:if (orderId.Length > 0) { string[] status = GetAtmStrategyEntryOrderStatus(orderId); 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") orderId = string.Empty; } } else if (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat) atmStrategyId = string.Empty;
Comment
-
I use the same code that you write but dont work fine, It makes no sense for it to fail because the order, once closed, should come as filled, but I am receiving the order without closing and with a filled status.The only way I have found to capture it well is to use getatmorderstatus, I check if it exists and if it doesn't exist continue. The problem is that this function gives an error in the log if it does not find the id but in itself it is not a problemLast edited by dcriador; 05-07-2024, 08:51 AM.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
71 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
143 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
76 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
47 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
51 views
0 likes
|
Last Post
|

Comment