Click here to Skip to main content
15,909,437 members
Home / Discussions / C#
   

C#

 
AnswerRe: what is the optimal method for handling time-triggered processing Pin
Luc Pattyn9-Mar-10 11:09
sitebuilderLuc Pattyn9-Mar-10 11:09 
AnswerRe: what is the optimal method for handling time-triggered processing Pin
AspDotNetDev9-Mar-10 12:18
protectorAspDotNetDev9-Mar-10 12:18 
GeneralRe: what is the optimal method for handling time-triggered processing Pin
TimWallace9-Mar-10 13:39
TimWallace9-Mar-10 13:39 
AnswerRe: what is the optimal method for handling time-triggered processing Pin
PIEBALDconsult9-Mar-10 13:39
mvePIEBALDconsult9-Mar-10 13:39 
QuestionSave an object to my exe? Pin
Matthew Klein9-Mar-10 5:38
Matthew Klein9-Mar-10 5:38 
AnswerRe: Save an object to my exe? Pin
Not Active9-Mar-10 6:47
mentorNot Active9-Mar-10 6:47 
AnswerRe: Save an object to my exe? Pin
Dan Mos9-Mar-10 6:47
Dan Mos9-Mar-10 6:47 
AnswerRe: Save an object to my exe? Pin
Luc Pattyn9-Mar-10 7:09
sitebuilderLuc Pattyn9-Mar-10 7:09 
GeneralRe: Save an object to my exe? Pin
Som Shekhar9-Mar-10 7:26
Som Shekhar9-Mar-10 7:26 
GeneralRe: Save an object to my exe? Pin
Luc Pattyn9-Mar-10 9:42
sitebuilderLuc Pattyn9-Mar-10 9:42 
AnswerRe: Save an object to my exe? Pin
Dave Kreskowiak9-Mar-10 7:32
mveDave Kreskowiak9-Mar-10 7:32 
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 

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.