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):
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 ?
Forum on trading, automated trading systems and testing trading strategies
SymbolInfoTick last price is 0
Alain Verleyen, 2020.06.10 23:47
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
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.