Console.WriteLine(c.Command("PLACE", "Sim101", "ES 09-20", "SELL", 1, "STOPMARKET", 0, 3155, "DAY", "12", "12", "", "").ToString());
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Placing short orders through NinjaTrader.Client assembly, raises error for stop loss
Collapse
X
-
Placing short orders through NinjaTrader.Client assembly, raises error for stop loss
Hi, I'm trying to place orders through de NinjaTRader.Client dll and I have encountered the problem that, if I place the order to sell a future and set the stop above the current price, ninjatrader raises an error indicating that stops above the current price are not supported..???? Is that possible? I'm using the Sim101 account.... Thanks in advance for any tips...
Console.WriteLine(c.Command("PLACE", "Sim101", "ES 09-20", "SELL", 1, "STOPMARKET", 0, 3155, "DAY", "12", "12", "", "").ToString());Tags: None
-
Hello abner77,
A buy stop order must be above the ask, a sell stop order must be below the bid.
This is also true if you pick up the phone and call your broker.
If you are wanting to place a sell order above the bid, you would need to use a limit order or a market if touched order.Last edited by NinjaTrader_ChelseaB; 07-09-2020, 09:35 AM.Chelsea B.NinjaTrader Customer Service
-
Sorry, I don't understand, if I want to aply an order with stop loss, let's say, current price is at 3150 and I want to go short (sell), and protect the maximum loss with the stop loss set at 3157, that canno't be below the bid, cause the bid is going to be, much lover than that.Originally posted by NinjaTrader_ChelseaB View PostHello abner77,
A buy stop order must be above the ask a sell stop order must be below the bid.
This is also true if you pick up the phone and call your broker.
If you are wanting to place a sell order above the bid, you would need to use a limit order or a market if touched order.
Comment
-
How would then I place an order with a stop loss from the API. It was my understanding that in order to place an Stoploss order it had to be in the same command as place, because the command CHANGE returns an error saying that the MARKET order that i place before (cause I've tried allso that, placing a market order and then try to change it to set an stoploss), is already on the market and cannot be changed. If I understand correctly, what you are saying is that in order to do this kind of protection I must place another operation in the opposite way with a limit price?Originally posted by NinjaTrader_ChelseaB View PostHello abner77,
When in a short position a stop market order used as a stop loss would be a buy order and not a sell order.
A buy order is used to exit a short position.
A buy stop market must be above the current ask price.
What does STOPMARKET then do? I have upload an image with the ninjatrader.Client help that it's relevant to this question...
1 Photo
Comment
-
Hello abner77,
Below is a link to the help guide with the available command parameters.
https://ninjatrader.com/support/help...ableToCommands
As well as a link the help guide with a list of available functions.
https://ninjatrader.com/support/help.../functions.htm
PLACE would be used to submit an order.
As an example:
SubscribeMarketData();
double currentAskPrice = MarketData("ES 09-20", 2);
Command("PLACE", "Sim101", "ES 09-20", "BUY", 1, "STOPMARKET", 0, (currentAskPrice + 1),
"DAY", string.Empty, NewOrderId(), string.Empty, string.Empty)Chelsea B.NinjaTrader Customer Service
Comment
-
If I do that and set a 7 pips as stop loss, it doesn execute, because price is far from there, (I'm saying the stop is way op the current price so obviously order does not execute) I don't understand this logic. how do i set up a buy or sell position configured with an stop loss of maximum 7 points against the position. Cannot be that difficult..... or there is something odd in the api not explained in the guide. I need a sample of how to do just that.Originally posted by NinjaTrader_ChelseaB View PostHello abner77,
Below is a link to the help guide with the available command parameters.
https://ninjatrader.com/support/help...ableToCommands
As well as a link the help guide with a list of available functions.
https://ninjatrader.com/support/help.../functions.htm
PLACE would be used to submit an order.
As an example:
SubscribeMarketData();
double currentAskPrice = MarketData("ES 09-20", 2);
Command("PLACE", "Sim101", "ES 09-20", "BUY", 1, "STOPMARKET", 0, (currentAskPrice + 1),
"DAY", string.Empty, NewOrderId(), string.Empty, string.Empty)
Last edited by abner77; 07-09-2020, 11:18 AM.
Comment
-
Hello abner77,
Do you have NinjaTrader 7 open?
I'm finding the code I have suggested is working without issue.
Below is a link to a video.
And a link to a forum post on the API.
Chelsea B.NinjaTrader Customer Service
Comment
-
I'm using NinjaTRader 8 64 bitsOriginally posted by NinjaTrader_ChelseaB View PostHello abner77,
Do you have NinjaTrader 7 open?
I'm finding the code I have suggested is working without issue.
Below is a link to a video.
And a link to a forum post on the API.
https://ninjatrader.com/support/foru...626#post793626
Comment
-
The sample of the video is not valid IMHO. You are using a BUY order with an stop which is just 1 point ABOVE the price. That's not the definition of setting a stop order. A buy order with an stop loss would be configured with the stop price several points BELOW the current price, so the operation would be executed at a market price, and, in case the market move against your position an touches the price set as stop loss, the position would be automatically closed.Originally posted by NinjaTrader_ChelseaB View PostHello abner77,
Do you have NinjaTrader 7 open?
I'm finding the code I have suggested is working without issue.
Below is a link to a video.
And a link to a forum post on the API.
https://ninjatrader.com/support/foru...626#post793626
Comment
-
Hello abner77,
I just wanted to clarify, were you able to try doing the test that Chelsea had provided a video of despite it not necessarily being valid or not?
The purpose of that was simply to put the order in and see it in the platform as a demonstration. You mentioned that the platform did nothing when you submitted the order so this test helps to make sure the platform is able to see an order come through.
I would suggest to go from the sample like shown in the video to test the API. If something you try after that point stops working you can know it was because of the code you used and not something else. A nothing result wouldn't be expected so making sure the connection is established and working is a good starting point.
Comment
-
I am able to place market orders and close positions through the API NinjaTrader.Client without any issue , the problem is just for the STOPMARKET orders (I haven't tried STOPLIMIT, but for the way I have trained my system STOPMARKET and CLOSEPOSITION positions are the only ones I really need.....Originally posted by NinjaTrader_Jesse View PostHello abner77,
I just wanted to clarify, were you able to try doing the test that Chelsea had provided a video of despite it not necessarily being valid or not?
The purpose of that was simply to put the order in and see it in the platform as a demonstration. You mentioned that the platform did nothing when you submitted the order so this test helps to make sure the platform is able to see an order come through.
I would suggest to go from the sample like shown in the video to test the API. If something you try after that point stops working you can know it was because of the code you used and not something else. A nothing result wouldn't be expected so making sure the connection is established and working is a good starting point.
These are working no problems so far (see image attached):
1 Photo
Comment
-
Hello abner77,
I tried this myself using the video steps and I can see stop market orders working on my end just like the video. I would suggest to save what you have as a zip excluding all the build data and attach it as a sample so we can review that before we continue further.
I look forward to being of further assistance.
Comment
-
Hi, I attach this toy sample trying to place a STOPMARKET order. Thanks for the assistance.Originally posted by NinjaTrader_Jesse View PostHello abner77,
I tried this myself using the video steps and I can see stop market orders working on my end just like the video. I would suggest to save what you have as a zip excluding all the build data and attach it as a sample so we can review that before we continue further.
I look forward to being of further assistance.
Attached Files
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Today, 05:17 AM
|
0 responses
36 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
124 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
64 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
41 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
46 views
0 likes
|
Last Post
|

Comment