Login Page - Create Account

Support Board


Date/Time: Sat, 20 Apr 2024 15:08:41 +0000



Post From: Is There A Faster Way to Enter Custom Study Data Inputs

[2017-11-27 15:21:04]
ertrader - Posts: 641
For question 2 above, I've had the requirement too so I coded it using std::ifstream reading a text file. This is documented in C++ http://www.cplusplus.com/reference/fstream/ifstream/open/

There may be a better way but using global variables (variables before the SCDLLName call) worked. Then, within your normal code, setting your study variable equal the global variables. Worked like a charm for me!

float ReadTradeSignalParams(SCStudyInterfaceRef sc)
{
  std::ifstream input("tradesignalparameters11.txt");
  int LineNum, p, q, r, s, t, u;
  while (!input.eof())
  {
    input >> LineNum >> p >> q >> r >> s >> t >> u;
    if (LineNum == g_ControlLine) break;
  }

// set the global variables to local variable values that come from the text file
// Then, in your main code, reference the global variables for study inputs
// In your main code, you will need to have some type of counter or trigger so that you do not
// continually call this file read function.
// the variables below with a g_ are my global variables
// the g_ControlLine above was just a parameter value I look for in the input file to
// stop reading values in the text file. I have several hundred and sometimes thousands of rows to read in depending on the tests I am running

  g_Input1 = p;
  g_Input2 = q;  
  g_Input3 = r;  
  g_Input4 = s;
  g_Input5 = t;  
  g_Input6 = u;  
  
  return(0);    
}
Date Time Of Last Edit: 2017-11-27 15:44:20