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
Calling Draw Arrow
Collapse
X
-
Hello smclrr,
Thank you for your post.
You could, but you could also just save that current bar to an int variable and not have to cast the string back to an int. I'd probably go that route for clarity, as it might not be clear why you're using the tag for a drawing object to get a bar index later.
Please let us know if we may be of further assistance to you.Kate W.NinjaTrader Customer Service
-
If I started saving them to a variable, I would have to create a variable to store it in, yes? Or can a script create a variable? I do not really know what I am doing.
I just saved the currentbar to each arrow that is draw byt the script and saw an opportunity to maybe use that. Does that require a lot to convert the string to an int?
Comment
-
Hello smcllr,
To store a drawing object would require creating a variable. If you have a lot of objects you could make a List to collect drawing objects.
You could use the arrows existing Anchor property to find the bars ago or time it was placed on so you don't need to worry about converting the Tag to an index.
A simple example of finding the objects Time or BarsAgo looks like the following:
Code:ArrowDown myArrow = Draw.ArrowDown(this, "tag1", true, 0, High[0] + TickSize, Brushes.Red); Print(myArrow.Anchor.Time); Print(myArrow.Anchor.BarsAgo);
https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1?view=netframework-4.8Represents a strongly typed list of objects that can be accessed by index. Provides methods to search, sort, and manipulate lists.
A very simple example of a list in NinjaScript would be the following:
Code:List<ArrowDown> myArrows = new List<ArrowDown>(); protected override void OnBarUpdate() { ArrowDown myArrow = Draw.ArrowDown(this, "tag1", true, 0, High[0] + TickSize, Brushes.Red); myArrows.Add(myArrow); }
JesseNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by algospoke, Today, 06:40 PM
|
0 responses
1 view
0 likes
|
Last Post
by algospoke
Today, 06:40 PM
|
||
Started by maybeimnotrader, Today, 05:46 PM
|
0 responses
6 views
0 likes
|
Last Post Today, 05:46 PM | ||
Started by quantismo, Today, 05:13 PM
|
0 responses
6 views
0 likes
|
Last Post
by quantismo
Today, 05:13 PM
|
||
Started by AttiM, 02-14-2024, 05:20 PM
|
8 responses
167 views
0 likes
|
Last Post
by jeronymite
Today, 05:00 PM
|
||
Started by cre8able, Today, 04:22 PM
|
0 responses
8 views
0 likes
|
Last Post
by cre8able
Today, 04:22 PM
|
Comment