Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Strategy in chart disables Chart Trader?
Collapse
X
-
I am using the SampleAtmStrategy as a template. Regarding ATMStrategyCreate() I understand how to enter my atmStrategyId, but am puzzled how to enter my logic, which is very simple for an upward price direction:
if(Close[1] < Open[1])In my prior attempt this logic actually moved the LongStop down as red bars declined, but how to use this in ATMStrategyCreate() ???{ EnterLongStop(High[1] + 1 * TickSize);}
Comment
-
Hello Pete77,
Here is one way you could accomplish that with the ATM strategy methods:
Because things are done a little differently in ATM strategy methods, it is very helpful to be aware of all the methods on this list: http://ninjatrader.com/support/helpG...gy_methods.htmCode://...in your variables region string orderId; //...in your OnBarUpdate() or other method if(Close[1] < Open[1]) { if(orderId == null) { orderId = GetAtmStrategyUniqueId(); AtmStrategyCreate(OrderAction.Buy, OrderType.Stop, 0, High[1] + 1 * TickSize, TimeInForce.Day, orderId, "MyTemplate", GetAtmStrategyUniqueId()); } else { AtmStrategyChangeEntryOrder(0, High[1] + 1 * TickSize, orderId); } }
Please let me know if I may be of further assistance.Michael M.NinjaTrader Quality Assurance
Comment
-
Hi Michael,
With your help I am making progress, Testing is slow when not able to use historical data. Sell & buy stops are now appearing. Next step is to cancel an order if it has not been filled by the close of the next bar, or if a new order is created. I will see what i can do with that. I have found some examples
Comment
-
Hello Pete77,
You can use Historical data if you require it for testing purposes. The fix I provided is just a quick solution to make sure your strategy position does not prevent your orders from submitting when you have the default settings set.
If you need to use historical data, please read through the following two documents and make sure you pick the settings that best apply to how you want your strategy to work, then you can remove the following code:
1. http://ninjatrader.com/support/helpG...unt%2BpositionCode:if(Historical) return;
2. http://ninjatrader.com/support/helpG..._positions.htm
You may wish to use "Immediately submit live working historical orders" and also "Sync account position = true".
"Immediately submit live working historical orders" can be selected by navigating to Tools -> Options -> Strategies tab -> NinjaScript sub-tab
You can set Sync Account Position in the strategy parameters box, when enabling the strategy.
Please let me know if you have any questions or if I may be of further assistance.Michael M.NinjaTrader Quality Assurance
Comment
-
Hello Pete77,
You would use the overload that contained liveUntilCancelled. For example:
If you set liveUntilCancelled to true, the order will NOT expire at the end of a bar, but instead remain live until the CancelOrder() method is called or its time in force has been reached.Code:EnterLongLimit(int barsInProgressIndex, bool liveUntilCancelled, int quantity, double limitPrice, string signalName)
You would have to store the entry in an IOrder so you could call the CancelOrder() method.
For more information on IOrders: http://ninjatrader.com/support/helpG...ightsub=iorder
For more information on the CancelOrder() method: http://ninjatrader.com/support/helpG...ub=cancelorder
Then you need to use the OnOrderUpdate() method to determine if the order was filled by the end of the next bar or not. If not, call the CancelOrder() method.
For more information on the OnOrderUpdate() method: http://ninjatrader.com/support/helpG...=onorderupdate
Please let me know if you have any further questions.Michael M.NinjaTrader Quality Assurance
Comment
-
HI Michael,
My strategy at its present stage is working fine in simulation, but when I switch to live it does not work at all, orders to not show up on the chart trader screen as the do in sim. As you know my strategy is on a separate non-chart trader screen. I brought up the the Dom and set it live, but that didn't have any effect.
Can you tell me what I am missing?
Comment
-
Hello Pete77,
When trying to run your strategy live, please open the strategies tab of the control center. If your strategy is colored anything except green when enabled (such as yellow), you are likely having an issue with your strategy position vs account position. Please see my earlier post for more information on this: http://ninjatrader.com/support/forum...5&postcount=23
Please clarify if your strategy is turning green or not in the strategies tab so I can investigate further.
Thank you in advance.Michael M.NinjaTrader Quality Assurance
Comment
-
Hello Pete77,
Based on your response, tt will help to see the code you are testing to find the cause of this behavior. If you do not want to post it here on the forums, please feel free to attach it in an email to platformsupport[AT]ninjatrader[DOT]com with the following information contained in the body: "ATTN: Michael M http://ninjatrader.com/support/forum/showthread.php?t=30165".
Thank you in advance.Michael M.NinjaTrader Quality Assurance
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
648 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
369 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
108 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
572 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
573 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment