Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Variable
Collapse
X
-
Variable
I have been building a strategy in the strategy builder and want to use the ATR indicator to base my profit target and stops on. I have made a variable and tried about a hundred things; I cannot make my variables register. I have looked all over the internet for some clarification. If I make it so if the time series is more than 600 am then set ATR1 to ATR, nothing happens. I've tried a variety of comininations and the variable doesn't register. It will compile fine, the strategy just exits as soon as it enters. Any help would be greatly appreciated. Thanks.Tags: None
-
Hello zrobfrank,
Thanks for your notes.
To clarify, you created a variable named ATR1 and are assigning the ATR indicator value to the ATR1 variable in the Conditions and Actions screen of the Strategy Builder. Is that correct?
Have you added prints in the script outside of the condition you are assigning a value to ATR1 that prints out the ATR1 variable to a NinjaScript Output window?
Adding prints would allow you to see what value the ATR1 is being set to. Below is a link to a forum post that demonstrates how to use prints to understand behavior.
https://ninjatrader.com/support/foru...121#post791121
Please note that a limitation of the Strategy Builder is that dynamic values cannot be assigned to Set methods in the Stops and Targets screen of the Strategy Builder.
To use dynamic values for stops and targets, you would need to use Exit methods, such as ExitLongLimit() and ExitLongStopMarket(), in the Conditions and Actions screen to place profit target and stop loss orders.
Here is a post from my colleague Jim that contains a video demonstrating how you could use ATR for stops in the Strategy Builder: https://forum.ninjatrader.com/forum/...15#post1121015
You may also find more information about this topic in the forum thread linked above.
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>
-
Is there a way to have dynamic stops/limits on the entry bar? Profit target/stop losses will offer protection as soon as a position is entered. Is it possible to stipulate conditions that will enact Exit methods as soon as a position is entered, or at least on the same bar? Thank you.Originally posted by NinjaTrader_BrandonH View PostHello zrobfrank,
Thanks for your notes.
To clarify, you created a variable named ATR1 and are assigning the ATR indicator value to the ATR1 variable in the Conditions and Actions screen of the Strategy Builder. Is that correct?
Have you added prints in the script outside of the condition you are assigning a value to ATR1 that prints out the ATR1 variable to a NinjaScript Output window?
Adding prints would allow you to see what value the ATR1 is being set to. Below is a link to a forum post that demonstrates how to use prints to understand behavior.
https://ninjatrader.com/support/foru...121#post791121
Please note that a limitation of the Strategy Builder is that dynamic values cannot be assigned to Set methods in the Stops and Targets screen of the Strategy Builder.
To use dynamic values for stops and targets, you would need to use Exit methods, such as ExitLongLimit() and ExitLongStopMarket(), in the Conditions and Actions screen to place profit target and stop loss orders.
Here is a post from my colleague Jim that contains a video demonstrating how you could use ATR for stops in the Strategy Builder: https://forum.ninjatrader.com/forum/...15#post1121015
You may also find more information about this topic in the forum thread linked above.
Please let me know if I may assist further.
Comment
-
Hello zrobfrank,
Thanks for your note.
Yes, to have a script calculate logic and place trades intrabar you could set the Calculate mode to OnPriceChange or OnEachTick.
Running the script with Calculate.OnBarClose means that the strategy would only process logic and place trades at the close of each bar.
By running the strategy with Calculate.OnPriceChange, the strategy will process logic for each change in price. This means that if an order was submitted and the condition to place the Exit orders becomes true on the next change in price, the Exit orders would be placed once the price changes.
Calculate.OnEachTick would work similarly to OnPriceChange except that logic would process for each incoming tick instead of each price change.
See this help guide page for more information about Calculate: https://ninjatrader.com/support/help.../calculate.htm
Please let me know if you have further questions on this.<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
52 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
130 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
70 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
44 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
49 views
0 likes
|
Last Post
|

Comment