Download MetaTrader 5

Associative array with mql

To add comments, please log in or register
compojoom
32
compojoom  

I'm developing an EA that sends a stack of orders. Each stack has an unique magic number and depending on my criteria I close all the deals in the stack. 

I want to store the bid and ask price for a magic number for later use. Unfortunately I cannot figure out how to do that. If I was doing this with php all i had to would be

 $prices[$magicNumber]['bid'] = 1231;
$prices[$magicNumber]['ask'] = 2222;

 Unfortunately mql is not php and I have no clue to achieve the same?

I thought about a multilevel dynamic array like prices[][2], but the problem is that I can't use the magic number as the key for the first level? 

 Any pointers to docs that explain how to do something similar are appreciated. 

Alain Verleyen
Moderator
31632
Alain Verleyen  

It needs to be coded. Check the codebase there is a library doing that somewhere.

EDIT : here https://www.mql5.com/en/code/11117

HashMap implementation
HashMap implementation
  • votes: 13
  • 2014.02.11
  • ydrol
  • www.mql5.com
An implementation of a HashMap in MQL4
To add comments, please log in or register