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. Quote
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. Quote
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? Quote
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 Quote
prosper4all Posted January 12, 2012 Report Posted January 12, 2012 This information is very helpful, thank you. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.