Getting the Last Price of another Symbol which is not the one loaded in the current window

 

Hello

I'm building an indicator that compares two symbols, so it needs rates from a different security that the one that is loaded in the current window, in order to make the calculations. 


Is there a way to load another price[] array in the indicator, which will load rates from a different instrument? If so, how to implement? It could be something like this:

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const int begin,
                const double &price[],
                const double &secondSymbolPrice[])


I tried loading this rates manually using CopyRates, SymbolInfoDouble and SymbolInfoTick but there's a problem with some securities, that don't display the last price. For the current bar they will return 0, which will absolutely mess up my indicator's line.

Currency pairs don't have a last price in the market watch (I just learn that this week):


Any ideas?

forex news - Trading blogs and financial markets analysis
forex news - Trading blogs and financial markets analysis
  • www.mql5.com
Forex – foreign exchange market, or currency market – is the market where one currency is traded for another. Open 24-hours a day from Sunday evening through to Friday night, it is the world's most
 

Last price only exists on centralized market. Not for Forex.

I already said it to you, how much time will I need to repeat it ?

 
Alain Verleyen:
Last price only exists on centralized market. Not for Forex.

Just be nice.

Yes, but how does Metatrader shows the last price on the chart? I mean in the current bar, when the candle is being formed, the close value. How do I get that information? It doesn't have to come from the market, just from inside Metatrader

 
Eduardo Fernando Teixeira:

Just be nice.

Yes, but how does Metatrader shows the last price on the chart? I mean in the current bar, when the candle is being formed, the close value. How do I get that information? It doesn't have to come from the market, just from inside Metatrader

Forex charts are based on Bid.
 
Alain Verleyen:
Forex charts are based on Bid.

Right, and what about that price[] array in the OnCalculate method. Do you know if I can have another one and load from another security? 

 
Eduardo Fernando Teixeira:

Right, and what about that price[] array in the OnCalculate method. Do you know if I can have another one and load from another security? 


Found out we can use CopyClose() for loading data from another symbol. It's much more stable and will work with all types of securities, regardless of their book characteristics.

Reason: