function symbol() syntax

 

dear every one,

I don`t understand how work function symbol()

what hapen in this case?

symbol()=gbpusd;

ticket=OrderSend(eurusd,OP_BUY,Lots,Ask,2,SL,TP);

The first line select gbpusd currency indead?

And the order will be sent with eurusd ?

thanks in advance

 

You got it backwards. Rule for using functions:

Wrong:

function() = variable;

right:

variable = function();

 

thank phy

yes, I have to put a variable

symbol()="gbpusd";

ticket=OrderSend(eurusd,OP_BUY,Lots,Ask,2,SL,TP);

but could you tell me what happen in this case?

The first line fix currency trade to "gbpusd" indead?

but the second line apply eurusd to the order?

it is possible without conflict?

thanks in advance

 

1. symbol() is not a variable name. You cannot say symbol() = "gbpusd"

2. Symbol() -- note: the name is captalized -- is a built in function. It will return the name of the charted indstrument. You cannot say Symbol() = "gbpusd".

good luck.

 

thank phy,

But how do you use this function?

I don`t understand.

if ( OrderSymbol()==Symbol())

ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,TP);

What is the meaning of theses lines?

where the currency pair is put?

thanks in advance

 

if ( OrderSymbol()==Symbol()) ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,TP);

If the pair in the previously selected order is equal to the pair on the chart, send an order to sell the charted pair.
 

thanks phy,

but how do you select a pair?

How do you make a pair active?

How do you enter the pair?

If you put the pair inside an OrderSend for exemple, will the

pair be active (selected) on the form after?

 

Some commands permit you to specify a pair. The parameter accepts a text string which can be explicit, like "EURUSD" or a string variable, or a string function.

Explicit:

OrderSend("EURUSD", ....

String Variable:

string name = "EURUSD";

OrderSend(name, ...

Function:

OrderSend(Symbol(), ...

 

thank phy,

that meen if you write: OrderSend("EURUSD", ....

after, Symbol() will return "EURUSD" ?

 

No.

string Symbol( )
Returns a text string with the name of the current financial instrument. --- meaning, the pair on the chart

Please read Documentation.

Put this in your code right after the start() function:

int start(){

Comment(" The current financial instrument is ", Symbol()); // <-------add this

.

view the result at the top left of your chart.

 

Ok, I understand, symbol() return the pair of the chart

and OrderSymbol() return the pair chosed on last OrderSend

indead?

Reason: