lines[i].name=ObjectName(0,i,0,OBJ_TREND); lines[i].name=ObjectName(0,i,0,OBJ_HLINE); if(i<trendTotal)You are using one variable for two incompatible purposes.
Object type | TL | TL | HL | HL |
Object index | 0 | 1 | 0 | 1 |
Line index | 0 | 1 | 2 | 3 |
- Make one variable, to load your lines[] and write two loops over the range of object counts to get the objects.
- Or adjust your HL index
I make fix it. Thank you so much.
int objCount=0; for(int i=0; i<trendTotal;i++) { lines[objCount].name=ObjectName(0,i,0,OBJ_TREND); Print(objCount," = ",lines[objCount].name); lines[objCount].curPrice=NormalizeDouble(ObjectGetValueByTime(0,lines[objCount].name,time),_Digits+1); objCount++; } for(int j=0;j<hlineTotal;j++) { lines[objCount].name=ObjectName(0,j,0,OBJ_HLINE); Print(objCount," = ",lines[objCount].name); lines[objCount].curPrice=NormalizeDouble(ObjectGetValueByTime(0,lines[objCount].name,time),_Digits+1); objCount++; }
When you post code please use the CODE button
(Alt-S)! (For large amounts of code, attach it.)
Please edit
your post.
General rules and best pratices of the Forum. - General - MQL5 programming forum
Messages Editor
General rules and best pratices of the Forum. - General - MQL5 programming forum
Messages Editor
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.
I`m beginner & study for MQL5 programming.
I make the EA get the trend line name & Horizontal name but i can not fix it.
I use two ObjectName in EA. 1st ObjectName is OK buy 2nd ObjectName is not correctly. If I change each two sentence, always 1st is OK.
I don`t know why it is not properly excute. Please help me.