If this is not possible, I assume I can create a DLL in Visual Studio, and reference it.
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
Compile with /unsafe
Collapse
X
-
Please consider.
I think that for advanced programmers it may provide a lot of both: memory and CPU usage optimization. As for now, when I'm using certain indicator separately and then as an embedded indicator in another indicator/strategy , I understand a separate instance of this indicator is created, including its BarArray. In addition , separate , BUT EXACTLY THE SAME computations for 2 or more instances are performed.
I'm not sure, than even with memory usage optimization in NT7 you're eliminating this resources waste.
It seems, If I could create and use ONE instance of the same indicator with the same input values globally, it would vastly eliminate waste of resources.
I can implement such pattern, using pointers , for specific variables I need with cooperation between indicator instances fully programmed according to my needs.
Comment
-
Originally posted by xTrader1 View Post...I understand a separate instance of this indicator is created, including its BarArray. In addition , separate , BUT EXACTLY THE SAME computations for 2 or more instances are performed...
Regards
Ralph
Comment
-
Thank you for remark.
Originally posted by Ralph View PostThat is absolutely not true xTrader. Only one indicator instance is created by NT for each indicator with identical signatures.
Regards
Ralph
After reading your remark, I experimented a little:
1) I created 3 new charts using historical data for the same instrument, the same last date , all of them 1 sec. period , 60000 bars back. When adding the 2nd chart, memory usage incerased by 34MB , but after adding the 3-rd chart it decreased by 17MB.
2) Then I added Bollinger Band indicator with the same inputs to all the charts. Adding to the 1-st chart raised memory usage by 3.5 MB. Adding to the 2-nd chart raised memory usage by 3.5 MB again. Adding to the 3-rd chart raised the memory usage by 1.25 MB only.
It seems, you're right, but somehow NT "gives up" memory allocation, not for the 2-nd, but for the 3-rd instance. But then:
3) I added 4-th identical new chart. This time memory usage grew by 55Mb. Adding Bollinger DECREASED memory usage by 8MB.
It seems that there is no direct correlation between memory usage and number of identical charts, but even if you're right, NT preallocates all th time more and more resources for the same charts with the same indicators.
I used Bollinger, not custom indicator, to avoid any possible bugs. Therefore I could not printout a hash of the Bollinger indicators, which in my mind would be an ultimative indication , whether we're talking about the same instance.
Then:
4) I wrote Test1 indicator, with one plot. The only thing it is doing , is to print relevant hash codes :
protected override void OnBarUpdate()
{
if (CurrentBar == 1)
{
Print(this.GetHashCode()) ;
Print(Close.GetHashCode()) ;
}
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
Plot0.Set(Close[0]);
}
I added the indicator to all 4 charts. Hashcode is different, for both Close and "this" .
I'm an experienced programmer , but .NET beginner.
In my understanding of .NET it means we have separate instances of Test1 and Close the Test1 instances are using for every chart.
Anything I don't understand ?
Comment
-
Interesting evaluation xTrader1.
Seems I have to revise my point of view partially. I agree with you that there is a separate indicator instance created, as soon as you open one on a chart (It is possible to observe that process with print statements). And during this process an opened Indicator is instantiated several times by Ninja, until one of them is used to be applied to the chart, the others are trashed. That may explain why the memory usage gets down occasionally.
On the other hand, if you access an indicator in your code, then it is reused assuming the signature is identical. You can prove that if you have a look at the code of a indicator (after compilation). At the file's end you find a section starting with
#region NinjaScript generated code. Neither change nor remove.
There you could find the explanation why.
Maybe these two different applications of an indicator should be considered separately.
Regards
Ralph
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by johntraderuser2, Today, 02:34 AM
|
0 responses
6 views
0 likes
|
Last Post Today, 02:34 AM | ||
Started by IanS00, 03-27-2024, 11:24 AM
|
2 responses
12 views
0 likes
|
Last Post Today, 02:00 AM | ||
Started by Mariawilcoxi, Today, 01:32 AM
|
0 responses
5 views
0 likes
|
Last Post
by Mariawilcoxi
Today, 01:32 AM
|
||
Started by gleichnerany, Today, 01:17 AM
|
0 responses
5 views
0 likes
|
Last Post
by gleichnerany
Today, 01:17 AM
|
||
Started by WHICKED, 03-27-2024, 12:33 PM
|
4 responses
47 views
0 likes
|
Last Post Today, 12:28 AM |
Comment