Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
DrawTools and PriceLevel
Collapse
X
-
All about the inheritance.
PriceLevelContainer inherits from DrawingTool so it has the DrawingTool class as its base and adds some items in its class that are used to have multiple price levels.
Now, GannFan inherits from PriceLevelContainer. So, now GannFan as all the inheritance classes that PriceLevelContainer uses. Fibonacci does the same thing.
Line doesn't require to have all those extra price levels, so it just needs to inherit from DrawingTool itself.
You can see what is added in the PriceLevelContainer by looking at the PriceLevels script in the editor.
Let me know if that made sense.
-
GannFann, FiboanncciTools, AndrewsPtichfork, and TrendChannel all use the PriceLevel class, which derives from a DrawingTool just like the Line object.
PriceLevel is used for storing multiple prices at different levels which can be configured in the UI. There is @PriceLevels.cs object you can review if you needed.
I'm not sure what your specific question is so sorry if that's not helpful but perhaps enough to get you started. Let me know if you have specific questions.MatthewNinjaTrader Product Management
Comment
-
If you need to have a drawing tool that uses multiple price levels such as the Fibonacci does. You can add levels and remove them. The code then iterates through the price levels and draws a line or whatever you need it to. Note that this is done in the OnRender() method of the code.
This also allows the properties portion of the PriceLevelContainer to show up in the UI and be able to adjust them.
I strongly recommend taking a look at what Fibonacci, or even Andrews Pitchfork, is doing with the price level in the code. This gives a better idea of what to look for and how to effectively use them to your advantage.
Comment
-
I've been successful in extending FibonacciLevels in order to utilize the PriceLevels object (and move the param where I want).
However, is it possible to have TWO PriceLevel parameters?
If so, can anyone point me in the right direction?
If I do something like this, it refers to the base.PriceLevels object. Is there a simple way to create another instance of this without duplicating all the underlying objects?
PHP Code:[PropertyEditor("NinjaTrader.Gui.Tools.CollectionEditor")]
[Display(ResourceType = typeof(Custom.Resource), Name = "Levels", Prompt = "NinjaScriptDrawingToolsPriceLevelsPrompt", GroupName = "My Group", Order = 1)]
[SkipOnCopyTo(true)]
public new List<PriceLevel> myPriceLevels
{
get { return base.PriceLevels; }
set { base.PriceLevels = value; }
}
Comment
-
Hello,
Thank you for the question.
This is certainly possible but you would need to duplicate some objects. Because you are inheriting from the GannAngleContainer which controls the property PriceLevels, you would need to duplicate the logic for the existing GannAngleContainer in order to do this.
After duplicating the GannAngleContainer, you could then inherit from this instead which could contain any number of PriceLevel objects.
I have composed a sample using the GannFan as its base, I just duplicated the logic used for the initial fan so the file is quite large. The changes or duplicated logic has the number 2 at the end of the name like GannAngleContainer2.
I look forward to being of further assistance.Attached FilesJesseNinjaTrader Customer Service
Comment
-
Hello,
Thank you for the reply.
I wanted to check, is this a sample you have created based on what was uploaded or the sample directly?
If the sample uploaded is in question, where specifically are you seeing that the levels are not saved? On my end I am seeing the sample I had uploaded is saving the levels and persisting between restarts with the workspace. I did not account for all of the template types so I certainly could have missed something you are now trying.
If this is your own version of the sample, I would suggest to compare the differences regarding the PriceLevelContainer used, where in the logic the second price levels is being used to see what may be missing.
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Comment
-
Thank you for the quick reply. To answer your question, it's in my custom code. However, my first thought is it could be an issue with "order of events".
In my VenderLicense() call, I am populating the "PriceLevels" if they are empty. This is great for the very first time the tool is initiated. However, when editing the params, I think it's being called again, before being populated by whatever mechanism that stores and populates individual drawing object parameters. So, it thinks it's empty, and resorts to default.
However, I see in @FibonacciTools.cs that defaults are set when State.Configure, so my approach should be fine, which means something else is the issue...
I will look closer at details of what could be different. I'm sure I'm doing something wrong...
Thanks again!
Comment
-
Hello,
Thank you for the additional details.
Please let me know what you locate in the script in this case, the vendor license was an unexpected test that I had not had in mind.
The states in NT8 do get called at various different times depending on what is happening in the platform and what menus are opened, so you certainly could be on to what is happening in your script or the order of operations.
I believe the sample I had posted was also having this happen before I was initializing the PriceLevels, you may want to check the Log tab or output window to check if while using the vendor licensing if you are getting any exceptions for the property being null. Because the vendor licensing is done in the constructor, that could certainly change the order of operations in the sample.
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Comment
-
Hello,
That was actually intentional, I had intended to duplicate the tool completely so that was carried over but the original GannAngle is still used.
This could actually be removed from the sample as it is not really demonstrating anything but was only changed to not cause an error.
In order to actually create your own GannAngle class and also use it, you would also have to create your own PriceLevel class as well, kind of a cascade effect with this tool.
The PriceLevel class its self has an Attribute that specifically uses GannAngle [XmlInclude(typeof(GannAngle))], Technically GannAngle2 would work but would not be serialized. I felt this was outside of the scope of what was needed in the sample. I will update the sample to not include the extra code that is not needed.
I look forward to being of further assistance.Last edited by NinjaTrader_Jesse; 07-01-2016, 11:15 AM.JesseNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by pmachiraju, 11-01-2023, 04:46 AM
|
8 responses
147 views
0 likes
|
Last Post
by rehmans
Today, 06:44 PM
|
||
Started by mattbsea, Today, 05:44 PM
|
0 responses
5 views
0 likes
|
Last Post
by mattbsea
Today, 05:44 PM
|
||
Started by RideMe, 04-07-2024, 04:54 PM
|
6 responses
33 views
0 likes
|
Last Post
by RideMe
Today, 05:31 PM
|
||
Started by tkaboris, Today, 05:13 PM
|
0 responses
5 views
0 likes
|
Last Post
by tkaboris
Today, 05:13 PM
|
||
Started by GussJ, 03-04-2020, 03:11 PM
|
16 responses
3,282 views
0 likes
|
Last Post
by Leafcutter
Today, 04:14 PM
|
Comment