Click here to Skip to main content
15,898,134 members
Home / Discussions / C#
   

C#

 
AnswerRe: Save an object to my exe? Pin
Matthew Klein9-Mar-10 7:44
Matthew Klein9-Mar-10 7:44 
AnswerRe: Save an object to my exe? Pin
#realJSOP9-Mar-10 8:40
professional#realJSOP9-Mar-10 8:40 
AnswerRe: Save an object to my exe? Pin
AspDotNetDev9-Mar-10 12:44
protectorAspDotNetDev9-Mar-10 12:44 
AnswerRe: Save an object to my exe? Pin
AspDotNetDev9-Mar-10 12:57
protectorAspDotNetDev9-Mar-10 12:57 
GeneralRe: Save an object to my exe? Pin
Matthew Klein9-Mar-10 13:23
Matthew Klein9-Mar-10 13:23 
QuestionComparing things with null - but not for equality Pin
harold aptroot9-Mar-10 5:05
harold aptroot9-Mar-10 5:05 
AnswerRe: Comparing things with null - but not for equality Pin
Dan Mos9-Mar-10 5:33
Dan Mos9-Mar-10 5:33 
QuestionCode is Rounding Down instead of Rounding Up Pin
suprsnipes9-Mar-10 4:15
suprsnipes9-Mar-10 4:15 
Hi,

I am reading a text file successfully with the code below but the result is rounding down instead of rounding up I have tried to use Math.Ceiling to resolve this issue and have now come unstuck. Appreciate the help.

   [Description("Displays Levels")]
    public class MyCustomIndicator2 : Indicator
    {
        #region Variables
        // Wizard generated variables
        // User defined variables (add any user defined variables below)
		private string path = Cbi.Core.UserDataDir.ToString() + "PIn.txt";
		private int[] levels;
		private int count = 0;
		private string readText = "";
		
		private int roundedValue;
		private	int diff = int.MaxValue;
   		private	int tmp, res = 0;
   		
		
        #endregion

        /// <summary>
        /// This method is used to configure the indicator and is called once before any bar data is loaded.
        /// </summary>
        protected override void Initialize()
        {
            CalculateOnBarClose	= true;
            Overlay				= true;
            PriceTypeSupported	= false;	
			levels 				= new int[100000];
        }

        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            // Use this method for calculating your indicator values. Assign a value to each
            // plot below by replacing 'Close[0]' with your own formula.
			
			readText = File.ReadAllText("C:\\PIn.txt");
			
			int roundedValue = ((int)Math.Ceiling(Close[0])); 
			
			string [] split = readText.Split(new Char [] {';'});
				foreach (string s in split)
				{
					count++;
					tmp = int.Parse(s);
					levels[count] = tmp;
					
					if (tmp > roundedValue)
					{
						if(diff == null)
							diff = roundedValue;
						if ((tmp - roundedValue) < diff)
						{
							res = tmp;
							diff = tmp - roundedValue;
						}
					}
				}
				Print(res);
        }

        #region Properties

        #endregion
    }
}


Regards,
suprsnipes
GeneralRe: Code is Rounding Down instead of Rounding Up Pin
harold aptroot9-Mar-10 4:20
harold aptroot9-Mar-10 4:20 
AnswerRe: Code is Rounding Down instead of Rounding Up Pin
Richard MacCutchan9-Mar-10 4:42
mveRichard MacCutchan9-Mar-10 4:42 
AnswerRe: Code is Rounding Down instead of Rounding Up Pin
PIEBALDconsult9-Mar-10 4:44
mvePIEBALDconsult9-Mar-10 4:44 
AnswerRe: Code is Rounding Down instead of Rounding Up Pin
Luc Pattyn9-Mar-10 4:46
sitebuilderLuc Pattyn9-Mar-10 4:46 
GeneralRe: Code is Rounding Down instead of Rounding Up Pin
Richard MacCutchan9-Mar-10 6:19
mveRichard MacCutchan9-Mar-10 6:19 
GeneralRe: Code is Rounding Down instead of Rounding Up Pin
Luc Pattyn9-Mar-10 6:37
sitebuilderLuc Pattyn9-Mar-10 6:37 
GeneralRe: Code is Rounding Down instead of Rounding Up Pin
Richard MacCutchan9-Mar-10 7:38
mveRichard MacCutchan9-Mar-10 7:38 
GeneralRe: Code is Rounding Down instead of Rounding Up Pin
Luc Pattyn9-Mar-10 9:41
sitebuilderLuc Pattyn9-Mar-10 9:41 
AnswerRe: Code is Rounding Down instead of Rounding Up Pin
Rob Philpott9-Mar-10 6:10
Rob Philpott9-Mar-10 6:10 
AnswerRe: Code is Rounding Down instead of Rounding Up Pin
suprsnipes9-Mar-10 21:41
suprsnipes9-Mar-10 21:41 
QuestionPasspoint: Robust Discretization Pin
einsteinmow9-Mar-10 3:17
einsteinmow9-Mar-10 3:17 
AnswerRe: Passpoint: Robust Discretization Pin
R. Giskard Reventlov9-Mar-10 4:08
R. Giskard Reventlov9-Mar-10 4:08 
GeneralRe: Passpoint: Robust Discretization Pin
EliottA9-Mar-10 5:05
EliottA9-Mar-10 5:05 
QuestionDataBinding issue Pin
GDavy9-Mar-10 3:17
GDavy9-Mar-10 3:17 
AnswerRe: DataBinding issue Pin
darkelv9-Mar-10 4:06
darkelv9-Mar-10 4:06 
GeneralRe: DataBinding issue Pin
GDavy9-Mar-10 20:06
GDavy9-Mar-10 20:06 
QuestionC# database connection Pin
2010JohnFByers9-Mar-10 3:15
2010JohnFByers9-Mar-10 3:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.