Storing number of opened trades in static variable like dictionary - page 2

 
honest_knave:

@Foed

Which build are you using?

T‌here were handle issues with Build 1045, and given the handle/pointer distinction in MQL...

 
honest_knave:

I had 1010 and now upgraded to 1045. Its still happening :(
 
Foed:
I can not find the another one implementation of dictionary for mql4. Do you , please, know any?
.mqh file is now attached, but I thought there could be some my mistake in my usage.


You can try my simple example of hashmap from the blog. Also I'm sure searching through the site will produce many other implementations.

A‌s for your current problem, here is the line in your mqh-file where the error happens:

        TKey  key() {
            if (_currentEntry != NULL) {
                return _currentEntry._key; // line 967, position 24 - _currentEntry access
            } else {
                return NULL;
            }
        }
I don't know what's wrong with this implementation and how _currentEntry gets broken - this requires deeper investigation or an assistance from the author.
MQL's OOP notes: HashMap supports old-fashioned indicators in MetaTrader 5
MQL's OOP notes: HashMap supports old-fashioned indicators in MetaTrader 5
  • 2016.09.29
  • Stanislav Korotky
  • www.mql5.com
MetaTrader 5 is not back compatible with MetaTrader 4 in many aspects. This is bad, but we can do nothing with this. Yet we can do something to simplify translation of MetaTrader 4 products into...
 
Foed:

I had 1010 and now upgraded to 1045. Its still happening :(
What is still happening ? Did you use the JC update ?
 
Alain Verleyen:
What is still happening ? Did you use the JC update ?

JC's update is the same file.

O‌P means the crash remains.

 
Alain Verleyen:
What is still happening ? Did you use the JC update ?

I meant crash is still happening.

I'm using the newer version of ydrols code - the one with new renamed methods etc.

Sorry if i wrote it badly.‌

 
Stanislav Korotky:

JC's update is the same file.

O‌P means the crash remains.

exactly, thank you.

I will look probably at your code tonight. I hope it will work in mql4, because your article is primary about mql5. Thank you Stanislav.

ANd ofcourse i will be still trying to figure out whats is happening and why is it crashing.‌

 
Foed:

I will look probably at your code tonight. I hope it will work in mql4, because your article is primary about mql5.

My code is about OOP MQL which exists both in MT5 and MT4 (though some applied codes are intended for porting MT4 products to MT5 and vice versa). The HashMap is surely compatible with both platforms.
 
Stanislav Korotky:
My code is about OOP MQL which exists both in MT5 and MT4 (though some applied codes are intended for porting MT4 products to MT5 and vice versa). The HashMap is surely compatible with both platforms.


It look like most of it works. But Im still getting error while compiling your HashMapSimple.mqh.

‌'operator' - function already defined and has body HashMapSimple.mqh 75 7

'operator' - member function already defined HashMapSimple.mqh 75 7

C‌ould you please help me? Thank you. I dont want to work with your code and cause it won't work (second reason is I'm not this experienced I could fix someone elses Class code :) )

 
Foed:


It look like most of it works. But Im still getting error while compiling your HashMapSimple.mqh.

‌'operator' - function already defined and has body HashMapSimple.mqh 75 7

'operator' - member function already defined HashMapSimple.mqh 75 7

C‌ould you please help me? Thank you. I dont want to work with your code and cause it won't work (second reason is I'm not this experienced I could fix someone elses Class code :) )


Did you see the paragraph in the blog?

Types should be standard MQL types, not classes. Also type of keys can not be int because int is already used for accessing elements by indices. If necessary though, one may use long or uint for keys as a replacement.

‌It looks like you try to use int type for keys.