How To Take Values From Chart Objects For Order

 

Hi Guys and Gals,

I'm trying to use the price properties of the attached screen shot from an indicator as my entry, take profit and stop loss levels for an EA I'm creating. I use Mql4 compiling software so don't write very much code myself.


Being new to mql4 code I dont know how to do it.

I'm guessing from my research that ObjectGet would be the starting point however I stand to be educated.

0.88599 (Arrow PriceRight) is the stop loss and is named: RC-Stp4 (the number changes with each drawing of the indicator so each one is unique)
the Green line is a trendline named: RC-Thr4
0.88115 (Arrow PriceLeft) is the take profit level named: RC-Trg4

Any assistance will be appreciated

Thanks

 
 

This is hopeless. Without you willing to learn to Code. Here...Anyways. You can find 90% of repeat questions by searching Google: mql4.com+question.

 

You have to make the distinction between Objects and lines or "arrows" (also Wingdings) that are drawn by an Indicator and stored in an Indicator buffer. You can tell if it's an object because it can be selected by double clicking it . .

Assuming you understand that and you want to get the properties for an object then you first have to know it's name, you said that they change, if they simply increment then you should be easily able to find the most recent one . . . if that is what you want.

So you use ObjectGet https://docs.mql4.com/objects/ObjectGet with the Object name and the object property you want to "get" https://docs.mql4.com/constants/objects/properties . Some objects like a H Line just have one price value, OBJPROP_PRICE1, others like trend lines have two, OBJPROP_PRICE1 & OBJPROP_PRICE2 as well as two datetimes OBJPROP_TIME1 & OBJPROP_TIME2

If you want to interpolate along the Trendline you can do it just with some simple maths or there is a function to help, https://docs.mql4.com/objects/ObjectGetValueByShift

Does this help ?

 
RaptorUK:

You have to make the distinction between Objects and lines or "arrows" (also Wingdings) that are drawn by an Indicator and stored in an Indicator buffer. You can tell if it's an object because it can be selected by double clicking it . .

Assuming you understand that and you want to get the properties for an object then you first have to know it's name, you said that they change, if they simply increment then you should be easily able to find the most recent one . . . if that is what you want.

So you use ObjectGet https://docs.mql4.com/objects/ObjectGet with the Object name and the object property you want to "get" https://docs.mql4.com/constants/objects/properties . Some objects like a H Line just have one price value, OBJPROP_PRICE1, others like trend lines have two, OBJPROP_PRICE1 & OBJPROP_PRICE2 as well as two datetimes OBJPROP_TIME1 & OBJPROP_TIME2

If you want to interpolate along the Trendline you can do it just with some simple maths or there is a function to help, https://docs.mql4.com/objects/ObjectGetValueByShift

Does this help ?


Thanks RaptorUK. Thats really helpful.

I'll check all the links out.

As the name increments on each new signal what code do I need to identify the last signal? - as you mentioned, that's the one I want. I was going to try searching for the string"RC-Thr&&" for the trend line. Is using the double && correct?

when the direction changes all previous signals are wiped.

The trendline is horizontal so just one double value is used in both parameters and a 3 hour time bracket so that shouldn't be too difficult.

I'll experiment with the code and see what i come up with.

Any extra advice is appreciated.

Cheers

Pjonz

 
pjonz2008:

Thanks RaptorUK. Thats really helpful.

I'll check all the links out.

As the name increments on each new signal what code do I need to identify the last signal? - as you mentioned, that's the one I want. I was going to try searching for the string"RC-Thr&&" for the trend line. Is using the double && correct?

I've not done much with strings but I'm pretty sure && isn't right, && is AND

You could simply do a while loop, do a FindObject looking for RC-Stp + an incrementing number, when the find fails you have gone past the last one.

 
RaptorUK:
You could simply do a while loop, do a FindObject looking for RC-Stp + an incrementing number, when the find fails you have gone past the last one.
If you count down, the first one matching should be the last one.
 

Hi. I'm trying to create an indicator using trendline crosses.

I know that i can get value of a t/l by using ObjectGetValuebyShif function.

But i want to get the value of t/l for a specific timeframe. is there anyway that i can do it?

 
enuzunyolcu:

Hi. I'm trying to create an indicator using trendline crosses.

I know that i can get value of a t/l by using ObjectGetValuebyShif function.

But i want to get the value of t/l for a specific timeframe. is there anyway that i can do it?

There is, but you would have to write your own function as I don't believe that you could use any of the standard functions.

You would have to find the anchor points in the other time-frame then calculate what it's value would be for a particular bar.

ie if the 2nd anchor point is 10 bars after the first and price difference is 100 pips, you would calculate that it moves 10 pips per bar.

Then you would check the shift of the bar compared to the first anchor point and if it is 5, then you would calculate that it is 50 pips higher/lower than the first anchor price.

Reason: