alerts when price crosses horizontal/diagonal trendlines. help needed.
Please use this to post code . . . it makes it easier to read.

When finding where a horizontal line is you simply need to know it's price level, you get this by querying the object properties . . . . with an angled trend line it's price changes as it's time changes . . . so you need to use this: ObjectGetValueByShift
hey raptor, thanks for the help but unfortunately i am not a coder at all. i just know how to implement some logic stuff to an existing code. but what you explained is much too much for my very small knowledge about mpl4. i don't even know where or how to use the ObjectGetValueByShift function.. i am still in the mql4-kindergarten ;)
ps. next time i will use the SCR button ;)
i'm sorry when you feel being treated like a slave. i just copied a code here and asked a question about it because i don't understand why angled lines are not working.
hi forum,
this indicator displays an alert, everytime the price touches a horizontal line. that works fine with pivot-indicators and also with lines i draw myself.
now i want to know if it is possible that an alert comes up when a diagonal trendline is touched. i am not a programmer but i think it is already implemented (OBJ_TREND) but it does not work.
can somebody help me with that?
thank you!!!
int start()
{
//----
if (displayAlert==false) return;
static datetime Time0;
if (Time0 == Time[0]) return; // One alert per bar.
double H = High[0], L = Low[0];
for(int iObj = ObjectsTotal() - 1; iObj >= 0; iObj--)
{
string name = ObjectName(iObj);
if (ObjectType(name) == OBJ_HLINE)
{
double line = ObjectGet(name, OBJPROP_PRICE1);
}
else if (ObjectType(name) == OBJ_TREND)
{
if (ObjectGet(name, OBJPROP_TIME1) >= Time[0])
line = ObjectGet(name, OBJPROP_PRICE1);
else if (ObjectGet(name, OBJPROP_TIME2) >= Time[0])
line = ObjectGet(name, OBJPROP_PRICE2);
else continue; // Line stops before current candle
}
else continue; // Not HLINE or TREND
if (H >= line && line >= L)
{
Alert("Price has touched ", name);
Time0 = Time[0]; // No more alerts.
}
}
//----
return(0);
}