Memory efficiency with array trickery/ simulations - page 3

 
nicholish en:

Look... I hate to sound negative, however, the questions and anti-patterns you're always posting here implies that you don't have a background in programming. There's nothing wrong with that provided you seek to gain the requisite knowledge. It seems like you have fun making stuff by hacking around in the terminal with MQL, but if you're not willing to put in the effort to learn some fundamentals then you're going to be stuck making spaghetti code and people will get tired of giving answers to XY problems. 

"if you're not willing to put in the effort to learn some fundamentals then"

Project essentially over ; thx for all of your help. 

"anti-patterns you're always posting here "

I'm really learning from all of this so this is not an XY problem as it is necessary and essential for myself. Saying it is an XY will result in you will be questioned without ability to answer

And if you got no examples well I still appreciate your taking the time to post. a logical debate discussion if available is a fun thing; however they might call it non MQL4 related not myself having fun here 


 
nicholish en:

Look... I hate to sound negative, however, the questions and anti-patterns you're always posting here implies that you don't have a background in programming. There's nothing wrong with that provided you seek to gain the requisite knowledge. It seems like you have fun making stuff by hacking around in the terminal with MQL, but if you're not willing to put in the effort to learn some fundamentals then you're going to be stuck making spaghetti code and people will get tired of giving answers to XY problems. 

"Code that overuses GOTO statements rather than structured programming constructs, resulting in convoluted and unmaintainable programs, is often called spaghetti code."

My program is easy to maintain and microsecond efficient to the best of my knowledge; lucky enough it gets the job done . Like I'm said, I'm using various int arrays as their access time is best for what int capabilities provide and will not use the string array simulations. Not a bad idea for someone who is learning all of this in my opinion. If you think it is, and that it means I dont know CS, well its at least extremely functional!! Id use the double array math thing if better.

Goto - Wikipedia
  • en.wikipedia.org
GoTo ( goto , GOTO , GO TO or other case combinations, depending on the programming language) is a statement found in many computer programming languages. It performs a one-way transfer of control to another line of code; in contrast a function call normally returns control. The jumped-to locations are usually identified using labels, though...
 
nadiawicket:

"Code that overuses GOTO statements rather than structured programming constructs, resulting in convoluted and unmaintainable programs, is often called spaghetti code."

My program is easy to maintain and microsecond efficient to the best of my knowledge; lucky enough it gets the job done w "MQL4". 


You missed the entire point of what spaghetti code is...

Getting back on topic, there is no point optimizing micros when you're consuming malformatted strings. You either have a bigger issue upstream in your code or you're not truly understanding your bottleneck. It's one or the other.

 
nicholish en:


You missed the entire point of what spaghetti code is...

Getting back on topic, there is no point optimizing micros when you're consuming malformatted strings. You either have a bigger issue upstream in your code or you're not truly understanding your bottleneck. It's one or the other.

I never had a "bottleneck" but sure I take any suggestions; Im not even using strings as Ive said many times i went to ints as I taught myself; any more suggestions? What bottleneck are you talking about= doesnt exist

Run time seems to be dealt with at compiler time for a lot more than is obvious to a self taught CS

 
nadiawicket:

I never had a bottleneck

This entire thread you've been complaining about string functions "that messes up the speed". You're clearly trying to optimize to fix a situation where you've got an array of malformatted strings. I tried to help by asking you how you were getting the array of strings in the first place because that's your real problem, not how to be more efficient at working with bad data. 

 
nicholish en:

This entire thread you've been complaining about string functions "that messes up the speed". You're clearly trying to optimize to fix a situation where you've got an array of malformatted strings. I tried to help by asking you how you were getting the array of strings in the first place because that's your real problem, not how to be more efficient at working with bad data. 

Im not complainting at all. Why do you say that I'm complaitnting? Im just asking a strictly code based question on the forums

" I tried to help by asking you how you were getting the array of strings in the first place because that's your real problem"

And I posted the solution many times that Im just using 2 int arrays instead of array simulations bc run time not affected to which you did not say anything other than I need to take CS and question me a troll however its my OP Post and thread so kind of funny

