Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Retrieving Horizontal Lines from .xml file
Collapse
X
-
Hello RJBen,
I would suggest for the time being to close all charts and open a single chart and then apply 1 horizontal line to that chart. Then run your code and make sure it shows only 1 object as the count in your print. Then assuming that is successful try 2 objects on the chart and make sure the count matches again. If the counts become out of sync that would point to something being done in code with the script you are using.
Comment
-
I only have one ES chart open.
So I removed the .xml files from the NinjaTrader 8\templates\GlobalDrawingObject folder and restarted the program.
I ticked the "Show global draw objects" in the Data Series window. No global horizontal lines showed up on the chart so- so far so good. I added a Horizontal Line and set it to ES (All charts). I ran my Indicator and the Output window showed:
@Horizontal Line 6107.75
Total number of Draw Objects 772
****************************************
It printed it 772 timesLast edited by RJBen; 01-29-2025, 09:30 AM.
Comment
-
Here it is. Thanks for all your help Jesse.Attached Files
Comment
-
Hello RJBen,
This is because you are using Count in your print:
Print("Total number of Draw Objects " + Count);
You need to use
Print("Total number of Draw Objects " + DrawObjects.Count);
If you are seeing slowness you also need to add a historical return because this collection is not intended to be used historically but only in realtime going forward.
protected override void OnBarUpdate()
{
if(State == State.Historical) return;
Comment
-
-
Hello RJBen,
It prints that many times because you are executing it for every bar, that collection is resource intensive so it should not be used on historical bars. The best way to test that is to add that state check, connect to a live connection and open a small timeframe chart like 10 seconds and apply it there. That will execute the code once every 10 seconds so you can easily see what is being printed one time. if you make code changes and reload the script the next update will be in 10 seconds again.
Comment
-
Hello RJBen,
You can use ClearOutputWindow() however keep in mind that clears the entire window, not just the last line. If you have other scripts producing output it will clear that info as well.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
71 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
143 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
76 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
47 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
51 views
0 likes
|
Last Post
|

Comment