swordfish Posted November 20, 2011 Report Share 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 Link to comment Share on other sites More sharing options...
masterdeki Posted November 21, 2011 Report Share 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 Link to comment Share on other sites More sharing options...
swordfish Posted November 21, 2011 Author Report Share 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 Link to comment Share on other sites More sharing options...
szelee Posted November 21, 2011 Report Share 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 Link to comment Share on other sites More sharing options...
prosper4all Posted January 12, 2012 Report Share Posted January 12, 2012 This information is very helpful, thank you. Quote Link to comment Share on other sites More sharing options...
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.