Hi!
You declare LastHigh in start function and it's erase in every tick. You should do this outside start function at the beginning of your code.
No, error is in fact that you try to create a new Object on every incoming tick with same name "Buy". You have to check result returned by function ObjectCreate() by calling GetLastError().
In fact, it seems that the error is that every new object has the same name. The error code I was getting by calling GetLastError() is code # 4200 (Object exists already)
I have modified the code to assign a different name to each new arrow.
int start() { double LastHigh, datetime MyTime; string StrName; LastHigh = iHigh(NULL, PERIOD_D1, 1); if(Bid > LastHigh) { MyTime = iTime(NULL, PERIOD_H1, 1); StrName = StringConcatenate("UpArrow",TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS )); if(!ObjectCreate(StrName, OBJ_ARROW, 0, TimeCurrent(), LastHigh)) { Print("error: can't create label_object! code #",GetLastError()); return(0); } ObjectSet(StrName, OBJPROP_ARROWCODE, 241); ObjectSet(StrName, OBJPROP_COLOR, Green); } return(0); }
It works fine now. Thank you ! ! !
Hi!
You declare LastHigh in start function and it's erase in every tick. You should do this outside start function at the beginning of your code.
I tried declaring LastHigh outside the start function at the beginning of my code and it works just as fine as inside. Which way is better, I mean, in terms of code efficiency?
ok i miss understood your code logic logic
i don't know how exacely mql4 interpreter work so i don't know which code is more efficiency however in this type of language it is not so important but i think it's better to declare it inside
Thank you Fugi.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I need to draw an arrow in the chart. There are several other forums whit an answer to this, but i don't know what I am doing wrong, there are no arrows.
can someone help me please?
My code is: