-
Play videoPlease edit your post.
For large amounts of code, attach it. - Perhaps you should read the manual. ObjectGetValueByShift - Object Functions - MQL4 Reference

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi there this is an old indicator and I am trying to modify it from horizontal lines to trend lines , but I cant figure out how to read a trendline That I have added to the chart ,
any ideas or articles on this subject would be appreciated
cheers Ron
//|
//|
//+------------------------------------------------------------------+
//
//
extern bool AlarmOn =True; // Alarm on or off
extern bool SignalOnClose = False; // if false we use bid price to signal line break
extern string ResistanceLineName = "R_Alert"; // Line ID that will trigger alarm Note I rename trendline to "R_Alert" in its properties
extern string SupportLineName = "S_Alert"; // Line ID that will trigger alarm
extern string SoundFile = "alert2.wav"; // Sound ID
extern int DelayBetweenAlarm = 10; //
extern color SRLineClr = Lime; // SR Line color
extern color SRLineClr2 = Red; // SR Line color
extern int SRLineWidth = 2;
#property indicator_chart_window
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
//int init()
// {
//---- indicators
//---- indicators
//if(ObjectFind(ResistanceLineName) == -1) {
// ObjectCreate(ResistanceLineName, OBJ_TREND, 0, 0,iHigh(NULL, 0,0));
// }
// ObjectSet(ResistanceLineName, OBJPROP_COLOR, SRLineClr);
// ObjectSet(ResistanceLineName, OBJPROP_WIDTH, SRLineWidth);
// if(ObjectFind(SupportLineName) == -1) {
// ObjectCreate(SupportLineName, OBJ_TREND, 0, 0,iLow(NULL, 0, 0));
// ObjectSet(SupportLineName, OBJPROP_COLOR, SRLineClr2);
// ObjectSet(SupportLineName, OBJPROP_WIDTH, SRLineWidth);
// }
// return(0);
// }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
//int deinit()
// {
//----
//----
// if(UninitializeReason() != REASON_PARAMETERS && UninitializeReason() != REASON_CHARTCHANGE) {
// ObjectDelete (SupportLineName);
// }
//----
// return(0);
// }
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//----
//----
if(AlarmOn){
double PreviousClosePrice = Bid;
if(SignalOnClose == true) {PreviousClosePrice = iClose(NULL, 0, 1);}
double ResistancePrice = ObjectGet(R_Alert, OBJPROP_PRICE1);
double SupportPrice = ObjectGet(SupportLineName, OBJPROP_PRICE1);
if(PreviousClosePrice > ResistancePrice && ResistancePrice !=0)Alerts(1);
if(PreviousClosePrice < SupportPrice && SupportPrice !=0)Alerts(2);
}
Print ("R_Alert= ", ResistancePrice); // NOTE I try to print value of trend line
//----
return(0);
}
//+------------------------------------------------------------------+
{ //in reverse ie }
static datetime AlertLastTime = 0;
if(TimeCurrent() > AlertLastTime ) {
AlertLastTime = TimeCurrent () + DelayBetweenAlarm;
PlaySound(SoundFile);
}
}