dots on the chart

 

Help with dots on the chart

I am trying to place dots on the charts whenever there is condition.

eg

if close[0] > High[1]

{

ObjectSet("ArrowB",OBJPROP_COLOR, Green);
ObjectSet("ArrowB", OBJPROP_ARROWCODE, 159);
ObjectSet("ArrowB", OBJPROP_TIME1, Time[0]);
ObjectCreate ("ArrowB",OBJ_ARROW,0,TimeCurrent(),0,Bid);

}

the issue is the dot is keep on moving, can somebody please help to create dot on every bar. The picture attached is from mql3.

Thanks,
AJ

 
I'm curious why you set object parameters before creating it? It's like watching a program on TV before turning it on. :)

Objects are referred by their names. Hence if you need multiple objects give them unique names.
Either time stamp or shared counter would do.
if (close[1] > High[2])
{
    string name = StringConcatenate("ArrowB ", TimeToStr(Time[1]));
    
    if (ObjectCreate(name, OBJ_ARROW, 0, Time[1], High[1]) // returns false if object exists already.
    {
        // set the properties if ObjectCreate() succeeds and a new arrow is placed on the chart.
        ObjectSet(name, OBJPROP_COLOR, Green);
        ObjectSet(name, OBJPROP_ARROWCODE, 159);
    }
}
 

Hi Irtron,

Thanks for your code, it works. .. I apprecaite for your help. I thought first you set the value and then create it. Create would create a dot. looks it other way around.

Regards,

AJ

Reason: