Please can you help me providing a sample of code to do that:
I want to check if into my txt there is "OK" before calculate the indicator on the chart. If != OK ninjatrader indicator has to read again the file until found "OK". When OK, the indicator has to start your process.
I tried with the code below but the indicator doesn't exit the loop and all crashes (i've put the code into state.dataloaded):
while(Testo5 != "OK"){ // if (!File.Exists(path5)) // { // // If file does not exist, let the user know // Print("File does not exist."); // return; // } // /* The try-catch block is used for error handling. // In this case it is used to ensure you only have one stream object operating on the same file at any given moment. */ // try // { // // Sets the file the StreamReader will read from // sr5 = new System.IO.StreamReader(path5); // string line5; // // Read lines and calculate the current day's OHLC from the file. While loop will go through the whole file. // while ((line5 = sr5.ReadLine()) != null) // { // Testo5 = File.ReadAllText(path5); // } // } // catch (Exception e) // { // // Outputs the error to the log // Log("You cannot write and read from the same file at the same time. Please remove SampleStreamWriter.", NinjaTrader.Cbi.LogLevel.Error); // Print(e.ToString()); // } // if (sr5 != null) // { // sr5.Dispose(); // sr5 = null; // }
Comment