Broker-specific symbols

Posted By: boatman

Broker-specific symbols - 04/27/14 12:04

Hi everyone

Just wanted to share an experience about broker-specific asset symbols while setting up a simulated broker account.

My broker (Think Forex) uses a suffix for its currency instruments based on the type of account you have with them. For my account, the suffix 'pro' is added. So the EUR/USD instrument becomes EURUSDpro.

In order to use the correct price history, I altered Zorro's EA to capture the correct asset names as suggested in the manual:

string assetFix(string Asset)
{

if(Asset == "AUD/USD") return("AUDUSDpro");
if(Asset == "EUR/USD") return("EURUSDpro");

etc

Unlike the currencies, the broker's indices match the indices used in the strategy. However, when I try to trade the strategy, Zorro doesn't seem to recognise the indices. I added the indices to the list of assets in the EA's code, even though they matched:

if(Asset == "NAS100") return("NAS100");
if(Asset == "SPX500") return("SPX500");

...and then the strategy worked fine.

Anyone else find something similar? Am I missing something here?

Either way, this might be a workaround if anyone else finds a similar problem.
Posted By: boatman

Re: Broker-specific symbols - 04/29/14 07:55

Now I've run into some problems with Zorro's EA recognising the metals. This is my asset list, copied directly from the Zorro EA:

/ convert a real asset name (f.i. "EURUSD") to a MT4 specific name (f.i. "EURUSDi")
string assetFix(string Asset)
{
// replace asset names directly (example)
// if(Asset == "XAGUSD") return("SILVER"); // "XAG/USD" in strategy => "SILVER" in MT4
// if(Asset == "XAUUSD") return("GOLD");
if(Asset == "AUD/USD") return("AUDUSDpro");
if(Asset == "EUR/USD") return("EURUSDpro");
if(Asset == "GBP/USD") return("GBPUSDpro");
if(Asset == "USD/CAD") return("USDCADpro");
if(Asset == "USD/CHF") return("USDCHFpro");
if(Asset == "USD/JPY") return("USDJPYpro");
if(Asset == "EUR/CHF") return("EURCHFpro");
if(Asset == "NAS100") return("NAS100");
if(Asset == "SPX500") return("SPX500");
if(Asset == "US30") return("US30");
if(Asset == "GER30") return("GER30");
if(Asset == "XAU/USD") return("XAUUSD");
if(Asset == "XAG/USD") return("XAGUSD");

// no direct replacement -> detect and add suffix automatically
string s = Symbol();
if(StringLen(s) > 6 && StringLen(Asset) <= 6) {
s = StringSubstr(s,6,StringLen(s)-6);
Asset = StringConcatenate(Asset,s);
static bool once = true;
if(once) {
Print("Adding ",s," to asset names");
once = false;
}
}
return(Asset);
}

All of the currency and index assets are recognised, but silver (XAG/USD) returns error #053 (XAG/USD unavailable!).

Any idea what could be causing this?

Thanks in advance.
Posted By: dusktrader

Re: Broker-specific symbols - 04/29/14 09:59

Slashes are different, in my experience. I believe Zorro does expect XAU/USD the same way your platform is presenting it.

Therefore, try taking out that line altogether and see if it works.
Posted By: jcl

Re: Broker-specific symbols - 04/29/14 16:16

Assets have no slashes in the MT4 script, so give the original names without the slash in the assetFix function.

The suffix "pro" however is normally added automatically, so you don't need the function for this.
© 2024 lite-C Forums