Jump to content

⤴️-Paid Ad- Check advertising disclaimer here. Add your banner here.🔥

Recommended Posts

Posted
I need help to insert a line to limit the spread for opening a trade.

I tried this but it did not work:

extern double MaxSpreadPips = 2.2;

 

Thank you.

We must see some more code to be able to help you,this is just initialisation of double but where you use it in code,what conditions...?Give us some more code.

Posted
We must see some more code to be able to help you,this is just initialisation of double but where you use it in code,what conditions...?Give us some more code.

 

Ah, yes. I need to compare bid/ask difference with the user set input maxspreadpips. My question is general so I can insert the code in all the EAs that are not limiting the spreads. There must be a standard block of IF_THEN routine to limit the spread. Take the simple moving average EA in MT4 for example. What do you add so that the maxspreadpips will be active?

Posted

You must first add the following:

 

int Spread = MarketInfo(Symbol(),MODE_SPREAD);

 

then your programming logic, example:

 

if (Spread > MaxSpreadPips) return (0); // Do not trade if spread more than 2.2pips

 

For 4 digit platform you should set MaxSpreadPips = 2.2, and 5 digit platform you set it to MaxSpreadPips = 22;

 

Hope this help.

  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


⤴️-Paid Ad- Check advertising disclaimer here. Add your banner here.🔥

×
×
  • Create New...