Announcement

Collapse
No announcement yet.

programming question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • programming question

    Howdy,

    I've built a script that reads a text file containing position information in a text delimited format regarding my account at the brokerage while trading. It seems to be CPU intensive and combined with 9 currency charts running seems to be too much for my computer. This text file is written out from an API connection to our account. I run this script on a 1 second chart as it supplies seconds. minutes and hours to my one hour trading charts through a global variable. Text file is in the following format and contains specific trade entry price, stop price, direction, lots traded, profit etc.

    GBPJPY A0-FX|S|143.77|95.40000000001974|-100000.0|1.43770000000000|156693896|100000|144.89| B
    EURJPY A0-FX|S|115.05|116.6|-100000.0|1.1505E7|156693876|100000|116.1|B

    in premain i have
    fl = new File( "broker.account.report" );
    CurrencyValue = new Array("EUR A0-FX", "AUD A0-FX", "JPY A0-FX", "CHF A0-FX", "GBP A0-FX", "CAD A0-FX", "GBPJPY A0-FX", "NZD A0-FX", "EURJPY A0-FX");

    in main I have

    if(fl.exists()){
    for (x=0; x<CurrencyValue.length; x++){ // we grab a currency and begin going through the text file
    nMyValue = CurrencyValue[x];
    fl.open( "rt" );
    var line;
    trading = false;
    while ( !fl.eof()){
    line = fl.readln();
    if (line != null) {
    var sline = line.split("|");
    if (nMyValue == sline[0]){

    /////////////////////////////////
    here we search to see if the currency is found in the text file, indicating it is in trade, and this information is passed to that particular chart using a global variable. We also parse out the information and perform various tasks and display the information on the one second chart listing all current positions.
    ////////////////////////////////

    }
    }
    if(fl.eof() && !trading){
    ///////////////////////////////
    here we get to the end of the file and find no matches and pass the fact that the current symbol being looked for is not in a trade and this information is sent to the particular chart trading that currency using a global variable. This is done in order for the chart to be taken out of a trade in case we stopped out or the trade has dissappeared for any reason.
    }
    }
    fl.close();
    }
    }

    I believe that although this works, there must be a better, less CPU intensive way to do this but it escapes me. If any of you programming gurus hava any ideas - your thoughts would be greatly appreciated.

    Thanks in advance,
    Chris
Working...
X