A simple situation. A Script that runs with CalculateOnBarClose = True, then when a new Bar is beginning, I'd like to call its current Open. Is it as simple as calling Open[0] setting previously CalculateOnBarClose = False ?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
How to get the current open of a building Bar?
Collapse
X
-
How to get the current open of a building Bar?
Hi Ninjas,
A simple situation. A Script that runs with CalculateOnBarClose = True, then when a new Bar is beginning, I'd like to call its current Open. Is it as simple as calling Open[0] setting previously CalculateOnBarClose = False ?Tags: None
-
Hi Pstrusi,
Yes, in order to get the most current bar being built you will need to have the script run with CalculateOnBarClose set to false. You can then filter it out with FirstTickOfBar.
This will be true when a new bar is built.
http://www.ninjatrader.com/support/h...ttickofbar.htmCal H.NinjaTrader Customer Service
-
But I have this doubt: in order to get the proper signals from the Script, this must evaluate the Close, Open and Median of the last closed Bar; if I use tick by tick Bar, how can I call this?
Allow me to explain clearly the situation:
The Script evaluates Bar by Bar ( CalculateOnBarClose = True ) But when a signal entry is received, the Script must trigger an order at the price of the FirstTick of the next bar, so this is why I'm askingLast edited by pstrusi; 12-16-2013, 07:20 AM.
Comment
-
Not sure how, cause I'm still using CalculateOnBarClose=False. Do you mind to show me how to set and call this serie 1?
If I'm using CalculateOnBarClose=False, any new Bar Object will be filtered through the tick by tick method, right? then how can I set a Bar object series that carries Close, Open and Median that I need for my calculations?Last edited by pstrusi; 12-16-2013, 07:49 AM.
Comment
-
Pstrusi,
Example of this in use is below -
This filters out the FirstTickOfBar, which is also the last tick of the closed bar, meaning that the if statement will only be true when a bar closes with the first tick of the new bar.Code:protected override void OnBarUpdate() { if(FirstTickOfBar) { if(SMA(14)[1] > SMA(7)[1]) { EnterLongLimit( 5, Close[1], "Long1"); } } }Cal H.NinjaTrader Customer Service
Comment
-
I see your logic, the tick before the FirstTick will be the Close of the last Bar, but that means too that: Median[1] and Open[1] will be the correct values for the whole Last Bar ? or will these values be the same as Close[1] cause they're just reference to the that tick?Originally posted by NinjaTrader_Cal View PostPstrusi,
Example of this in use is below -
This filters out the FirstTickOfBar, which is also the last tick of the closed bar, meaning that the if statement will only be true when a bar closes with the first tick of the new bar.Code:protected override void OnBarUpdate() { if(FirstTickOfBar) { if(SMA(14)[1] > SMA(7)[1]) { EnterLongLimit( 5, Close[1], "Long1"); } } }
Comment
-
I imagined that. Allow me to remind my simple request:
I got a script that evaluates closed Bar by Closed Bar ( CalculateOnBarClose = True ), once the last closed Bar is evaluated, the script triggers an Limit Order ( BUY or SELL ) that it should be at the same price of the FirstTickofBar ( obvious the next active Bar ), so as you can see the conflict is obvious because I'd need two opposite CalculateOnBarClose ( True and False )
So my question:
How could I achieve this ?
Comment
-
This is not possible. However, this is why the FirstTickOfBar is there. This function only returns true when the first tick of a new bar comes through. After that, anything held in that if statement will not be calculated until the next new bar.the conflict is obvious because I'd need two opposite CalculateOnBarClose ( True and False )
This allows you to simulate a CalculateOnBarClose set to true and run your script on a bar by bar calculation while running it set to false on the chart.Cal H.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
571 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
330 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 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
549 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
549 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment