Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
error in Bars.GetOpen(0)
Collapse
X
-
error in Bars.GetOpen(0)
Hello. I want to capture the value of Bars.GetOpen(0) in a variable and when I print it it gives me the value 13228.25 when its actual value is 13108.25. It is in a renko chart but in a candlestick chart it gives me the same error. What am I doing wrong? thank you.Tags: None
-
Hello julifro,
Thanks for your post.
QuantKey_Bruce is correct. Bars.GetOpen(0) would get the open price of the bar for bar index 0 which is the first bar on the chart window.
This is because the GetOpen() method takes a bar index argument and not a barsAgo argument. The bar index is the number of the bar on the chart. A bar index of 0 refers to the first bar on the chart since that bar has a bar index of 0.
BarsAgo refers to the number of bars back from the current processing bar on the chart. A barsAgo value of 0 refers to the current processing bar on the chart.
You could use Open[0] with the barsAgo value of 0 to get the open price of the current building bar on the chart.
See the help guide documentation below.
Bars.GetOpen(): https://ninjatrader.com/support/help...t8/getopen.htm
Open: https://ninjatrader.com/support/helpGuides/nt8/open.htm<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
-
Thanks for the reply. I really want to place an order with a custom button. When I press the button, the order is sent correctly 15 ticks from Open[0] but when EnterLongStopLimit is the order and a new bar is created, the order moves. What I want is for the order not to move once I launch it and I don't know how to do it
Comment
-
Hello julifro,
If the order price is changing, this would be because the order method is being called again.
Change the logic to submit the order and then not evaluate as true until you want to submit a new order.
One way to do that would be to use a bool. Require the bool to be false in the condition that submits the order. In the action block set the bool to true and submit the order. Set the bool back to false in another condition when you are ready for a new order.
Be sure you are using IsLiveUntilCancelled as true so the order does not automatically cancel.Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
646 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
367 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
570 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