Using iCustom with strings

 

Hello


Im having a little trouble with the iCustom function, my code so far is as follows -



string open_pair;

string pairs_names[2] = {"EUR", "GBP"};


open_pair=StringConcatenate("\"", pairs_names[0], pairs_names[1], "\"");

Alert(open_pair);

double final_check_ma1 = iMA(open_pair,PERIOD_H1,15,0,MODE_SMA,PRICE_CLOSE,0);

double final_check_ma2 = iMA(open_pair,PERIOD_H1,35,0,MODE_SMA,PRICE_CLOSE,0);

      

if (final_check_ma1 < final_check_ma2)

   {

   Alert("down");

   }

if (final_check_ma1 > final_check_ma2)

   {

   Alert("up");

   }



Can any one give any hints why it might not be accepting the string for the currency pair?




thanks

 
fatcheese:

Hello


Im having a little trouble with the iCustom function, my code so far is as follows -






Can any one give any hints why it might not be accepting the string for the currency pair?




thanks

fatcheese,

I suppose your problem is in the following line:

open_pair=StringConcatenate("\"", pairs_names[0], pairs_names[1], "\"");
Try removing the quotes. Then the line will look like this:
open_pair=StringConcatenate(pairs_names[0], pairs_names[1]);
Good luck!
 
robofx.org:

fatcheese,

I suppose your problem is in the following line:

robofx.org:

fatcheese,

I suppose your problem is in the following line:

I think its the fact iCustom wont accept a string for some reason,


those quotes are there as they are required for iCustom

 

Try the following code:

open_pair = pairs_names[0] + "/" + pairs_names[1]
 

FatCheese

I see no mention of "iCustom" in your supplied code.

iMA() is what your code shows.

A symbol string does not have double quotes. Double quotes are used to describe a series of characters as a string. They are not generally speaking as part of the string as your code does.

You have in fact assigned to open_pair a string "\"EURGBP\"" ie, "EURGBP" and the system expects to get EURGBP without the surrounding double quotes

Additionally, a symbol pair name string does not have "/" embedded in it.

"EURGBP" is correct string for any symbol pair reference on the ClientTerminal platform.

I have no knowledge of other formats required by other brokers, but assume is same.

ALL docs I have ever read use xxxyyy to identify symbol.

Also, if your code is only interested in the chart which it is attached to then use: Symbol() or NULL. You could even use "EURGBP" but why hard code stuff - makes code maintenance a nightmare!

Have you looked at the interface spec for iMA() ?

Have you read the THE BOOK ?

btw, I understand that maybe you want to print out or alert with the symbol name and you maybe want to show as EUR/GBP or "EURGBP", but that is not related to what you pass to iMA() or any function wanting symbol string.

HTH