string PlaceArrow(int intArrowType,string strArrowName,double dblArrowPoint) { int intArrowCode=0; color colArrowColour=""; ObjectsDeleteAll(0,OBJ_ARROW_DOWN); ObjectsDeleteAll(0,OBJ_ARROW_UP); switch(intArrowType) { case 1: ObjectCreate(0,strArrowName,OBJ_ARROW_DOWN,0,Time[0],dblArrowPoint); // Create the Doji Type object colArrowColour="clrRed"; intArrowCode=234; break; case 2: ObjectCreate(0,strArrowName,OBJ_ARROW_UP,0,Time[0],dblArrowPoint); // Create the Doji Type object colArrowColour="clrBlue"; intArrowCode=233; break; } ObjectSetInteger(0,strArrowName,OBJPROP_COLOR,colArrowColour); ObjectSetInteger(0,strArrowName,OBJPROP_ANCHOR,ANCHOR_TOP); ObjectSetInteger(0,strArrowName,OBJPROP_ARROWCODE,intArrowCode); ObjectSetInteger(0,strArrowName,OBJPROP_STYLE,STYLE_SOLID); ObjectSetInteger(0,strArrowName,OBJPROP_WIDTH,1); ObjectSetInteger(0,strArrowName,OBJPROP_BACK,True); //--- return the value return(0);
You are creating your arrows, then changing the object arrowcode
You can make a quick fix by making this change
ObjectsDeleteAll(0,OBJ_ARROW_DOWN); ObjectsDeleteAll(0,OBJ_ARROW_UP); //Change to ObjectsDeleteAll(0,OBJ_ARROW);
But you should really tidy up your code so that it is consistent.
If I may make a suggestion
Create your objects in init
Move your objects in the main program
Delete objects in deinit, preferably without using ObjectsDeleteAll
I also note that your function is declared as a string, yet returns(0)
Please do not delete all arrows of any type. Use code that selects only the arrows your indi draws. This avoids confusion and blame when another person's indi deletes items it did not create and user thinks it's your indi that is the cause. Thank you ! :)
for(int i=ObjectsTotal()-1;i>=0;i--) if(StringFind(ObjectName(i),strArrowName,0)>=0) ObjectDelete(ObjectName(i));
Thanks for all your suggestions - it really is appreciated. I did not post the whole code because it runs to over 500 lines. Its only my first full length EA so I've still got a lot to learn and your suggestions will be a big help.
Thanks again

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi Everyone,
I've got a problem that I've been struggling with for two days without success so I hope someone can tell me where I'm going wrong. The below code is part of an EA that places three MAs on the chart. The code below looks at each MA and places an up arrow if the MA is going up and a down arrow if the MA is going down. It works absolutely perfectly, so what is the problem?
It works perfectly if I stay on one time frame only but I want it to do the same as I change time frames. As I change time frames it puts in the new arrows but does not delete the arrows from the previous time frame. In the end it ends up with 6 arrows, three up and three down and nothing I've tried to do will delete them. You'll see from the code that ObjectsDeleteAll(0,OBJ_ARROW_DOWN); ObjectsDeleteAll(0,OBJ_ARROW_UP); are in there and they must be deleting the arrows when I'm on PERIOD_D1 because only the correct arrows appear but when I swap time frames the command stops working. Anyway any advice would be greatly appreciated. Here is the code: