I would appreciate help to copy a line from one MT4 chart to another programatically. If I draw a line on a one hour time frame I would like the line to be recreated on my 15 min chart time frame as well as my 1 min time frame. So I have three charts and drawing a line on the one chart should recreate the line on the other two charts as well. The line that I draw on my 1 hour time frame will be drawn with a mouse rather than the line being drawn programatically.
Asked
Active
Viewed 404 times
1 Answers
0
This seems to be the answer:
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam)
{
//---
long lNextChartID = 0, lSecondChartID = 0;
datetime dtOpenTime,dtCloseTime;
double dOpenPrice,dClosePrice;
if(id==CHARTEVENT_OBJECT_CREATE)
{
if(ObjectType(sparam) == OBJ_TREND)
{
lNextChartID = ChartNext(ChartID());
lSecondChartID == ChartNext(lNextChartID);
dtOpenTime = ObjectGet(sparam,OBJPROP_TIME1);
dtCloseTime = ObjectGet(sparam,OBJPROP_TIME2);
dOpenPrice = ObjectGet(sparam,OBJPROP_PRICE1);
dClosePrice = ObjectGet(sparam,OBJPROP_PRICE2);
if(ChartSymbol(lNextChartID) == ChartSymbol(0) &&
ChartPeriod(lNextChartID) < ChartPeriod(0))
{
ObjectCreate(lNextChartID,sparam + "1",OBJ_TREND,0,dtOpenTime,dOpenPrice,dtCloseTime,dClosePrice);
}
}
}
}

Jean
- 137
- 1
- 13