Announcement
Collapse
No announcement yet.
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.
-
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:
If you had a lot of objects you could use a C# list to hold all of the items and later loop over them. There is information on using lists in the following link: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:
The myArrows list could be used later to loop over and find certain objects or do an action for each object like checking its bars ago.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); }
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
62 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
134 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
75 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
45 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
50 views
0 likes
|
Last Post
|

Comment