Announcement

Collapse
No announcement yet.

*txt file output

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

  • *txt file output

    i wrote a *efs file for automated trading and I need a *.txt output file (I´m working with ninjatrader, which is reading the *.txt file)

    The output contens of the *.txt-file for Ninja-using is exact :

    "DAX","BUY","2","1","SCALE","MKT","0","0","2","5", "3","2","TRUE","0","0",

    - I need exact this order and in quotation marks

    In my *.efs I wrote:
    .
    .
    .
    ninjaEntry.open("w");
    ninjaEntry.writeln (""DAX","BUY","2","1","SCALE","MKT","0","0","2","5 ","3","2","TRUE","0","0",")
    ninjaEntry.close();
    .
    .
    .
    it is not accepted by *.efs. If I write ("DAX,BUY,2,1,.....") it is accept by *.efs, I get the output DAX, BUY, 2,1,....but I need in my output-file "DAX","BUY"....all in quotation marks


    What can I do?



    All the best

  • #2
    Hi Torso,

    I have never written a script to send output to a text file, but to put quotes around text in the formula output windo you need to use the 2 character sequence \" to get a " symbol to display. My guess is that this would also work when sending text to a file.

    I used this test code:

    debugPrintln("\"TEST\",\"test\"");

    and got this display:

    "TEST","test"

    In your case, you would need to use something like this:

    ("\"DAX\",\"BUY\"")

    Dale Sullivan

    Comment


    • #3
      I've been thru this before...

      I've been thu this before with EFS and I am including a bunch of code that should for for NT3.

      All of this is designed for trading the e-mini. You'll notice the "ES" in all of the functions - this represents the e-mini.

      There is also the "NTEnabled" variable (which is a true/false switch). This switch is used to enable the writing of the files to NT3.

      You'll probably have questions, but this is the working code that I use.

      If you have any questions, please let me know...

      PHP Code:
      function WriteNTFile(OrderTypeContractsPTLevel) {
      if (
      NTEnabled) {
        var 
      = new File("order.txt");
           if (
      OrderType == "BUY") {
            if (
      CheckStateNTFile() != 1) {
             if (
      /*(CheckStateNTFile() == 0) || */(CheckStateNTFile() == 2) || (CheckStateNTFile() == -1)) {
               
      // close/cancel current order
                
      WriteNTCloseFile();
                
      WriteNTCancelFile();
             }
             
      debugPrintln("Executing Order "+OrderType+":"+Contracts);
             
      drawShapeRelative(0low()-0.75Shape.UPARROWnullColor.limeShape.ONTOPBarCount+"LongArrow");
             
      f.open("wt");
                 
      f.writeln("ES,"+Contracts+",GTC,"+OrderType+",MKT,0,0,,,,,"+Simulation+",,");
             
      f.close();
             
      StrategyisInTrade true;
             
      StrategyisShort false;
             
      StrategyisLong true;
             
      AdjStopNeeded true;
             
      AdjStopStage 0;
             
      //TradePending = true;
            
      }
           }
           if (
      OrderType == "SELL") {
            if (
      CheckStateNTFile() != -1) {
             if (
      /*(CheckStateNTFile() == 0) || */(CheckStateNTFile() == 2) || (CheckStateNTFile() == 1)) {
               
      // close/cancel current order
                
      WriteNTCloseFile();
                
      WriteNTCancelFile();
             }
             
      debugPrintln("Executing Order "+OrderType+":"+Contracts);
             
      drawShapeRelative(0high()+0.75Shape.DOWNARROWnullColor.redShape.ONTOPBarCount+"ShortArrow");
             
      f.open("wt");
                 
      f.writeln("ES,"+Contracts+",GTC,"+OrderType+",MKT,0,0,,,,,"+Simulation+",,");
      //           f.writeln('"ES","'+OrderType+'","'+Contracts+'","0","BRACKET","MKT","0","'+nStopPrice+'","'+PTLevel+'","0","5","0","FALSE","0","0",');
             
      f.close();
             
      StrategyisInTrade true;
             
      StrategyisShort true;
             
      StrategyisLong false;
             
      AdjStopNeeded true;   
             
      AdjStopStage 0;
            
      // TradePending = true;
            
      }
           }
      //     WriteNTStopAdjustFile();
      }
      }

      function 
      WriteNTCloseFile() {
       if (
      NTEnabled) {
        var 
      = new File("close.txt");
                      
      f.open("wt");
                         
      f.writeln("ES");
                      
      f.close();
        
      debugPrintln(vHour+":"+vMin+" : Close Issued");
             
      StrategyisInTrade false;
             
      StrategyisShort false;
             
      StrategyisLong false;
       }
      }

      function 
      WriteNTStopAdjustFile(NTTypeType) {
      if (
      NTEnabled) {
        if (
      AdjStopNeeded) {
        if ((
      CheckStateNTFile() == 1) || (CheckStateNTFile() == -1)) {  
         var 
      = new File("order.txt");
          if(!
      f.exists()) {  
            if (
      NTType == 0) {
                      
      f.open("wt");
                         
      f.writeln("ES,"+DefEntryContracts+",GTC,"+Type+",STP,0,"+nStopPrice+",,,,,"+Simulation+",,");
                      
      //   f.writeln("ES,NEW1,"+nPTPrice+","+nStopPrice+",");
                      
      f.close();
             
      debugPrintln(vHour+":"+vMin+" : Stop Adj. Issued"+nStopPrice );
            }
            if (
      NTType == 1) {
                      
      f.open("wt");
                         
      f.writeln("ES,"+DefEntryContracts+",GTC,"+Type+",STPLMT,"+nPTPrice+",0,,,,,"+Simulation+",,");
                      
      //   f.writeln("ES,NEW1,"+nPTPrice+","+nStopPrice+",");
                      
      f.close();
             
      debugPrintln(vHour+":"+vMin+" : PT Adj. Issued"+nPTPrice );
            }
           
      AdjStopStage +=1;
           if (
      AdjStopStage 1) {  AdjStopNeeded false;  }
          }
        }
        }
      }
      }


      function 
      WriteNTCancelFile() {
      if (
      NTEnabled) {
        var 
      = new File("cancel.txt");
                      
      f.open("wt");
                         
      f.writeln("ES");
                      
      f.close();
        
      debugPrintln(vHour+":"+vMin+" : Cancel Issued");
      }
      }


      function 
      CheckStateNTFile() {
      if (
      NTEnabled) {
      var 
      returnvalue 0;
        
      //  this FORCES it to open "ESupdate.exe" - for the E-mini.
        //  you can change this filename to the symbol you want to trade.
        
      var = new File("ESupdate.txt");
              if(
      f.exists()) {
                      
      f.open("rt");
                       var 
      stateline;
                         
      stateline f.readln();
                      
      f.close();
                var 
      PosCount stateline.split(",");
             
      //   debugPrintln(" "+PosCount[0]+" : "+stateline);
                
      if (PosCount[0] == '"FLAT"') {
                 
      returnvalue 0;
                 
      StrategyisInTrade false;
                 
      StrategyisShort false;
                 
      StrategyisLong false;
                } else if (
      PosCount[0] == '"PENDING"') {
                 
      returnvalue 2;
                } else if (
      PosCount[0] == '"LONG"') {
                 
      returnvalue 1;
                 
      StrategyisInTrade true;
                 
      StrategyisShort false;
                 
      StrategyisLong true;
                } else if (
      PosCount[0] == '"SHORT"') {
                 
      returnvalue = -1;
                 
      StrategyisInTrade true;
                 
      StrategyisShort true;
                 
      StrategyisLong false;
                }
              } else {
                 
      returnvalue 0;
              
      //   debugPrintln("File Does Not Exist");
              
      }
            
      //  debugPrintln("NT Status :"+returnvalue);
          
      return (returnvalue);
      }

      Brad Matheny
      eSignal Solution Provider since 2000

      Comment


      • #4
        Brad,

        Can you check your email I just sent you a message, let me know
        asap

        Regards
        Spam

        Comment

        Working...
        X