How to get data from object (horizontal line) then store at variable
-
i need someone help , i dont know how to get data value from a horizontal line then store to variable. i need to use the existing data (horizontal line), then store to varriable method, because customer want, if accidentally close the MT4 app, then there is a horizontal able to trace back for variable.
https://fxdreema.com/shared/gJQx3YBEb
can help me done a workable function? -
I'm not sure exactly what you're trying to do for your particular project linked, it's a little confusing to me. But generally when I personally want to store something from a object. I'll grab a For Each Object node and input the name of it. Then modify variable and get the value/property I need. Here is an example. The lines will redraw each new trade placed so the name is always the same and the variable is updated automatically each new trade. This will only work if one trade is open at a time though. If there is more than one, it can be more complicated. I hope this helps you at least a little bit.
-
thank u very much from yr idea and time, i appreciate it
i also not that familiar on draw object block.
my desire function is to get data value from "horizontal line", then assign to a variable. This is to create No matter how i suddenly close MT4 then open again, i wish able to remain the data for variable, because in fact when we close MT4, all variable become 0 as initial. we need a draw object help
Such as GOLD buy order placed 1900, SL 1895, TP 1910, horizontal line is drawn at 1895 and 1910. The horizontal line is to trace back the SL and TP, this customer want. -
I see, so if closed the whole chart window for example, yes the variable is back to 0. I believe what you're looking for is probably storing the value into a GlobalVariable, which stays stored in MetaTrader for a certain amount of time. So even if the chart window closed and EA shutdown, etc, it will remain the same. There is a block in FXDreema called Terminal Variables, which does this under the Output section.
Unfortunately, I'm not super knowledgeable on the topic but it's what you're probably looking for. You'll likely need to utilize the OnDeinit and OnInit function with your global variable. I can look into it when I have some more time unless you figure it out or someone else can help out!
-
wow, now i only know about terminal variable, will try and play it
-
wow this really help me a lot!!!, terminal variable can store value when close the MT4 apps, open back, then can see the important data, great thank you. i no need to use drawn object get value which much troublesome.
-
@Steven_ This seems to work and what you want. Instead of modify variables, I am using the Terminal Variables block instead. Then on OnInit, you want to pass and Draw Line at the price "Terminal Variable Name".
So it will draw the lines again on initiation and it should update properly automatically.

-
aiya is not working nicely, terminal variable very hard to use it
-
@Steven_ Hm, I'm not sure then. The way I did it always redrew the lines back even when exiting the expert at the last opened trade SL/TP level. May be more complicated in a larger project.
-
if fail to use terminal variable, then if able to get data from horizontal line, or text appear, then is ok as long as get data from chart object. The main purpose is to get data from object then store to variable.
else using terminal variable.
-
I don't know what your whole project looks like on exactly what your doing so I can't really help further.
You could use a normal variable on the OnTick tab. Then, maybe on DeInit incase of MetaTrader closure, store into a Terminal Variable. Then OnInit, draw the lines back with terminal variable like I showed, but add an additional block Modify Variables, to modify the original variable back from your OnTick tab using the terminal variable. Seems like a headache.
-
@willramsey If you need the bot to find that horizontal line as soon as the terminal is reopen you will need a standard variable (never a terminal variable) and store the price value in the 'on init' tab like this:

Please notice that the line should have a name that needs to be correct. Otherwise it will not find it.
-
@l-andorrà Yes, but I was saying terminal variable if the chart the EA on was completely closed and was shutdown. If the chart window closed, the line is also gone. But, maybe I was misunderstanding him.
-
I don't know if terminal variables can do it. What I'm saying s that you don't know them if you are using standard variables like I said.
-
Terminal variables can be used in place of nearly any numeric variable, but they do not lose value when the terminal is closed.
-
the horizontal line created by EA will not delete after shutdown, it still appear when open it again.
it is much better to use chart & object, hence better use the horizontal line value to pass to variable again once we open MT4, because variable will clear after shutdown. -
When something happens set the global variable value to something like 0, then it cannot be used until needed.
-
great! using simple chart & object can trace and store value into variable, no need terminal variable, will later future improve the function. Thank u to everyone spend time and share the idea, great.