- The line is saved as it should. When the strategy is reloaded, there is a red line. How can this line be deleted without deleting the strategy?
- I tried to save a horizontal line instead of a normal line then I get an error message: Strategie 'SerializeObjectExample': Error on calling 'OnStateChange' method: Sie greifen mit einem ungültigen Wert auf einen Index zu, der außerhalb des erwarteten Bereichs ist. Z.B. Zugriff auf eine Reihe mit [BarsAgo] mit einem Wert von 5, wenn nur 4 Kerzen im Chart vorhanden sind. I know what the error message means, but not how I can fix the error, does anyone have a tip for me?
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
SerializeObjectExample
Collapse
X
-
SerializeObjectExample
Hi, I look at the example "SerializeObjectExample" and have 2 questions:
Tags: None
-
Hello sidlercom80,
Thanks for your post.
Please note that the approach described in the example you describe uses C# code that is not standard NinjaScript. While the example was originally intended to be helpful, serializing objects on your own would be outside of our scope of support. In a supported manner, we would suggest leaving serializable objects public and to handle non-serializable objects by converting them to something that is serializable, like Brushes, or to store serializable properties that can then be used to recreate the non-serializable object.
How brushes are serialized in NinjaTrader 8 - https://ninjatrader.com/support/help...lor_inputs.htm
When a line is drawn from NinjaScript, it will be owned by that NinjaScript. When this example redraws the line, it becomes NinjaScript owned and if the line gets deleted the strategy would then become disabled. There is not a supported means to remove a drawing object that was drawn from NinjaScript.
The example is a bit old, but you may have more luck trying what is done in State.Realtime, after making it accept HorizontalLines. (Drawing methods may use BarsAgo logic internally, and if you try to do something in State.Historical before bars are processed, that internal BarsAgo logic may fail. I tested the script in State.Realtime after changing it to use Horizontal lines and it worked for me.
If you have any other inquiries, please don't hesitate to open a new ticket.JimNinjaTrader Customer Service
- Likes 1
-
Hello _Jim, thank you for your detailed answer! That with the state.realtime was a good tip ;-)
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by judysamnt7, 03-13-2023, 09:11 AM
|
4 responses
57 views
0 likes
|
Last Post
by DynamicTest
Today, 08:25 PM
|
||
Started by ScottWalsh, Today, 06:52 PM
|
4 responses
36 views
0 likes
|
Last Post
by ScottWalsh
Today, 07:40 PM
|
||
Started by olisav57, Today, 07:39 PM
|
0 responses
7 views
0 likes
|
Last Post
by olisav57
Today, 07:39 PM
|
||
Started by trilliantrader, Today, 03:01 PM
|
2 responses
19 views
0 likes
|
Last Post
by helpwanted
Today, 07:25 PM
|
||
Started by cre8able, Today, 07:24 PM
|
0 responses
9 views
0 likes
|
Last Post
by cre8able
Today, 07:24 PM
|
Comment