Jo Jomax: But when there are 100 objects, this way can not be good. My question is : Is there a way for 100 objects?
Why do you think it's “not good,” (whatever that means)?
Go through the object list and change them one by one.
William Roeder #:
Why do you think it's “not good,” (whatever that means)?
Go through the object list and change them one by one.
I thought I should copy-paste 100 times the following code and then change the names:
if(id== CHARTEVENT_CHART_CHANGE) { if(ChartGetInteger(0 ,CHART_SCALE, 0) <= 1) { ObjectSetInteger(0, "x", OBJPROP_TIMEFRAMES, OBJ_NO_PERIODS); ObjectSetInteger(0, "y", OBJPROP_TIMEFRAMES, OBJ_NO_PERIODS); . . . } else { ObjectSetInteger(0, "x", OBJPROP_TIMEFRAMES, OBJ_PERIOD_M1|OBJ_PERIOD_M5|OBJ_PERIOD_M15); ObjectSetInteger(0, "y", OBJPROP_TIMEFRAMES, OBJ_NO_PERIODS); . . . } }
But I can use the following code:
void OnChartEvent(const int id, const long& lparam, const double& dparam, const string& sparam)
{
if(id== CHARTEVENT_CHART_CHANGE)
{
if(ChartGetInteger(0 ,CHART_SCALE, 0) <= 1)
{
for(int i=0; i< ObjectsTotal(); i++)
{
if(ObjectGetInteger(0, ObjectName(0, i, 0, 1), OBJPROP_TYPE, 0) == OBJ_HLINE)
{
ObjectSetInteger(0, ObjectName(0, i, 0, 1), OBJPROP_TIMEFRAMES, OBJ_NO_PERIODS);
}
}
}
else
{
.
.
.
}
}
}
Thank you for your idea. I think there is no another way.
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
I want to hide an object on a chart in Mt5 when the scale of this chart changes to 0 or 1 (the scale can change from 0 to 5). unfortunately MQL5 does not have a command like
for chart_scale. I found a way to hide and unhide an object in different scales and timeframes. By using "CHARTEVENT_CHART_CHANGE" we can do it: