I need to know how I can force the call the the given member function, either directly from OnButtonClick(), or how to force it to trigger OnBarUpdate() to be called.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
How to take an action from OnButtonClick()
Collapse
X
-
How to take an action from OnButtonClick()
My strategy creates a button on the chart which sets a flag to do a particular action which is taken next time OnBarUpdate() is called. However, if the market is closed, but the strategy is still running (connected to feed), I still need that action to be taken. I tried calling the function directly from OnButtonClick(), but it does not work, presumably because that code is running from a different thread.
I need to know how I can force the call the the given member function, either directly from OnButtonClick(), or how to force it to trigger OnBarUpdate() to be called.
Tags: None
-
Hello DerkWehler,
You would need to do the action from the button event if you want it at the same time as the press, you may need to surround your code in the button event with a TriggerCustomEvent. Depending on what you are trying to do that may also not work if you are at the end of market hours, some actions require market data to be processed.
-
Thank you, I will try calling it from OnButtonClick() like that. The function it calls references Time[0], so that may be the problem(?) Can I reference Time[0] when market is closed?Originally posted by NinjaTrader_Jesse View PostYou would need to do the action from the button event if you want it at the same time as the press, you may need to surround your code in the button event with a TriggerCustomEvent. Depending on what you are trying to do that may also not work if you are at the end of market hours, some actions require market data to be processed.
Also, is there a ninjascript method I can call to be able to tell whether the market is open?
Comment
-
Hello DerkWehler,
Yes to access series you would have to use TriggerCustomEvent. You can access the last closed bar which will not be the furthest right on the chart, the very last bar on the chart only closes when the first tick of the next session is observed.
To tell if the market is open you can use the session iterator to find the session times. https://ninjatrader.com/support/help...oniterator.htm
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
62 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
134 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
75 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
45 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
50 views
0 likes
|
Last Post
|

Comment