swordfish Posted November 20, 2011 Report Posted November 20, 2011 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.
masterdeki Posted November 21, 2011 Report Posted November 21, 2011 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.
swordfish Posted November 21, 2011 Author Report Posted November 21, 2011 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?
szelee Posted November 21, 2011 Report Posted November 21, 2011 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. prosper4all 1
prosper4all Posted January 12, 2012 Report Posted January 12, 2012 This information is very helpful, thank you.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now