Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Not to remove horizontal line when strategy enabled
Collapse
X
-
Not to remove horizontal line when strategy enabled
Hi, I am using Draw.HorizontalLine(); for drawing horizontal lines in my strategy. after the strategy is disabled, these lines stays on the chart which is ok. But when I re-enable the strategy those lines gets removed. Is there anyway to keep those drawn lines from being removed when I re-enable the strategy?Tags: None
-
Hello asmmbillah, thanks for your post.
When a strategy instance draws any drawing tool and the strategy is disabled the drawing tool will be removed. If you need to preserve the levels of the horizontal line you will need to re-draw it at some point in the historical data, or at the first real time bar. This could be done by writing the lines data to a .txt file then reading that .txt file to re-populate the lines. We have an example here demonstrating file IO from a script:
https://ninjatrader.com/support/help..._propertie.htm
Alternatively, you can draw the horizontal lines manually then access their data from the DrawObjects array. See the documentation here:
https://ninjatrader.com/support/help...rawobjects.htm
Please let me know if you have any questions on this material.
-
thanks, but when my strategy is in state.Terminated state, it does not remove the line which is what I wanted; but that kind of contradicts from what you said above. I just wanted to keep that drawing as it is on the chart when I re-enable the strategy. When it goes through initial states, what what point it actually gets removed?
Comment
-
Hello asmmbillah, thanks for your reply.
In my test script (attached) the line is removed after State.Terminated. It will draw a line on the first real time bar, so test on a 10 second chart and wait for the first real time bar. You may test this out on your end, the line should get removed after the strategy is terminated.
Please let me know if I can assist any further.Attached Files
Comment
-
Thanks. I should have explained it. I have added some to your script. on next bar it will enter long and onexecutionupdate it will draw the line and terminate. you will see the line remains on the chart. I hope that should clarify. However as said, when I re-enable it, line gets removed. I just want to keep it when I re-enable it. thanks in advance.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Today, 05:17 AM
|
0 responses
43 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
124 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
65 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