Download MetaTrader 5

I need help on confirming whether this would run as I intend it to run

To add comments, please log in or register
Kevin Kim
35
Kevin Kim  

So, here's a general template for my EA 

So far, there seems to be no compiling errors and warnings ...  

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  

double

XYZ_Ask = MarketInfo("XYZ",MODE_ASK),

ABC_Bid = MarketInfo("ABC",MODE_BID),

..........

..Defining remaining variables... 

..........

DEF_Ask = MarketInfo("DEF",MODE_ASK); 

 

int OnInit()

{

while( Condition A || Condition B || ...... || Condition E ){

if(Condition A){       // Condition A would be a profitable trade signal

bool CURRENCY_XYZ = OrderSend("XYZ",OP_BUY,1,Ask,2,Ask-15*Point,Ask+15*Point);

bool  CURRENCY_ABC = OrderSend("ABC",OP_SELL,1,Bid,2,Bid+15*Point,Bid-15*Point);}

break;

.............

.. doing same for the remaining conditions ....

.............

  if(Condition B){

bool CURRENCY_DEF = OrderSend("DEF",OP_SELL,1,Bid,2,Bid+15*Point,Bid-15*Point);

bool CURRENCY_GHI = OrderSend"GHI",OP_Buy,1,Ask,2,Ask-15*Point,Ask+15*Point); }

break;

  };

 

if( ( OrderSend("XYZ",OP_BUY,1,Ask,2,Ask-15*Point,Ask+15*Point)) && (CURRENCY_ABC = OrderSend("ABC",OP_SELL,1,Bid,2,Bid+15*Point,Bid-15*Point)) ){

while( Condition F ){          // Condition F would be the optimal exit point

OrderClose( OrderSend("XYZ",OP_BUY,1,Ask,2,Ask-15*Point,Ask+15*Point),1,Bid,2);

OrderClose(  OrderSend("ABC",OP_SELL,1,Bid,2,Bid+15*Point,Bid-15*Point),1,Ask,2);

break;};

}; 

.......

.... doing same for remaining

......

if( (  OrderSend("DEF",OP_SELL,1,Bid,2,Bid+15*Point,Bid-15*Point) ) && (CURRENCY_GHI = OrderSend"GHI",OP_Buy,1,Ask,2,Ask-15*Point,Ask+15*Point)) ){

while( Condition X ){

OrderClose(  OrderSend("DEF",OP_SELL,1,Bid,2,Bid+15*Point,Bid-15*Point),1,Ask,2);

OrderClose(  OrderSend"GHI",OP_Buy,1,Ask,2,Ask-15*Point,Ask+15*Point),1,Bid,2);

break;};

}; 

 

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 

 

So, just to simply explain, the EA would screen continuously for any possible profitable conditions called Condition A or Condition B .... as shown above and would execute a long or short hedging on multiple currencies

 depending on which condition is met. Then, the EA would then screen continuously for optimal exit point, then would close the corresponding orders. 

 

So, here are just a quick questions.

 

Would it work if I simply put the entire OrderSend() function inside OrderClose() function where the ticket number is located? if not, how would I go about fixing it? 

Also, if the EA reads the whole code and executes a trade, will it go back to the beginning automatically and repeat the whole process? or do I need to turn off and turn EA on again? 

To add comments, please log in or register