ListAllSymbols.Rmd
Simple example to obtain all available symbols in MT5 marketwatch and theirs types (CFD, Forex, etc).
Load mt5R
package.
library(mt5R)
Use MT5.Marketwatch()
to obtain all marketwatch symbols.
AllSymbols <- MT5.Marketwatch() print(AllSymbols) #> [1] "Coffee C CFD (M5)" "Cotton - Cash" "Heating Oil" #> [4] "Sugar - Cash" "UK Oil" "UK Oil - Cash" #> [7] "US Oil" "US Oil - Cash" "Bitcoin" #> [10] "Ethereum" "EURUSD"
Create a data.frame to summary all the data.
df_symbols <- data.frame(Symbol = AllSymbols, Type = NA)
Use MT5.SymbolType()
to obtain the type of every symbol using loop.
for(i in seq_len(dim(df_symbols)[1])) { df_symbols[i,2] <- MT5.SymbolType(df_symbols[i,1]) }
MT5.SymbolType()
)
-1
not found.0
is stock.1
is option.2
is future contract.3
is Forex.4
is CFD.print(df_symbols) #> Symbol Type #> 1 Coffee C CFD (M5) 4 #> 2 Cotton - Cash 4 #> 3 Heating Oil 4 #> 4 Sugar - Cash 4 #> 5 UK Oil 4 #> 6 UK Oil - Cash 4 #> 7 US Oil 4 #> 8 US Oil - Cash 4 #> 9 Bitcoin 4 #> 10 Ethereum 4 #> 11 EURUSD 3