Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Stop loss as high of previous candle
Collapse
X
-
Hello RainIsWet,
Thanks for writing in.
You could use Exit order methods, such as ExitLongStopMarket(), to place a stop loss at the previous candle's High price (High[1]).
By passing in a BarsAgo value of 1 when accessing the High price, we get the High price 1 bar ago.
For example, the syntax might look something like this to submit 1 sell stop market order at the previous bar's High price :
ExitLongStopMarket(1, High[1]);
See the help guide documentation below for more information.
ExitLongStopMarket(): https://ninjatrader.com/support/help...stopmarket.htm
High[]: https://ninjatrader.com/support/helpGuides/nt8/high.htm
Please let me know if I may assist further.<span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>
-
Hello RainIsWet,
Thanks for your note.
If the Exit() methods in your script are not being submitted as expected this would indicate that the condition to place the order is not evaluating as true or the order is being ignored for other reasons.
To understand why the script is behaving as it is, such as placing orders or not placing orders or drawing objects when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.
In the strategy add prints (outside of any conditions) that print the values of every variable used in every condition that places an order along with the time of that bar. Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).
Also, enable TraceOrders which will let us know if any orders are being ignored and not being submitted when the condition to place the orders is evaluating as true.
Below is a link to a forum post that demonstrates how to use prints to understand behavior.
https://ninjatrader.com/support/foru...121#post791121
That said, I have attached an example video demonstrating that the ExitShortStopMarket() order would place a stop loss at the High[1] value when the conditions to do so become true.
See this demonstration video: https://brandonh-ninjatrader.tinytak...OV8yMDY0NDczNQ
Let us know if we may assist further.<span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>
Comment
-
Hello RainIsWet,
Thanks for your note.
"myStop" is the SignalName of the ExitShortStopMarket() order. "myTarget" is the SignalName of the ExitShortLimit() order. "myEntry" is the SignalName given to the EnterShort() method. We also use the "myEntry" for the FromEntrySignal properties of our Exit order methods to tie those Exits to that Enter order method.
Here is a quick demonstration video showing where these properties are located: https://brandonh-ninjatrader.tinytak...NF8yMDY1MzM4Mg
More information about SignalNames could be found on this help guide page: https://ninjatrader.com/support/help...#EntryMethods]
Information about FromEntrySignal could be found here: https://ninjatrader.com/support/help...oCloseAPositio n
You will see these properties available when creating your Enter and Exit order methods in the Strategy Builder.
This publicly available training video, Strategy Builder 301', briefly touches on this topic: https://www.youtube.com/watch?v=_KQF2Sv27oE&t=13s
Please let me know if you have further questions.Last edited by NinjaTrader_BrandonH; 12-08-2022, 04:02 PM.<span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Today, 05:17 AM
|
0 responses
50 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
126 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
69 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
42 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