private SortedList<int, int> MySlVolume = new SortedList<int, int>();
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
How to find the 1st, 2nd, and 3rd highest volume for the day in real time
Collapse
X
-
While you were responding I was able to try enough variations to come up with the attached indicator using Volume. This sortedList keeps a list of the 4 highest volumes looking for duplicates before adding a new one. This is just what I was looking for and will allow me to finish my project.
In your response you suggested:
#region Variables
private SortedList<int, int> MySlVolume = new SortedList<int, int>();
Does this code declare and initialize at the same time?
In my code:
#region Variables
private SortedList<int, int>
Initialize()
MySlVolume = new SortedList<int, int>();
Is either way OK? or is one preferable?Attached Files
Comment
-
Originally posted by Taddypole View PostWhile you were responding I was able to try enough variations to come up with the attached indicator using Volume. This sortedList keeps a list of the 4 highest volumes looking for duplicates before adding a new one. This is just what I was looking for and will allow me to finish my project.
In your response you suggested:
#region Variables
private SortedList<int, int> MySlVolume = new SortedList<int, int>();
Does this code declare and initialize at the same time?
In my code:
#region Variables
private SortedList<int, int>
Initialize()
MySlVolume = new SortedList<int, int>();
Is either way OK? or is one preferable?
It is great news that you came to the solution yourself, with barely hints from me as to what to do. I kind of sensed that you might prefer to reach your own solution, and am glad to think that I may have been right.
All the best to you, and may all your trades be winners!Last edited by koganam; 05-22-2013, 05:34 PM.
Comment
-
Ran into another bump along the way.
Print("Test" + Time[0] + MySlVolume[0].ToString());
Print("Test" + Time[0] + MySlVolume[1].ToString());
Print("Test" + Time[0] + MySlVolume[2].ToString());
Print("Test" + Time[0] + MySlVolume[3].ToString());
Tried to print out the values at indexes 0,1,2,3 in MySlVolume. The code compiles but when applied to a chart I get an error message as follows:
System.Collections.Generic.KeyNotFoundException was unhandled by user code
Message=The given key was not present in the dictionary.
tried many things but can't get the print to work. Can't find a method to get key or value by index. This seems to be my problem. ????
Have attached updated VolTwo.cs file and a picture of the debugging session showing the SortedList with keys and values populated. Don't understand why i get this error message.
Comment
-
Originally posted by Taddypole View PostRan into another bump along the way.
Print("Test" + Time[0] + MySlVolume.Keys[0].ToString());
Print("Test" + Time[0] + MySlVolume.Keys[1].ToString());
Print("Test" + Time[0] + MySlVolume.Keys[2].ToString());
Print("Test" + Time[0] + MySlVolume.Keys[3].ToString());
Tried to print out the values at indexes 0,1,2,3 in MySlVolume. The code compiles but when applied to a chart I get an error message as follows:
System.Collections.Generic.KeyNotFoundException was unhandled by user code
Message=The given key was not present in the dictionary.
tried many things but can't get the print to work. Can't find a method to get key or value by index. This seems to be my problem. ????
Have attached updated VolTwo.cs file and a picture of the debugging session showing the SortedList with keys and values populated. Don't understand why i get this error message.
Comment
-
Hello Mindset,
The SortedList<int, int> is general c# and is not specific to NinjaScript.
Represents a collection of key/value pairs that are sorted by key based on the associated IComparer implementation.
This specific object type will work in a script made for NinjaTrader 7 or a script made for NinjaTrader 8.Chelsea B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by fx.practic, 10-15-2013, 12:53 AM
|
5 responses
5,404 views
0 likes
|
Last Post
by Bidder
Today, 12:22 AM
|
||
Started by Shai Samuel, 07-02-2022, 02:46 PM
|
4 responses
95 views
0 likes
|
Last Post
by Bidder
Today, 12:11 AM
|
||
Started by DJ888, Yesterday, 10:57 PM
|
0 responses
8 views
0 likes
|
Last Post
by DJ888
Yesterday, 10:57 PM
|
||
Started by MacDad, 02-25-2024, 11:48 PM
|
7 responses
159 views
0 likes
|
Last Post Yesterday, 10:23 PM | ||
Started by Belfortbucks, Yesterday, 09:29 PM
|
0 responses
8 views
0 likes
|
Last Post
by Belfortbucks
Yesterday, 09:29 PM
|
Comment