newbee1713006039 Posted March 18, 2010 Report Share Posted March 18, 2010 Hello, I have an EA here and everything is working fine, except the "PairAppendix1" and "PairAppendix3" I have added. Tried it with BeamFX http://www.beamfx.com/metatrader/BeamFXMT4.exe which has the "b" added to the pairs and it does not work. Could someone please have a look what I have done wrong? EA is here: http://depositfiles.com/files/k8siu9o49 Thx in advance! regards Newbee Quote Link to comment Share on other sites More sharing options...
⭐ birt Posted March 18, 2010 Report Share Posted March 18, 2010 Re: [REQ] Can someone correct this Code? What exactly is not working? What error do you get? Just in case it helps you, here's some code that I wrote a while ago to properly figure out the prefix, join elements (if any) and suffix for a currency pair: string currencies[] = { "EUR", "USD", "CHF", "GBP", "JPY", "AUD", "CAD", "NZD", "HKD", "DKK", "NOK", "SEK", "SGD", "RUB", "RUR", "ZAR", "UAH", "RON", "MXN", "TRY", "PLN", "HUF", "PHP", "MTL", "HRK", "LVL", "CZK", "ILS", "LTL", "XAU", "XAG" }; string prefix = ""; string join = ""; string suffix = ""; string baseCurrency, quoteCurrency; string symbol = Symbol(); for (int j = 0; j < StringLen(symbol); j++) { for (int i = 0; i < ArraySize(currencies); i++) { int idx = StringFind(symbol, currencies[i], 0); if (idx >= 0 && idx <= j) { if (idx > 0) { prefix = StringSubstr(symbol, 0, idx); } baseCurrency = StringSubstr(symbol, idx, 3); break; } } if (StringLen(baseCurrency) > 0) { break; } } for (i = 0; i < ArraySize(currencies); i++) { int idx2 = StringFind(symbol, currencies[i], idx + 3); if (idx2 >= 0) { if (idx2 > idx + 3) { join = StringSubstr(symbol, idx + 3, idx2 - (idx + 3)); } quoteCurrency = StringSubstr(symbol, idx2, 3); suffix = StringSubstr(symbol, idx2 + 3); break; } } If you run the above code on your broker's EURUSD and the pair is wickedly named "booEUR-USDeww", after you run the above code, your prefix variable will contain "boo", your join variable will contain "-" and your suffix variable will contain "eww", while baseCurrency will be set to "EUR" and quoteCurrency to "USD". If you wanted to construct the most probable GBPUSD pair from there, you'd write myGBPUSDpair = prefix + "GBP" + join + "USD" + suffix; Quote Link to comment Share on other sites More sharing options...
San4x Posted March 18, 2010 Report Share Posted March 18, 2010 Re: [REQ] Can someone correct this Code? Nice one birt. Since there seems only a "b" to be added as suffix, perhaps this could do the trick as well: string Pair = StringSubstr(Symbol(), 0, 6); It extracts the first 6 characters from Symbol(), which is the current pair in the chart. Quote Thanks for the kudos...much appreciated! Link to comment Share on other sites More sharing options...
newbee1713006039 Posted March 19, 2010 Author Report Share Posted March 19, 2010 Re: [REQ] Can someone correct this Code? Would be great if someone could check my failure with "Appendix1" and "Appendix3" inside the code - fix it and reupload it to http://depositfiles.com. EA is here: http://depositfiles.com/files/k8siu9o49 Would be great. Thx in advance ;-) Newbee Quote Link to comment Share on other sites More sharing options...
San4x Posted March 19, 2010 Report Share Posted March 19, 2010 Re: [REQ] Can someone correct this Code? Can you describe the exact failure and what's needed to fix it? The more info the faster we can work. Perhaps it's a good idea to include the original code, and tell us what you were trying to achieve with adding new code to it. There might just be a simpler and better way.... Quote Thanks for the kudos...much appreciated! Link to comment Share on other sites More sharing options...
newbee1713006039 Posted March 19, 2010 Author Report Share Posted March 19, 2010 Re: [REQ] Can someone correct this Code? Can you describe the exact failure and what's needed to fix it? The more info the faster we can work. Perhaps it's a good idea to include the original code, and tell us what you were trying to achieve with adding new code to it. There might just be a simpler and better way.... When I add the EA to the chart of BeamFX, I always get the message: "Please enable all pairs on Market Watch Window". But all needed pairs are shown. Beamforex uses "b" after pairs, like GBPJPYb. Do not know what I have done wrong here. Newbee Quote Link to comment Share on other sites More sharing options...
⭐ birt Posted March 19, 2010 Report Share Posted March 19, 2010 Re: [REQ] Can someone correct this Code? It looks ok at the first sight. If I'm not mistaken, having both BuyPair1 and BuyPair2 set to false (which is the default) will result in the same error so you might want to check those. If at least one of them is set to true, temporarily add a "debug" print at the end of the init routine such as: Print ("Pair1 is " + Pair1 + " while Pair2 is " + Pair2); When you did that, run it and check the experts log, see if the Pair variables have the expected values. If they don't have the correct values, add similar Print lines everywhere and use them for debugging. Quote Link to comment Share on other sites More sharing options...
newbee1713006039 Posted March 19, 2010 Author Report Share Posted March 19, 2010 Re: [REQ] Can someone correct this Code? It looks ok at the first sight. If I'm not mistaken, having both BuyPair1 and BuyPair2 set to false (which is the default) will result in the same error so you might want to check those. If at least one of them is set to true, temporarily add a "debug" print at the end of the init routine such as: Print ("Pair1 is " + Pair1 + " while Pair2 is " + Pair2); When you did that, run it and check the experts log, see if the Pair variables have the expected values. If they don't have the correct values, add similar Print lines everywhere and use them for debugging. Sorry but the problem is not the BuyPair1 and BuyPair2, this works well. I only have the problem after I have added the Appendix1 and Appendix3 strings Newbee Quote Link to comment Share on other sites More sharing options...
⭐ birt Posted March 19, 2010 Report Share Posted March 19, 2010 Re: [REQ] Can someone correct this Code? In your init function, you have the following piece of code: { CloseBuyOrders(MagicNumber); CloseSellOrders(MagicNumber); return(0); } You're aware that return(0) will prevent further execution of the init function, thus it won't even reach the part of the code where you're adding the appendix to the pair, right? Are you also aware that you would've been able to quickly figure out the problem if you bothered trying what I said with the prints? Quote Link to comment Share on other sites More sharing options...
newbee1713006039 Posted March 19, 2010 Author Report Share Posted March 19, 2010 Re: [REQ] Can someone correct this Code? It looks ok at the first sight. If I'm not mistaken, having both BuyPair1 and BuyPair2 set to false (which is the default) will result in the same error so you might want to check those. If at least one of them is set to true, temporarily add a "debug" print at the end of the init routine such as: Print ("Pair1 is " + Pair1 + " while Pair2 is " + Pair2);. This code does not solve the problem. Still get the message: "Please enable all pairs on Market Watch Window". Quote Link to comment Share on other sites More sharing options...
⭐ birt Posted March 19, 2010 Report Share Posted March 19, 2010 Re: [REQ] Can someone correct this Code? First of all, that Print thing wasn't supposed to solve the problem, but to help you figure out what the problem was. Second, are you even reading what I'm writing? In my previous post I described how that extra return (0); at the beginning of the init() function is most likely what makes it not work. Did you try removing that? Quote Link to comment Share on other sites More sharing options...
newbee1713006039 Posted March 22, 2010 Author Report Share Posted March 22, 2010 Re: [REQ] Can someone correct this Code? Sorry guys, all you suggestions did not work. Quote Link to comment Share on other sites More sharing options...
⭐ birt Posted March 22, 2010 Report Share Posted March 22, 2010 Re: [REQ] Can someone correct this Code? I downloaded the BeamFX terminal, installed it, copied your EA, commented out the return(0); I mentioned above and guess what? It works. My conclusion is that you're either someone who doesn't really want to be helped or you're simply not very good at following instructions and don't want to admit it. I am done trying to help you, my patience supply has run out. Quote Link to comment Share on other sites More sharing options...
newbee1713006039 Posted March 22, 2010 Author Report Share Posted March 22, 2010 Re: [REQ] Can someone correct this Code? I downloaded the BeamFX terminal, installed it, copied your EA, commented out the return(0); I mentioned above and guess what? It works. My conclusion is that you're either someone who doesn't really want to be helped or you're simply not very good at following instructions and don't want to admit it. I am done trying to help you, my patience supply has run out. Hello birt, I tried it and it again, but it does not work on my platform. Do not know what the problem is. I will reinstall it and see what happens. thx a lot for your answer, that it works on your platform. newbee -- 22 Mar 2010, 21:54 -- I downloaded the BeamFX terminal, installed it, copied your EA, commented out the return(0); I mentioned above and guess what? It works. My conclusion is that you're either someone who doesn't really want to be helped or you're simply not very good at following instructions and don't want to admit it. I am done trying to help you, my patience supply has run out. Hello birt, after new installation of MT4, it works on my plattform as well. Thx a lot for your help ;-) Gave you kudos on all your posts here. newbee 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.