Loop through double variables to find variable name
-
Hi, I have a scenario where I have a lot of double variables created (for example (High, and high 5%, high 10% are variable names) , each of which will always ultimately be my Order price, stop loss and take profit.
I have different buying and selling scenarios whereby they all ultimately go to the same bucket of pending orders at which point I have an order price, which is stop loss and take profit variable.I would like the robot to tell me what the double price variable name is once an order is triggered. For example when an order price double variable is created I want to loop through all the double variable names to find out the order price of the double variable name. So eg if order price double price = High 5% (double variable name) then return High5% Would anyone know how to do this? I envisage having to create a collection of double variables then running a custom code block but I don't have a clue how to code.
Thanks -
You can't get variable names. I think that when the source code is compiled, all variable names are just gone. They are used only for us, to be able to read the source code. The program itself works with the memory addresses behind variables. If you want to map values with names in MQL4, I imagine using 2 arrays. But arrays are very annoying for me in MQL4.
By the way, I can see your project and it has more than 1400 blocks. I honestly don't understand how some people like you are able to work with such projects, for me personally even 20 blocks are much. But I think you can remove many blocks with different techniques. Like this row of Formula blocks starting with block 13 - all those are just calculations with Variables and one block with custom MQL4 code can replace them all.
-
@fxdreema
Thanks a lot for the info, I am taking your advice on those formula blocks to reduce into one block. The limiting factor for me is I only know very basic coding hence why I did that bit I've figured out how to do it.
On the array idea, would you have any examples I could refer to in order to try that? Thanks -
Here you have @miro1360 post where you can find array´s info
Hope this helps
-
@josecortesllobat
Thanks, I have seen that before but looks like too much for my brain to deal with unfortunately.