Metatrader 5 coding questions / issues - page 2

 
dr.house7:
Thanks, but how could I use objectget function if I call the indicator using iCustom?

Doc

The "main" parameter for ObjectGet...() function is the name of the object (regardless of who or what created the object). So all you have to know is the name. Now, in metatrader 4 if you call an indicator with iCustom() it still creates objects. Frankly in metatrader 5 I did not test that yet. Will see if it works as in metatrader 4.

 
mladen:
Doc The "main" parameter for ObjectGet...() function is the name of the object (regardless of who or what created the object). So all you have to know is the name. Now, in metatrader 4 if you call an indicator with iCustom() it still creates objects. Frankly in metatrader 5 I did not test that yet. Will see if it works as in metatrader 4.

about OBJPROP, I need OBJPROP_PRICE1 e OBJPROP_PRICE2? are these x y axis or what?

I wrote this, obviously don't work

zz1l = iCustom(Symbol(),0,"ZigZag_AutoChannel_1_3",ExtDepth1,0,0);

zz1h = iCustom(Symbol(),0,"ZigZag_AutoChannel_1_3",ExtDepth1,1,0);

double zz1l=ObjectGet("trend_1", OBJPROP_PRICE1);

double zz1h=ObjectGet("trend_2", OBJPROP_PRICE1);
 
dr.house7:
about OBJPROP, I need OBJPROP_PRICE1 e OBJPROP_PRICE2? are these x y axis or what?

I wrote this, obviously don't work

zz1l = iCustom(Symbol(),0,"ZigZag_AutoChannel_1_3",ExtDepth1,0,0);

zz1h = iCustom(Symbol(),0,"ZigZag_AutoChannel_1_3",ExtDepth1,1,0);

double zz1l=ObjectGet("trend_1", OBJPROP_PRICE1);

double zz1h=ObjectGet("trend_2", OBJPROP_PRICE1);

No, those are nt x and y axxis

In time series x axes is time. So if you want x and y "coordinate" then you should query OBJPROP_TIME1 for x part of the coordinate and OBJPROP_PRICE1 for y part of the coordinate

 
mladen:
No, those are nt x and y axxis In time series x axes is time. So if you want x and y "coordinate" then you should query OBJPROP_TIME1 for x part of the coordinate and OBJPROP_PRICE1 for y part of the coordinate

so, for the cross signal at the current bar I need only OBJPROP_PRICE1, right?

In my post #13 what's wrong (it's an mq4), the use of iCustom?

 
dr.house7:
so, for the cross signal at the current bar I need only OBJPROP_PRICE1, right? In my post #13 what's wrong (it's an mq4), the use of iCustom?

Doc

iCustom() in metatrader 5 returns a handle to a custom indicator, not a value of a buffer. I do not know what are the last 2 values that you are using in the call to iCustom() in that example. To get the value of the buffer you need to do the CopyBuffer() routine too (only then you specify which buffer is to be copied to your assigned array/buffer)

 
mladen:
Doc iCustom() in metatrader 5 returns a handle to a custom indicator, not a value of a buffer. I do not know what are the last 2 values that you are using in the call to iCustom() in that example. To get the value of the buffer you need to do the CopyBuffer() routine too (only then you specify which buffer is to be copied to your assigned array/buffer)

I know I'm a bit out of topic but, this is my mq4 try, could you please let me know what's wrong?

Thanks a lot

 
dr.house7:
I know I'm a bit out of topic but, this is my mq4 try, could you please let me know what's wrong? Thanks a lot

Try using this code :

double dummy = iCustom(Symbol(),0,"ZigZag_AutoChannel_1_3",ExtDepth1,0,0); // called to force object drawing

double zz1l = ObjectGetValueByShift("trend_1",0); // get value of trend_1 object at current bar

double zz1h = ObjectGetValueByShift("trend_2",0); // get value of trend_2 object at current bar

[/PHP]

instead of this one :

[PHP] zz1l = iCustom(Symbol(),0,"ZigZag_AutoChannel_1_3",ExtDepth1,2,0);

zz1h = iCustom(Symbol(),0,"ZigZag_AutoChannel_1_3",ExtDepth1,3,0);

double zz1l=ObjectGet("trend_1", OBJPROP_PRICE1);

double zz1h=ObjectGet("trend_2", OBJPROP_PRICE2);

 
mladen:
Try using this code :
double dummy = iCustom(Symbol(),0,"ZigZag_AutoChannel_1_3",ExtDepth1,0,0); // called to force object drawing

double zz1l = ObjectGetValueByShift("trend_1",0); // get value of trend_1 object at current bar

double zz1h = ObjectGetValueByShift("trend_2",0); // get value of trend_2 object at current bar

[/PHP]

instead of this one :

[PHP] zz1l = iCustom(Symbol(),0,"ZigZag_AutoChannel_1_3",ExtDepth1,2,0);

zz1h = iCustom(Symbol(),0,"ZigZag_AutoChannel_1_3",ExtDepth1,3,0);

double zz1l=ObjectGet("trend_1", OBJPROP_PRICE1);

double zz1h=ObjectGet("trend_2", OBJPROP_PRICE2);

Finally it works thanks

Very nice day, I learned something I did not know existed "ObjectGetValueByShift"...it's a very useful toy.

 
dr.house7:
Finally it works thanks Very nice day, I learned something I did not know existed "ObjectGetValueByShift"...it's a very useful toy.

Yes,

It allows you to get value of a trend line at whatever bar you wish to test

 
mladen:
Yes, It allows you to get value of a trend line at whatever bar you wish to test

instead for mt5 there is this function right?

ObjectGetDouble

Reason: