Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
running code when the trading buttons are pressed
Collapse
X
-
just to be clear, locking wouldn't interfere with manual trading being executed? I understand what a lock is, I just don't understand how NinjaTrader handles it. I can avoid locks for now since I will use the events for what I need to do, however I'd still like to understand this in case I need to use it in the future.
-
Hello NinjaCustomer,
Within our documentation, we advise to lock the collection when reading and support its access. There should not be instances where reading the account positions would interfere with trade execution and I have not observed any such issue yet.
If you come across a case, please let us know.
JimNinjaTrader Customer Service
Comment
-
-
Hello NinjaCustomer,
NinjaTrader 8 is a multi threaded application and you are welcome to create asynchronous code to be used with your NinjaScript project, although I would typically advise against making NinjaTrader wait for asynchronous operations to complete. We will not be able to provide direction for creating asynchronous code as these concepts are outside the context of NinjaScript itself, but we do have documented Multi Threading Considerations which I will link below.
Multi Threading Considerations - https://ninjatrader.com/support/help...-threading.htm
We look forward to being of any further assistance.JimNinjaTrader Customer Service
Comment
-
thanks, yeah async / await doesn't seem to be useful for me - I was going to use ThreadPool.QueueUserWorkItem until I read your link.. how does one use ChartControl.Dispatcher.InvokeAsync in an addon? I mean, what should be used instead of ChartControl? I just want run something to process the open positions asynchronously (reading them only, not manipulating them)
Comment
-
my code seems to work fine with ThreadPool.QueueUserWorkItem, would there be any problems using this instead of Dispatcher.Invoke ?
note to self: I'll stick with ThreadPool since Globals can't be accessed from OnStateChange() and this way I don't have to find an Instrument object to accessLast edited by NinjaCustomer; 02-13-2019, 12:58 AM.
Comment
-
Hello NinjaCustomer,
There aren't any best practice tips or advisories I could provide for using ThreadPools. If you find something works for you, you are welcome to use it.
If you would like to use a Dispatcher from an AddOn you could use Globals.RandomDispatcher.InvokeAsync. You can also use a Dispatcher on an Instrument object.
I look forward to being of any further assistance.JimNinjaTrader Customer Service
Comment
-
Multi-Threading Consideration for NinjaScript:
https://ninjatrader.com/support/help...-threading.htm
and
my addon compiles usually.. and it does access an external dll. However, I added one call to the dll.. one line.. and every time I try to compile this it hangs the
for my referenceLast edited by NinjaCustomer; 03-06-2019, 12:54 PM.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by kaywai, 09-01-2023, 08:44 PM
|
5 responses
601 views
0 likes
|
Last Post Today, 12:32 AM | ||
Started by xiinteractive, 04-09-2024, 08:08 AM
|
6 responses
22 views
0 likes
|
Last Post Today, 12:31 AM | ||
Started by Pattontje, Yesterday, 02:10 PM
|
2 responses
17 views
0 likes
|
Last Post
by Pattontje
Yesterday, 11:49 PM
|
||
Started by flybuzz, 04-21-2024, 04:07 PM
|
17 responses
230 views
0 likes
|
Last Post
by TradingLoss
Yesterday, 11:45 PM
|
||
Started by agclub, 04-21-2024, 08:57 PM
|
3 responses
17 views
0 likes
|
Last Post
by TradingLoss
Yesterday, 11:42 PM
|
Comment