Download MetaTrader 5

How to add Maximum spread into EA settings?

To add comments, please log in or register
Peter Kot
25
Peter Kot  

Anyone know how to configure  mq4 file, so I can choose and change anytime  maximum spread ?

I only managed to create the  icon in the EA settings:

 extern double   MaxSpread  = 5;

but I can`t figure out the rest of the settings...

Thank you

Desmond Obafemi
12
Desmond Obafemi  
Peter Kot:

Anyone know how to configure  mq4 file, so I can choose and change anytime  maximum spread ?

I only managed to create the  icon in the EA settings:

 extern double   MaxSpread  = 5;

but I can`t figure out the rest of the settings...

Thank you

input int    MaxSpread        = 20; // Enter Maximum allowed spread


double SymSpread = MarketInfo(Symbol(), MODE_SPREAD); // This will Obtain broker Spread for current pair

if(MaxSpread > 0 && MaxSpread <= SymSpread) // This part compares broker spread with maximum allowed spread, and refuse trade if maxspread is exceeded

{

Print("Spread is greater than Maximum allowed Spread");

return;} 

Osama Shaban
1589
Osama Shaban  

You need to write at the beginning of the start( ) the following ...

double spread = MarketInfo(Symbol(),MODE_SPREAD);

In the if( ) condition line of opening your order add to the conditions the spread one as the following ...

if (... && ... && ... && spread <= MaxSpread && ... )
  OpenYourByOrSellOrder();

...
...
...

If you can't do this, no other way rather than uploading your mq4 file here.

Good luck

To add comments, please log in or register