Sounds like you dont really understand my issue or something but its [SOLVED]! THX!
 
nadiawicket:

Im not complainting at all. Why do you say that I'm complaitnting? Im just asking a strictly code based question on the forums

" I tried to help by asking you how you were getting the array of strings in the first place because that's your real problem"

And I posted the solution many times that Im just using 2 int arrays instead of array simulations bc run time not affected to which you did not say anything other than I need to take CS and question me a troll however its my OP Post and thread so kind of funny

Sounds like you dont really understand my issue or something but its [SOLVED]! THX!

I honestly meant you no disrespect...


I understand that you are attempting a micro-optimization for replacing a multi-dimensional array with some sort of string array so you can conceptually glue together an object. Going back to my point, had you been more clear about your intentions from the start somebody could have told you that it was a bad idea and that you should only be using n-dimensional arrays for matrix algebra. Your use is best suited for an array/list of structs/objects, and you should never bind multiple things together (esp. different data types) with a multi-dimensional array. Also, if you understood OOP you would get to make use of standard library (how MQL5 was intended to be used) and you wouldn't feel like the language was so cumbersome. The people who hate MQL5 all have one thing in common, they don't understand OOP and the concept of importing high-level dependencies. 


Again, there's nothing wrong with being a beginner. It's always best to learn programming by making stuff -- and for that I applaud you. I do recommend that at some point you stop and learn a language and understand some common patterns so that way you won't go down a rabbit-hole of "XY". Trust me, I speak from experience. Once I learned programming and corrected the many bad habits I had developed from bad MQL examples, I kicked myself for not having done it sooner. Just some food for thought ;)

Documentation on MQL5: Standard Library
Documentation on MQL5: Standard Library
  • www.mql5.com
MQL5 Standard Library is written in MQL5 and is designed to facilitate writing programs (indicators, scripts, experts) for end users. Library provides convenient access to the most of the internal MQL5 functions.
 
nicholish en:

I honestly meant you no disrespect...


I understand that you are attempting a micro-optimization for replacing a multi-dimensional array with some sort of string array so you can conceptually glue together an object. Going back to my point, had you been more clear about your intentions from the start somebody could have told you that it was a bad idea and that you should only be using n-dimensional arrays for matrix algebra. Your use is best suited for an array/list of structs/objects, and you should never bind multiple things together (esp. different data types) with a multi-dimensional array. Also, if you understood OOP you would get to make use of standard library (how MQL5 was intended to be used) and you wouldn't feel like the language was so cumbersome. The people who hate MQL5 all have one thing in common, they don't understand OOP and the concept of importing high-level dependencies. 


Again, there's nothing wrong with being a beginner. It's always best to learn programming by making stuff -- and for that I applaud you. I do recommend that at some point you stop and learn a language and understand some common patterns so that way you won't go down a rabbit-hole of "XY". Trust me, I speak from experience. Once I learned programming and corrected the many bad habits I had developed from bad MQL examples, I kicked myself for not having done it sooner. Just some food for thought ;)

"you won't go down a rabbit-hole of "XY"."

Why XY if not a waste of time for me? 

"I understand that you are attempting a micro-optimization for replacing a multi-dimensional array with some sort of string array so you can conceptually glue together an object."

I was trying many things, among them, strings,ushort.doubles,typecasting,etc; however, this was way before solving issue by confirming through research and experimentation that Im luckily not really really going to benefit from anything non basic

"I do recommend that at some point you stop and learn a language "

What exactly should I learn?

"some common patterns"

Which? 

 
nadiawicket:

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

   string arr[1] = { "_126" };
   int replaced=StringReplace(arr[0],"_"," ");
   int fromarr = int(StringTrimLeft(arr[0]));
   Print("from arr is ",IntegerToString(fromarr));


there's no built-in, typecasting is needed

 
roshjardine:


there's no built-in, typecasting is needed

thx for this issue exactly yes for others even pure math sometimes faster than messing w strings

Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
  • www.mql5.com
//| Expert initialization function                                   | //| Expert deinitialization function                                 | //| Expert tick function                                             | //| test1                                                            |...