How to add Maximum spread into EA settings?

 

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

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

 

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

Reason: