Coding help - page 192

 

hi mladen,

i try long time incorporate, apply & make some codes to this indicator, it has display, no refresh and repaint issues, but i do not know why it has not, could you tell me the reason? but it has also a big weakness that it only calculate signal or value after the candle bar close, when the candle still running, it will not change any signals or value, but i just use the exact same calculation formula as before CCI trial indicators sent you before, why has so different result? what the code inside have done to make such differences? But i do hope it can calculate like yours, can calculate the values and signals instantaneously when the candles is still running (not just after close), otherwise the signals will lagging at least one candlestick. how to improve this indicator if i want it to instantaneously change values & signals, thanks a lot for help.

 

Hello Coders,

hello mladen,

I found an indicator on my HDD which displays an alert when a horizontal line is touched by the price. I modified it a little bit and it works fine. But now I would like to add something. It often happens that an exact line is not touched and the price reverses some pips earlier. Now I could draw many lines more in the chart or I try to modify this indicator that it should not only display an alert when the line in the chart is touched but a few pips higher or lower. So the indicator should display an alert when the prices touches the line in the chart +5 pips or line -5 pips.

My idea is to change this line:

if (High[0]>=line && line>=Low[0]) to something like this:

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

Obviously that does not work.. I have no idea why.. :-/

And another problem is that this would be only work for 1.XXXX prices. I can't use 0.0005 for Yen-pairs or Index-CFDs.

I would be happy if somebody can fix it.

Thank you!!

Here is the code:

//+------------------------------------------------------------------+

//| LINE_ALERT.mq4 |

//+------------------------------------------------------------------+

extern bool Notification=true;

extern bool displayAlert=true;

string Text;

#property indicator_chart_window

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

//---- indicators

//----

return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

//----

//----

return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator iteration function |

//+------------------------------------------------------------------+

int start()

{

//----

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)

{

double line = ObjectGet(name, OBJPROP_PRICE1);

}

else continue; // Not HLINE

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

{

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

Alert(Text);

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

if (Notification) SendNotification(Text);

}

}

//----

return(0);

}

//+------------------------------------------------------------------+

 
Marbo:
Hello Coders,

hello mladen,

I found an indicator on my HDD which displays an alert when a horizontal line is touched by the price. I modified it a little bit and it works fine. But now I would like to add something. It often happens that an exact line is not touched and the price reverses some pips earlier. Now I could draw many lines more in the chart or I try to modify this indicator that it should not only display an alert when the line in the chart is touched but a few pips higher or lower. So the indicator should display an alert when the prices touches the line in the chart +5 pips or line -5 pips.

My idea is to change this line:

if (High[0]>=line && line>=Low[0]) to something like this:

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

Obviously that does not work.. I have no idea why.. :-/

And another problem is that this would be only work for 1.XXXX prices. I can't use 0.0005 for Yen-pairs or Index-CFDs.

I would be happy if somebody can fix it.

Thank you!!

Here is the code:

//+------------------------------------------------------------------+

//| LINE_ALERT.mq4 |

//+------------------------------------------------------------------+

extern bool Notification=true;

extern bool displayAlert=true;

string Text;

#property indicator_chart_window

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

//---- indicators

//----

return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

//----

//----

return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator iteration function |

//+------------------------------------------------------------------+

int start()

{

//----

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)

{

double line = ObjectGet(name, OBJPROP_PRICE1);

}

else continue; // Not HLINE

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

{

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

Alert(Text);

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

if (Notification) SendNotification(Text);

}

}

//----

return(0);

}

//+------------------------------------------------------------------+

Marbo

You can do something like in th attached. The only thing you should revise is what exactly the distance in pips from a line should mean (+ or - in case of high or low)

Files:
 

Great! Thank you!!

 
zilliq:
Hi Mrtool and Mladen,

Can one of you explain how is construct the TSV Bullish & Bearish indicator please ? I haven't find any information about it ?

Thanks

Zilliq

Zilliq there is a version here https://www.forex-tsd.com/forum/debates-discussions/116-something-interesting-please-post-here/page299#comment_679505 with the source code.

 
cwu:
If I enter 0, does that mean there is no SL or TP? Thanks again.

Cwu,

Yes it should.

 

Guys

Been checking that TSV Bullish & Bearish and the oldest that I have found is from 2007. If that is the formula, then it is nothing else but a Gann high low activator in a bit different form (the essence - the calculation - is the same)

 

Thanks guys,

I will see that this week-end and I will post the TSV Bearish/bullish I have

I'm Vet in France and I work tomorrow, so I will check on Sunday

I have already code a Gann high and low, notably with a smooth version, so it must be simple

Have a nice week-end and thanks for all

Zilliq

 

Mladen,

I have another question about the line alert indicator. At the moment it is working with horizontal lines. I also tried to implement Trendlines by using OBJ_TREND but there is one issue I don't understand. I read in another Forum many months ago that the starting and the ending point of the Trendline must be determined. Could you please give me some info about how to do that? Or is that much more difficult than I imagine?

Best regards,

Marbo

 
Marbo:
Mladen,

I have another question about the line alert indicator. At the moment it is working with horizontal lines. I also tried to implement Trendlines by using OBJ_TREND but there is one issue I don't understand. I read in another Forum many months ago that the starting and the ending point of the Trendline must be determined. Could you please give me some info about how to do that? Or is that much more difficult than I imagine?

Best regards,

Marbo

Marbo

You actually do not need to know that start and the end. You can retrieve the values in a different manner (using ObjectGetValueByShift() function which will return price 0 if it is seeking a price outside the trend line). One example of how it can be done you can find at this post : https://www.mql5.com/en/forum/177603/page3

Reason: