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
Post web links to other trader's signals and make profit
Kevin Kim
Kevin Kim 2016.04.19 00:05 

So, here's a general template for my EA 

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



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);}



.. 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); }




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);




.... 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);






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