![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Senior Member
|
Sorry to ask a basic programming question, but C# is not my native language.
![]() I want an array that looks like this: Array[1,534.2]="Some string value". So I have Array[number,number]=string. How do you do this in C#? I tried this: private double[,] = new Array[6,6]; But it seems that the array cannot have a string as a value.
Price-Dynamics.com
A NinjaTrader Official Partner Visit http://www.price-dynamics.com to learn more about the Rhythm Relay trading system. Yes, you can discretionary or auto-trade with 75%+ accuracy! Use our Contact Us page to request free access to our daily Trader's Lounge where you can see the system in action in a live account!
Last edited by cassb; 11-03-2008 at 08:00 AM.
|
|
|
|
|
|
#2 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
Please try
private string[,] myArray = new string[6,6];
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
|
Tried that:
Array = new string[6,6]; Array[0,534.2]="Test"; Compiling this causes this: Cannot implicitly convert type 'double' to 'int'. An explicit conversion exists (are you missing a cast?)
Price-Dynamics.com
A NinjaTrader Official Partner Visit http://www.price-dynamics.com to learn more about the Rhythm Relay trading system. Yes, you can discretionary or auto-trade with 75%+ accuracy! Use our Contact Us page to request free access to our daily Trader's Lounge where you can see the system in action in a live account! |
|
|
|
|
|
#4 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
My apologies, edited post below.
Also array indexes needed to be int not double. Note: these are basic C# programming question. Unfortunately we can't provide support level down to that level.
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
|
It wants integers for the array subscripts. I can't use a double value for a subscript. Maybe I need an array within an array? I don't understand why this concept is so complex in C#.
Think of what I'm trying to do as: Array[Bar Number,Price] = "Text"
Price-Dynamics.com
A NinjaTrader Official Partner Visit http://www.price-dynamics.com to learn more about the Rhythm Relay trading system. Yes, you can discretionary or auto-trade with 75%+ accuracy! Use our Contact Us page to request free access to our daily Trader's Lounge where you can see the system in action in a live account! |
|
|
|
|
|
#6 | |
|
Senior Member
|
Quote:
Just a note in case someone is looking at this thread in the future -- I decided to just convert the price to an integer and convert it back to double when needed. To convert to integer, where pricedecimals is the number of decimals in TickSize: x = Convert.ToInt16(price*(10^pricedecimals)) Array[0,x]="text" To reconvert back to price: price = Convert.ToDouble(x/(10^pricedecimals))
Price-Dynamics.com
A NinjaTrader Official Partner Visit http://www.price-dynamics.com to learn more about the Rhythm Relay trading system. Yes, you can discretionary or auto-trade with 75%+ accuracy! Use our Contact Us page to request free access to our daily Trader's Lounge where you can see the system in action in a live account! |
|
|
|
|
|
|
#7 |
|
Junior Member
Join Date: Oct 2012
Location: chennai
Posts: 1
Thanks: 0
Thanked 0 times in 0 posts
|
The mixed arrays type is removed from .NET 4.0. I have not really seen any use of mixed arrays.
.Net Training in chennai |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Mixed minute/daily time frames? | monpere | Strategy Development | 12 | 06-08-2011 04:10 PM |
| Array question... | funk101 | Indicator Development | 14 | 01-21-2009 07:37 AM |
| Array | pipsheker | General Programming | 1 | 05-24-2008 03:45 AM |
| Mixed time frames | cherriman | Strategy Development | 23 | 03-10-2008 07:03 AM |
| Indicator using mixed colors | kgillis23 | Strategy Development | 5 | 05-23-2007 02:07 PM |