Click here to Skip to main content
16,004,890 members
Home / Discussions / C#
   

C#

 
GeneralRe: beginner question: foreach .. else? Pin
harold aptroot9-Mar-10 4:19
harold aptroot9-Mar-10 4:19 
AnswerRe: beginner question: foreach .. else? Pin
StarBP10-Mar-10 10:05
StarBP10-Mar-10 10:05 
QuestionFind in memory string another process Pin
pawel_19809-Mar-10 2:00
pawel_19809-Mar-10 2:00 
GeneralRe: Find in memory string another process Pin
harold aptroot9-Mar-10 2:09
harold aptroot9-Mar-10 2:09 
GeneralRe: Find in memory string another process Pin
pawel_19809-Mar-10 2:23
pawel_19809-Mar-10 2:23 
GeneralRe: Find in memory string another process Pin
harold aptroot9-Mar-10 2:41
harold aptroot9-Mar-10 2:41 
GeneralRe: Find in memory string another process Pin
pawel_19809-Mar-10 3:33
pawel_19809-Mar-10 3:33 
QuestionNeed to try casting it, or declaring tmp as double and then parsing double values into it later on Pin
suprsnipes9-Mar-10 1:22
suprsnipes9-Mar-10 1:22 
Hi,

I know I'm really close but not just quite there yet.

I'm reading data from a text file with the following code and as a newbie I am advancing bit by bit and I've come unstuck...again.

What I want to do now is in place of int num = 4991 I want to use Close[0] (which is a double) to compare against tmp (an int) but have absolutely no idea how to go about it.

Here is my code.

// 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 = "";


       <big>int num = 4991;</big>
       <big>private int tmp, res = 0;</big>
       private int? diff = null;

       #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[1000];
       }

       /// <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");

           string [] split = readText.Split(new Char [] {';'});
               foreach (string s in split)
               {
                   count++;
                   tmp = int.Parse(s);
                   levels[count] = tmp;

                   if (tmp > <big>num</big>)
                   {
                       if(diff == null)
                           diff = <big>num</big>;
                       if ((tmp - <big>num</big>) < diff)
                       {
                           res = tmp;
                           diff = tmp - <big>num</big>;
                       }
                   }
               }
               Print(res);
       }


Really appreciate the help,
suprsnipes
AnswerRe: Need to try casting it, or declaring tmp as double and then parsing double values into it later on Pin
Luc Pattyn9-Mar-10 1:37
sitebuilderLuc Pattyn9-Mar-10 1:37 
GeneralRe: Need to try casting it, or declaring tmp as double and then parsing double values into it later on Pin
suprsnipes9-Mar-10 2:24
suprsnipes9-Mar-10 2:24 
GeneralRe: Need to try casting it, or declaring tmp as double and then parsing double values into it later on Pin
Luc Pattyn9-Mar-10 2:28
sitebuilderLuc Pattyn9-Mar-10 2:28 
GeneralRe: Need to try casting it, or declaring tmp as double and then parsing double values into it later on Pin
suprsnipes9-Mar-10 3:07
suprsnipes9-Mar-10 3:07 
QuestionQuestions About Form Closing Event In winform Pin
jdnx9-Mar-10 0:15
jdnx9-Mar-10 0:15 
AnswerRe: Questions About Form Closing Event In winform Pin
Luc Pattyn9-Mar-10 0:18
sitebuilderLuc Pattyn9-Mar-10 0:18 
Questionidentify email sent or not Pin
NarendraSinghJTV8-Mar-10 23:55
NarendraSinghJTV8-Mar-10 23:55 
AnswerRe: identify email sent or not Pin
Gerrit4449-Mar-10 2:25
Gerrit4449-Mar-10 2:25 
GeneralRe: identify email sent or not [modified] Pin
NarendraSinghJTV9-Mar-10 21:02
NarendraSinghJTV9-Mar-10 21:02 
GeneralRe: identify email sent or not Pin
Gerrit4449-Mar-10 21:22
Gerrit4449-Mar-10 21:22 
GeneralRe: identify email sent or not [modified] Pin
Gerrit4449-Mar-10 21:25
Gerrit4449-Mar-10 21:25 
GeneralRe: identify email sent or not Pin
NarendraSinghJTV9-Mar-10 21:30
NarendraSinghJTV9-Mar-10 21:30 
GeneralRe: identify email sent or not Pin
NarendraSinghJTV9-Mar-10 21:37
NarendraSinghJTV9-Mar-10 21:37 
GeneralRe: identify email sent or not Pin
Gerrit4449-Mar-10 21:49
Gerrit4449-Mar-10 21:49 
GeneralRe: identify email sent or not Pin
NarendraSinghJTV9-Mar-10 22:13
NarendraSinghJTV9-Mar-10 22:13 
GeneralRe: identify email sent or not Pin
Gerrit4449-Mar-10 23:16
Gerrit4449-Mar-10 23:16 
GeneralRe: identify email sent or not Pin
NarendraSinghJTV9-Mar-10 23:19
NarendraSinghJTV9-Mar-10 23:19 

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.