Get the price of a different symbol from the request.price (MqlTradeRequest) of a pending order

 

Hello,

In my EA I am trading pending orders and in the volume request I ajust it to risk 2% of my balance account. My currency account is EUR and the problem is when I am trading a symbol which does not hold EUR on base and quote currency, like GBPUSD:

risk_percent = 2%;

ACCOUNT_BALANCE = 10000€

request.action  = TRADE_ACTION_PENDING;  

request.symbol  = GBPUSD;

request.price   = price_deal_in; 

request.sl = stop_loss;

In order to limit my loss to 2% x Account Balance, I set the following equation:

request.volume = NormalizeDouble((((risk_percent/100)*AccountInfoDouble(ACCOUNT_BALANCE)*price_EURUSD) / ( price_deal_in - stop_loss ))/100000,2);

So basically, somehow I would have to know the price of EURUSD symbol at the moment that my pending order turns into a deal. In different words, when the "request.price" of my trading symbol GBPUSD gets hit, I need to have the price of EURUSD. How can it be done?


Thanks in advance,

Filipe

 

Hello,


You can get the value of EURUSD:  

 price_EURUSD = SymbolInfoDouble("EURUSD", SYMBOL_LAST);

or you could get SYMBOL_ASK or SYMBOL_BID.

Let me know if it help you.

 
Ivan Ronchi:

....

Posso estar enganado, mas no Forex não tem informação de Preço Last.

Para isso use o preço de fechamento da vela 0, que funciona!


;)