Download MetaTrader 5

Strategy Tester - File Output

To add comments, please log in or register
nerobot
85
nerobot 2010.07.21 12:17 

Hi,


Not sure if this is a bug, or if I'm just trying to do something that is not possible. Below is a very simple EA code, to run on the tester to see if I can use the file output.


int OnInit(){

 int filePtr = FileOpen("FileOutput.txt", FILE_CVS|FILE_WRITE);

 FileWrite(filePtr, 1, 2, 3);

 FileClose(filePtr);


 return 0;

}


When run in a demo account, this works fine, but when I run it in the tester, the file is not even produced. Is file I/O even possible when using the tester?


Regards,


Steven

Get in touch with developers using Service Desk!
  • www.mql5.com
We therefore attach great importance to all user reports about issues in our programs and try to answer each one of them.
Rashid Umarov
Admin
11989
Rashid Umarov 2010.07.21 12:40  
Try to insert code properly.
MQL5.community - User Memo
  • 2010.02.25
  • MetaQuotes Software Corp.
  • www.mql5.com
You have just registered and most likely you have questions such as, "How do I insert a picture to my a message?" "How do I format my MQL5 source code?" "Where are my personal messages kept?" You may have many other questions. In this article, we have prepared some hands-on tips that will help you get accustomed in MQL5.community and take full advantage of its available features.
nerobot
85
nerobot 2010.07.21 12:42  
int OnInit(){

 int filePtr = FileOpen("FileOutput.txt", FILE_CVS|FILE_WRITE);

 FileWrite(filePtr, 1, 2, 3);

 FileClose(filePtr);


 return 0;

}


Hope that's clearer.


Steven


nerobot
85
nerobot 2010.07.21 12:46  

Sorry, just realised that the file will is opened in a different folder, under the tester folders. Sorry about that. That should help me figure out my other problem.


Steven

Bogdan Caramalac
1112
Bogdan Caramalac 2010.07.30 15:05  

I did the same thing and I can't find the file.

int OnInit()
  {
   if (DealHandlerDevice.IsSetup()==false)
     DealHandlerDevice.Setup();
   CreateInitialPyramid(Symbol());
   filehandle=FileOpen("drawdowns.txt",FILE_COMMON||FILE_ANSI||FILE_WRITE);
   return(0);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   double p=GlobalPips();
   p=GlobalPips();
   if (p<drawdown)
     drawdown=p;
   if (p>=Target)
     {
      FileWrite(filehandle,drawdown);
      //Print("Profit ",p," > target ",Target);
      CloseAll();
      CreateInitialPyramid(Symbol());
      drawdown=9999999999.99;
     }
   
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   FileClose(filehandle);
  }

If the backtest is stopped before end,  files are not written?

 

Slava
Moderator
6915
Slava 2010.07.30 15:44  
TheEconomist:

If the backtest is stopped before end,  files are not written?

Investigation needed. We'll check it
Bogdan Caramalac
1112
Bogdan Caramalac 2010.07.30 16:25  
Also (offtopic) : Why, if backtest is stopped before end, there is no Results tab?
Slava
Moderator
6915
Slava 2010.07.30 17:36  
TheEconomist:
Also (offtopic) : Why, if backtest is stopped before end, there is no Results tab?
We don't know the reason of interrupt. Therefore, agent should be stopped immediately and quickly
Bogdan Caramalac
1112
Bogdan Caramalac 2010.07.30 22:22  
No, I meant, If I stop it by clicking on Stop, I should see the Results tab containing what was done until that moment.
Bogdan Caramalac
1112
Bogdan Caramalac 2010.07.31 18:17  
File issue solved: it cannot make the file if operators are || . Must be only bitwise ( | ).
Slava
Moderator
6915
Slava 2010.08.02 13:27  
TheEconomist:
No, I meant, If I stop it by clicking on Stop, I should see the Results tab containing what was done until that moment.

We'll think about it.

Could you please write your suggestion to ServiceDesk 

12
To add comments, please log in or register