Testing EA that uses two pairs!

 
In a previous post, I asked a question whether or not it was possible to test an EA that is attached to one pair but opens trades in another by using the strategy tester. Gordon referred me to a post that talked about hedge trading and it gave me an idea which I was not able to put into action. I thought maybe you can help me overcome this limitation by giving me ideas on how to make this work. Here is my idea: When the sell or buy criteria are met in the EURUSD pair, I want to open a sell or buy order in the GBPUSD pair respectively. I thought of making two different EAs one to save the times of when these criteria happen in a file and another for placing or closing the orders at the times derived from the first EA. I know I have to use fileWrite and fileRead but there isn't enough information on these and I believe me I TRIED but in vane and I couldn't get the results I wanted. Would you be kind enough to tell me how I can do this?
EA1
if (sellcriterion)
save the current time in a file in the tester/files directory
if (buycriterion)
save the current time in a different file in the tester/files directory

EA2
has to check the times from the files one by one and if the time is right place orders accordingly


Any help in the form of guidance, tips, code, examples,etc. is really appreciated.

PS:I am currently testing my EA live and so far so good.
 
I think you are describing very well how it should be done by yourself.

FileWrite() 2 stamps MODE_WRITE|MODE_CSV (datetime + Bool) for Long/Short from EA 1 and then FileRead() MODE_READ|MODE_CSV in EA 2. Repeat in opposite direction.

It sounds like you know how to work with files already so you will probably make it.

It is really easy if you don´t confuse BINARY files with text files as I did and spent many days troubleshooting for nothing.

Please get back if it sounds confusing or if you would like some clarification.

Best wishes

/ McKeen
 
McKeen:

Please get back if it sounds confusing or if you would like some clarification.

The concept is very easy to get but since I don't have access to any examples of this used in a similar manner, I would really appreciate it if you could use this in a few lines of code as an example. Thanks!

 
farhang:

The concept is very easy to get but since I don't have access to any examples of this used in a similar manner, I would really appreciate it if you could use this in a few lines of code as an example. Thanks!

//+------------------------------------------------------------------+
//| do_pliku.mq4 |
//| crn |
//| |
//+------------------------------------------------------------------+
#property copyright "crn"
#property link "gaa1@poczta.fm"

int start()
{
//----

int plik=FileOpen(Period()+Symbol()+"dane_wskaznik.csv",FILE_CSV|FILE_WRITE,' ');
if(plik>0)
{
//for (int l = Bars; l>=0; l--)
for (int l = 0; l<=Bars-1; l++)
{
//int l=0;
double wskaznik=iCustom(0,0,"Mongol",21,3,0,0,l); //Indicator, Price or somthing
if(wskaznik == 2147483647 || 0){wskaznik = -1;}
FileWrite(plik,Time[l],wskaznik,Period() );
//Print(l);
}
FileClose(plik);
plik=0;
//Print(wskaznik);
}


return(0);
}
//+------------------------------------------------------------------+


My scripts for save price/indicator as CSV file.

I hope it will be helpfull

Reason: