Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Identifying a bar close in an "On price change" strategy?
Collapse
X
-
Identifying a bar close in an "On price change" strategy?
I know technically every price change the computer is registering that the previous bar has closed. But I have some bools and other functionality that need to be reset after the current bar officially closes. Is it possible to do that in an "On price change" strategy?Tags: None
-
Hello Plzwork123,
Thanks for your post.
You can use the system bool IsFirstTickOfBar which will be true on the first tick of the bar when using Calculate.OnPriceChange.
Reference: https://ninjatrader.com/support/help...ttickofbar.htm
-
I probably should have specified. I just want to confirm this is accessible from the strategy builder? That's what I'm working in. Having a hard time finding it.
Comment
-
Hello Plzwork123,
Thanks for your reply.
Yes, whenever you ask a strategy question it would be helpful to identify that you are using the strategy builder so we can provide an appropriate response.
In the Strategy Builder, there is no IsFirstTickOfBar property available.
However, you can still create such an event, here is how:
1) In the Inputs and variables section create a bool called FirstTickOfBar and set it to false. Create an int type variable called "WorkingBar"
2) In set 1 (the sequence is important), have no conditions. In the action section, set the FirstTickofBar bool to be false. The bool will be set false on every tick.
3a) In Set 2, for a condition use UerVariables>Workingbar, Not Equal, Misc>Current bar.
3b) In set 2, for action, Misc>Set WorkingBar and assign(click set in the field) to Misc>currentBar
3c) In set 2, for action, Misc>Set FirstTickOfBar to true by checking the check box.
Set 2 will check to see if the working bar is the same as the current bar and if it is not then that means we have a new bar. The action then is to assign the current bar to WorkingBar so that the condition is only true once per bar and that also means we are on the first tick of the bar. Because set 1 sets the bool false on every tick, that is why set 2 must be next to set the bool to true and subsequent use of the bool will be true, until the next tick.
This will provide a bool FirstTickOfBar that you can then use throughout your strategy. Keep in mind that sets 1 and 2 must be sets 1 and 2 in your strategy whenever you need first tick of the bar,
NOTE: If you apply this to bars that uses IsRemoveLastBarSupported, such as Renko bars, this method will not work correctly and would generate 3 FirstTickOfBar = true conditions.
Attached FilesLast edited by NinjaTrader_ChelseaB; 10-18-2021, 10:18 AM.
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