Memory efficiency with array trickery/ simulations

 

Trying to prevent excess arrays; anyone have an easy way to have for example string Array[0]="_126" be able to  be subtracted straight from an integer value? Like typecasting or something?

Array[0]="_126"; 

I want to subtract Bars-Array[0] without needing to worry about the _ so we can effectively compute without generating 126 without the _ in a separate array. Does it even matter PC Run time wise?

StringToInteger(Array[0]) not it

I dont want to use anything that is not in the vain of typecasting . Know about stringsubtract etc and would like to use ints instead

 
"_126" is not an int so that can not be done. Remove the underscore (StringSubstring) and then cast the result (or use StringToInteger.)
 
There is no affect on runtime using substring, it just shifts the address of the string by 1. 
 
Amir Yacoby: There is no affect on runtime using substring, it just shifts the address of the string by 1. 

You are assuming that it uses copy on write semantics. Don't assume.

 
William Roeder:

You are assuming that it uses copy on write semantics. Don't assume.

There is no assembler language that I know of that does not have the single MI of moving an address to another address - which is just one machine instruction. So it's safe to assume that a high level language that cares about performance will do it with just one MI in the end, if it's possible.

 
Don't assume!
 
William Roeder:
Don't assume!

Ok

 

THX!! One method is a DOUBLE value and (int)DoubleValue and use the decimal place values for "arrays"

String arrays look to be more memory consuming than double

Looks like i will be using ints bc more memory efficient

So just use for array 1 1value in int mode then for the 1value array now need to find way to skip the first 2 digits of the int in the most memory efficient way since I want to replicate a 2 dimensional array


So now its how to remove 2 digits from start of int


int value is 1121 just want to end up w 21 without using anything else than ints or typecasting (nor raw math like subtract 1100 or something bc functionality later)for array simulation usage. Can also be from the end so that if its 1121 just end up w 11 


Current method : string functions; 

StringSubstr(IntegerToString(Array[0]),0,-1);

So I'm trying to separate different types of bars in a 2 dimension array, like blue down so instead of using 2 arrays I just simulate 2 arrays by assign int Array[0] the array simulation 2 digits in front say blue is 1 and down is 0 so 10+bar and int to string inside the StringSubstr() function to simulate arrays; maybe something better than converting to string and then StringSubstr()? This looks to be the most memory efficient array usage on the platform

Documentation on MQL5: Conversion Functions / IntegerToString
Documentation on MQL5: Conversion Functions / IntegerToString
  • www.mql5.com
[in]  String length. If the resulting string length is larger than the specified one, the string is not cut off. If it is smaller, filler symbols will be added to the left.
 
William Roeder:
Don't assume!

You wouldnt even bother with array simulations even though you know that philosophically, it is better? "Just check profiler"? I cannot believe Official Metaquotes MQL4 Profiler has never worked on the tester bc they choose to push no-one-uses-MT5. If feels as if they have an issue with the common user using the profiler; where they want to cater to their "elite" MT5 users. How about just make a library for MQL4 MODE on or off for MT5? MT4 Users (sub numbers is evidence we were always the majority) never had access to your elite tools? It turns users away from the platform looking for a more open, higher level programming platform, better METAQUOTES dev team wanted. MT4 Should be the fully *functional* basis of MT5. 

Learning to use mt5 feels so unnecessary. It feels as if MT4 is just waiting for that obvious patch where we get the obvious implementable benefits of mt5 or a an MT5 library or something. MT5 is just "faster" at everything; and Metaquotes dev cant implement what could be implemented into MT4 because they are not a unified logical project? Unbelievable

2 Bit short array better than bit by character string arrays or every short array value character is also 2 bit? Dont know if I should ask that in another thread alltogether hope I dont get banned for alleged "double post" bc sometimes you got too many questions and they overlap @ META who should get a free IRC channel


Ive seen the little popus ask MT5 Someday? How about META is actually meta-functional 

Code profiling - Developing programs - MetaEditor Help
Code profiling - Developing programs - MetaEditor Help
  • www.metatrader5.com
Profiling means collecting program parameters during its execution. During a profiling, the execution time and the number of calls of individual functions and program code lines are measured. With this tool, the programmer is able to find and optimize the slowest code sections. Profiling can be performed on the normal chart of the trading...
 

Looks like microsecond count reveals that typecasting can be more time consuming than I thought. Well there was only one way to find out. I heard typecasting was the fastest way however I need to run it through a StringConcatenate that messes up the speed

Looking like 2 int arrays and a single string array and 2 shorts or 1 short array are all very very negligible difference; w string being slightly the best sometimes. So Ill just use 2 ints as access time is just 1 micro 

Which contradicts the byte memory usage of the data types in a way that implies that "all of it is dealt with at compile time" is the case here as well as with > and >= being the same speed at run time as well. Great to know
 
This all seems like one big X Y problem...
The XY Problem
  • xyproblem.info
The XY problem is asking about your attempted solution rather than your actual problem . This leads to enormous amounts of wasted time and energy, both on the part of people asking for help, and on the part of those providing help. User wants to do X. User doesn't know how to do X, but thinks they can fumble their way to a solution if they can...
Reason: