How can I allow an EA on one currency to communicate with the EA on another? - page 2

 
Also should it be OrdersTotal()-1 or 0 for the latest order? Should it Be OrdersHistoryTotal()-1 or 0 for the latest historical order I think I better change the Histroical orders part.
 

1) Global Variables look them up in the mql4 reference

2) Files: Either use the file functions of MQL4 (reference) or Win-File for reading and writing anywhere on your pc.

3) Named Pipe: Look in your folder ...MQL4\Scripts\Examples\Pipes and search here for examples

 
 bool FragileSymbol()
{   
 bool Fragile=false;
 bool FragilePositive=false; 
 double HistLots;
 string LastSymbol;
 if(OrderSelect(0,SELECT_BY_POS,MODE_HISTORY)){if((OrderProfit() + OrderSwap() + OrderCommission())<0)LastSymbol=OrderSymbol();Fragile=true;}
 if(OrderSelect(0,SELECT_BY_POS,MODE_HISTORY)){if(OrderSymbol()==LastSymbol && (OrderProfit() + OrderSwap() + OrderCommission())>0){FragilePositive=true;HistLots=OrderLots();}}
 if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES)){if(OrderSymbol()==LastSymbol && FragilePositive && OrderLots()<HistLots)Fragile=false;FragilePositive=false;}
 return (Fragile);
} 
    
Simpler version with amended index, I might be able to make one based on the ticket number but I don't think it will be necessary.
 
gooly:

1) Global Variables look them up in the mql4 reference

2) Files: Either use the file functions of MQL4 (reference) or Win-File for reading and writing anywhere on your pc.

3) Named Pipe: Look in your folder ...MQL4\Scripts\Examples\Pipes and search here for examples


Sorry I know what global variables are, I should have just mentioned the last two.

Will the EAs be able to modify files and read files?

I'll look at pipes.

Woops fixed

if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES)){if(OrderSymbol()==LastSymbol && FragilePositive){Fragile=false;FragilePositive=false;}

Oddly enough this line is causing problems

 bool FragileSymbol()
{   
 bool Fragile=false;
 bool FragilePositive=false; 
 double HistLots;
 string LastSymbol;
 if(OrderSelect(0,SELECT_BY_POS,MODE_HISTORY)){if((OrderProfit() + OrderSwap() + OrderCommission())<0 && OrderSymbol()!=Symbol()){LastSymbol=OrderSymbol();Fragile=true;}}
 if(OrderSelect(0,SELECT_BY_POS,MODE_HISTORY)){if(OrderSymbol()==LastSymbol && (OrderProfit() + OrderSwap() + OrderCommission())>0){FragilePositive=true;HistLots=OrderLots();}}
 if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES)){if(OrderSymbol()==LastSymbol && FragilePositive && OrderLots()<HistLots)Fragile=false;FragilePositive=false;}
 return (Fragile);
}  


if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES)){if(OrderSymbol()==LastSymbol && FragilePositive){Fragile=false;FragilePositive=false;}

Oddly enough this line is causing problems

 
K I've fixed that line now.......by deleting it.
 

"Will the EAs be able to modify files and read files?"

Of course, but there is the time (update) problem of reading and writing - be aware of this!

 
 bool FragileSymbol()
{   
 bool Fragile=false;
 bool FragilePositive=false; 
 string LastSymbol;
 if(OrderSelect(0,SELECT_BY_POS,MODE_HISTORY)){if((OrderProfit() + OrderSwap() + OrderCommission())<0 && OrderSymbol()!=Symbol()){LastSymbol=OrderSymbol();Fragile=true;}}
 if(OrderSelect(0,SELECT_BY_POS,MODE_HISTORY)){if(OrderSymbol()==LastSymbol && (OrderProfit() + OrderSwap() + OrderCommission())>0)Fragile=false;}
 return (Fragile);
}

Fin.

Hope it works in back tests, it's a lot more streamline than before, so making it mql5 ready shouldn't be too hard.

 
gooly:

"Will the EAs be able to modify files and read files?"

Of course, but there is the time (update) problem of reading and writing - be aware of this!


I'm trading on daily time frame, will the time still be an issue?
 
MetaNt:

I'm trading on daily time frame, will the time still be an issue?

hard to believe
 
MetaNt:

Fin.

Hope it works in back tests, it's a lot more streamline than before, so making it mql5 ready shouldn't be too hard.


What you're trying to do looks like this :

//+------------------------------------------------------------------+
 bool FragileSymbol()
{   
 bool Fragile=false;
 bool FragilePositive=false; 
 string LastSymbol;
 if(!OrderSelect(0,SELECT_BY_POS,MODE_HISTORY))
 Print("Failed to select order, error : "+(string)GetLastError());
  else  
   {
   if((OrderProfit() + OrderSwap() + OrderCommission())<0 && OrderSymbol()!=Symbol())
      {
      LastSymbol=OrderSymbol();
      Fragile=true;
      return (Fragile);
      }
   else
   if(OrderSymbol()==LastSymbol && (OrderProfit() + OrderSwap() + OrderCommission())>0)Fragile=false;
   } 
 return (Fragile);
}
//+------------------------------------------------------------------+

Why are you trying to select the same order over and over again ?

This :

if(OrderSelect(0,SELECT_BY_POS,MODE_HISTORY))

will get the same result over and over.

It will return the order at position zero in the history pool.

Don't you want to select the most recent closed one or something?

I thought you want a second EA to open a position as soon as the first one did. Are you aiming at something else now?

Reason: