How do I used CHashMap

 

Hi 


I am very new to MQL4 programming. But I am programming in another language.

I an trying to learn CHashMap to store key/value pairs in my test.

I show this example using CHashMap online


   CHashMap<string, int> d;
   
   d.Add("one", 1);
   d.Add("two", 2);
   d.Add("three", 3);

When add this code in my script EA, I am getting errors. I guess, I need to import this CHashMap Library.

void OnStart() {

    CHashMap<string, int> d;   

   d.Add("one", 1);

   d.Add("two", 2);

   d.Add("three", 3);

}

Please can someone help me, who to add library to my code.


Many thanks

Ish

 
ishf fady:

Hi 


I am very new to MQL4 programming. But I am programming in another language.

I an trying to learn CHashMap to store key/value pairs in my test.

I show this example using CHashMap online


When add this code in my script EA, I am getting errors. I guess, I need to import this CHashMap Library.

void OnStart() {

    CHashMap<string, int> d;   

   d.Add("one", 1);

   d.Add("two", 2);

   d.Add("three", 3);

}

Please can someone help me, who to add library to my code.


Many thanks

Ish

You must include the HashMap.mqh:


#include <Generic\HashMap.mqh>
 

I tried what you suggested, as shown below. I am still getting error. I am using MT4 platform from Oanda.

#property strict

#include <Generic\HashMap.mqh>

void OnStart(){

   CHashMap<string, int> d;

   d.Add("one", 1);

   d.Add("two", 2);

   d.Add("three", 3);

Please any advice
 
ishf fady:

I tried what you suggested, as shown below. I am still getting error. I am using MT4 platform from Oanda.

#property strict

#include <Generic\HashMap.mqh>

void OnStart(){

   CHashMap<string, int> d;

   d.Add("one", 1);

   d.Add("two", 2);

   d.Add("three", 3);

Please any advice

Please write your code in this field by pressing Alt + S key.

 
ishf fady:

I tried what you suggested, as shown below. I am still getting error. I am using MT4 platform from Oanda.

#property strict

#include <Generic\HashMap.mqh>

void OnStart(){

   CHashMap<string, int> d;

   d.Add("one", 1);

   d.Add("two", 2);

   d.Add("three", 3);

Please any advice

Here is my code: I get no compiler errors, no warnings. All is ok. I cannot see any problem(?)


#property strict
#include <Generic/HashMap.mqh>
void OnStart() {
   CHashMap<string, int> d;
   d.Add("one", 1);
   d.Add("two", 2);
   d.Add("three", 3);
}

Matthias

BTW: I'm using Metatrader 5, Build 2863
 
Dr Matthias Hammelsbeck:
BTW: I'm using Metatrader 5, Build 2863

Then why are you posting in the MT4 section??