Coding help - page 193

 

Всем привет!

дорого дня!!

помогите добавить красную полоску в индикатор

полоска зелёная работает хорошо (bear;// Lime)

красная не работает(bull;// Red;)

заранее Спасибо.

индикатор:

bearbull.mq4

Files:
 

Hi Mrtools & Mladen

I confirm that TSV Bullish & Bearish is only a histo version of Gann Hilo Activator as you see on my picture...

I will never understand why some people like to give some esoteric and strange name to an another indicator who already exist (Gann Hilow activator is already a strange and esoteric name...) ...

TSV Bullish & Bearish seemed to me very interesting, but like this it's more TSH Bullshit & Bearish

Have a nice day guys and thanks for your answer

Zilliq

Files:
 

Mladen,

I tried it this way:

int start()

{

//----

double _distance = pipsDistance*Point*MathPow(10,Digits%2);

if (displayAlert==false) return;

static datetime Time0;

if (Time0 == Time[0]) return; // One alert per bar.

for(int iObj = ObjectsTotal() - 1; iObj >= 0; iObj--)

{

string name = ObjectName(iObj);

if (ObjectType(name) == OBJ_HLINE)

{

line = ObjectGet(name, OBJPROP_PRICE1);

}

else if (ObjectType(name) == OBJ_TREND)

{

line = ObjectGetValueByShift(name,0);

}

else continue; // No line found

if ((High[0]>=(line-_distance) && (line+_distance)>=Low[0]))

{

Text = Symbol()+" M"+Period()+" touched S/R @ "+Close[0];

Alert(Text);

Time0 = Time[0]; // No more alerts.

if (Notification) SendNotification(Text);

}

}

//----

Right now I can't test it because there are no realtime quotes. But it seems logic to me to use the ObjectGetValueByShift() this way. I only look for line-touches within the current bar. Therefore I used (name,0).

But now I wanted to ask you if I really have to make a difference between OBJ_HLINE and OBJ_TREND. When I use ObjectGetValueByShift(name,0) then I also receive the value of a horizontal line or am I wrong? I see no logical difference between ObjectGet(name, OBJPROP_PRICE1) and ObjectGetValueByShift(name,0) when only the line's value of the current period is needed.

Maybe you can clarify that a bit? Thanks!!

 
Marbo:
Mladen,

I tried it this way:

int start()

{

//----

double _distance = pipsDistance*Point*MathPow(10,Digits%2);

if (displayAlert==false) return;

static datetime Time0;

if (Time0 == Time[0]) return; // One alert per bar.

for(int iObj = ObjectsTotal() - 1; iObj >= 0; iObj--)

{

string name = ObjectName(iObj);

if (ObjectType(name) == OBJ_HLINE)

{

line = ObjectGet(name, OBJPROP_PRICE1);

}

else if (ObjectType(name) == OBJ_TREND)

{

line = ObjectGetValueByShift(name,0);

}

else continue; // No line found

if ((High[0]>=(line-_distance) && (line+_distance)>=Low[0]))

{

Text = Symbol()+" M"+Period()+" touched S/R @ "+Close[0];

Alert(Text);

Time0 = Time[0]; // No more alerts.

if (Notification) SendNotification(Text);

}

}

//----

Right now I can't test it because there are no realtime quotes. But it seems logic to me to use the ObjectGetValueByShift() this way. I only look for line-touches within the current bar. Therefore I used (name,0).

But now I wanted to ask you if I really have to make a difference between OBJ_HLINE and OBJ_TREND. When I use ObjectGetValueByShift(name,0) then I also receive the value of a horizontal line or am I wrong? I see no logical difference between ObjectGet(name, OBJPROP_PRICE1) and ObjectGetValueByShift(name,0) when only the line's value of the current period is needed.

Maybe you can clarify that a bit? Thanks!!

Marbo

You have to make a difference between horizontal line and trend line simply because trend line is different type of object than the horizontal line (for horizontal line it is enough to read the value of the price1 and that is it, while, for the trend line, price1 does not need to be the same as the price 2 at all, and those prices can be completely different from prices in between)

 

Hi,

Can anyone help to fix a problem with this indicator?

In mt4 visual tester with enabled Backtesting mode it works Ok in mtf mode (H1-H4 on M5 chart)

but in the real chart - lines is delaying.

Thank you!

mtf_moving_average.mq4

Files:
 

Mladen,

that fact I understand. I mean it just for my simple indicator. For me it is not important where the Trendline comes from or where it goes to. I just need the value of it at the current bar. Therefore I asked if I could put it together and work only with ObjectGetValueByShift() for both lines.

But, however, do you think it works the way I did it in the code above?

Thanks!!

 
Marbo:
Mladen,

that fact I understand. I mean it just for my simple indicator. For me it is not important where the Trendline comes from or where it goes to. I just need the value of it at the current bar. Therefore I asked if I could put it together and work only with ObjectGetValueByShift() for both lines.

But, however, do you think it works the way I did it in the code above?

Thanks!!

Marbo

As far as I see it it should work

 
cain82:
Hi,

Can anyone help to fix a problem with this indicator?

In mt4 visual tester with enabled Backtesting mode it works Ok in mtf mode (H1-H4 on M5 chart)

but in the real chart - lines is delaying.

Thank you!

mtf_moving_average.mq4

Try using the one from this post instead : https://www.mql5.com/en/forum/173574/page239

 
mladen:
Try using the one from this post instead : https://www.mql5.com/en/forum/173574/page239

Thanks for reply!

But you indi works differently.

 
cain82:
Thanks for reply! But you indi works differently.

Yes, because it works correctly. If all that needs to be corrected would be done in the one you posted they would be exactly the same

regards

Reason: