Is it possible to do this?
- alarm possible when any horizontal line is touched?
- Trend indicators
- Elite indicators :)
Hey all,
1. Add lines to chart
2. Right-click
3. Object List
4. You will see the lines you drew with the names given to them.
Can an EA detect these? Probably. I haven't tried it myself, but this thread looks applicable.
https://www.mql5.com/en/forum/99406
- 2016.11.02
- www.mql5.com
1. Add lines to chart
2. Right-click
3. Object List
4. You will see the lines you drew with the names given to them.
Can an EA detect these? Probably. I haven't tried it myself, but this thread looks applicable.
https://www.mql5.com/en/forum/99406
Hey all,
you can filter any object by name, type, color, date of creation, you name it, this is powerful !
Here's an example of how you could add HLines dropped on the chart as S/R in your EA
//+------------------------------------------------------------------+ //| CustomSR-DragNDrop.mq4 | //| Copyright 2017, nicholishen | //| https://www.forexfactory.com/nicholishen | //+------------------------------------------------------------------+ #property copyright "Copyright 2017, nicholishen" #property link "https://www.forexfactory.com/nicholishen" #property version "1.00" #property strict #include <ChartObjects\ChartObjectsLines.mqh> #include <Arrays\ArrayObj.mqh> //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ class CSR : public CChartObjectHLine { public: bool Attach(string name) { return Attach(ChartID(), name, 0, 1); } }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ class CSRCollection : public CArrayObj { public: CSR *operator[](int i) { return At(i); } bool Add(string name) { if (MessageBox("Would you like to add " + name + " as S/R?", NULL, MB_YESNO) == IDYES) { CSR *line = new CSR; if(!line.Attach(name)) return false; line.Color(clrDarkOrange); line.Style(STYLE_DOT); line.Description("S/R"); return CArrayObj::Add(line); } return false; } bool Delete(string name) { for (int i = Total() - 1; i >= 0; i--) if (this[i].Name() == name) return Delete(i); return false; } void ToComment() { string res = ""; for (int i = 0; i < Total(); i++) res += (string)this[i].CreateTime() + " -- " + DoubleToString(this[i].Price(0), _Digits) + "\r\n"; Comment(res); } }; CSRCollection sr_collection; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int OnInit() { ChartSetInteger(0, CHART_EVENT_OBJECT_CREATE, true); ChartSetInteger(0, CHART_EVENT_OBJECT_DELETE, true); ChartSetInteger(0, CHART_SHOW_OBJECT_DESCR, true); return (INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void OnTick() { sr_collection.ToComment(); } //+------------------------------------------------------------------+ //| Timer function | //+------------------------------------------------------------------+ void OnTimer() { } //+------------------------------------------------------------------+ //| ChartEvent function | //+------------------------------------------------------------------+ void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { if (id == CHARTEVENT_OBJECT_CREATE && ObjectGetInteger(0, sparam, OBJPROP_TYPE) == OBJ_HLINE) { if (sr_collection.Add(sparam)) sr_collection.ToComment(); } else if (id == CHARTEVENT_OBJECT_DELETE) { if (sr_collection.Delete(sparam)) sr_collection.ToComment(); } } //+------------------------------------------------------------------+