Programming problem...!

 

hi,

does anyone knows, in an expert advisor, to program the "OrderSend()" function to open a trade on a symbol different from the one in which the ea is loaded?

thanks in advance.

 
gigiyoffee:
hi,

does anyone knows, in an expert advisor, to program the "OrderSend()" function to open a trade on a symbol different from the one in which the ea is loaded?

thanks in advance.

OrderSend(NULL, 0.... )

"NULL" specifies the pair for the order. Null means the current pair. You can put any string (that corresponds to a pair, such as GBPUSD) in there.

 
ryanklefas:
OrderSend(NULL, 0.... ) "NULL" specifies the pair for the order. Null means the current pair. You can put any string (that corresponds to a pair, such as GBPUSD) in there.

I thought you also had to use the market info function, I know this works:

extern string paircharta="EURUSD";//whatever symbol you want

tradeticketa = OrderSend(paircharta,OP_BUY,lotsize,MarketInfo(paircharta,MODE_ASK),slippage,MarketInfo(paircharta,MODE_ASK)-stoploss*MarketInfo(paircharta,MODE_POINT),MarketInfo(paircharta,MODE_ASK)+takeprofit*MarketInfo(paircharta,MODE_POINT),"orderstart",magica,0,Blue);

 
wolfe:
I thought you also had to use the market info function, I know this works:

extern string paircharta="EURUSD";//whatever symbol you want

tradeticketa = OrderSend(paircharta,OP_BUY,lotsize,MarketInfo(paircharta,MODE_ASK),slippage,MarketInfo(paircharta,MODE_ASK)-stoploss*MarketInfo(paircharta,MODE_POINT),MarketInfo(paircharta,MODE_ASK)+takeprofit*MarketInfo(paircharta,MODE_POINT),"orderstart",magica,0,Blue);

Well, that is the complicated way to do it.

 
ryanklefas:
Well, that is the complicated way to do it.

Seems like there is always an easier way, I usually don't learn it until too late!

 

Nice code dermusic, I like that!

 

Try something like the code posted below:

extern double Lots1=0.2;

extern double Lots2=0.1;

extern int StopLoss =50;

extern int TakeProfit=100;

int Slippage= 3;

int MagicNumber =123;

bool MySignal=false;

string Symbol1,Symbol2;

double orderprice;

int start()

{

Symbol1="USDCHF", Symbol2="GBPUSD"; //remember to put an "m" in if

//using an Interbankfx mini account, like "GBPUSDm"

if (MySignal==true)

{

if(IsTradeAllowed()==true)

{

sl=StopLoss*MarketInfo(Symbol1,MODE_POINT):

tp=TakeProfit*MarketInfo(Symbol1,MODE_POINT):

orderprice=MarketInfo(Symbol1,MODE_ASK);

OrderSend(Symbol1,OP_BUY,Lots1,orderprice,Slippage,orderprice-sl,orderprice+tp,"",MagicNumber,0,Blue);

}

{

sl=StopLoss*MarketInfo(Symbol2,MODE_POINT):

tp=TakeProfit*MarketInfo(Symbo2,MODE_POINT):

orderprice=MarketInfo(Symbol2,MODE_ASK);

OrderSend(Symbol2,OP_BUY,Lots2,orderprice,Slippage,orderprice-sl,orderprice+tp,"",MagicNumber,0,Blue);

}

return(0);

}

}