Placing pointers (arrows) on chart.

 

I wish to know can we put markers on history charts, because but to find the point by looking at numbers appears to be very difficult.


Can you please teach me how can I add pointers, up arrows and down arrows on charts, I want to place pointers there at run time.


I do not know if this could be done at the first place.



Thanks.

 
It can be done using an indicator index - DRAW_ARROW - or by using ObjectCreate() to create an OBJ_ARROW
 
phy:
It can be done using an indicator index - DRAW_ARROW - or by using ObjectCreate() to create an OBJ_ARROW

Phy,

Thanks,

But I have trouble getting it on screen, will it appear on the live screen?


I only have one chart opened, I put the following in my code.


ObjectCreate("Arrow1", OBJ_ARROW, 0, TimeToStr(Time[0],TIME_DATE|TIME_SECONDS), Bid);


How can I get the date and time real time value so that I can put it to for a part of the coordinate.


Also, my code will later litter arrows as it goes along the time domain, thus I have to name each arrow with unique name, thus how do I form a syntax in a way that "Arrow" but the number beside runs via a incremental counter, I hope you understand my concern.


Thanks.

 

ObjectCreate("Arrow1"+Bars, OBJ_ARROW, 0, Time[0], Bid);

That's one way.

 
phy:

That's one way.


Thanks,

ObjectCreate("Arrow1"+Bars, OBJ_ARROW, 0, Time[0], Bid);


I got no error and I do not see the arrow on chart, got I got to setup any thing to the chart?

I think the code is not connecting to the chart because, i did some lines manually on the chart, prior to running the codes, then in the code I have


ObjectsDeleteAll();


but the lines which I drew did not go away!

thus I think I am not connecting to chart,


if there are prerequisite, please let me know, thanks.

 

Post your code

 
datetime BarTime=0;
//-----
int StartBarCounter=1;
extern int BarsToWaitBeforeStart=10;
//-----
extern double TakeProfit=50;

int init()
{
Print("--------------------------------------------------------------------------------------------START---");
Print("----------------------------------------------------------------------------------------------------");
ObjectsDeleteAll();
return(0);
}

int deinit()
{
Print("----------------------------------------------------------------------------------------------------");
Print("----------------------------------------------------------------------------------------------END---");
return(0);
}

int start()
{
if(IsTradeAllowed()==false)
{
Print("Trading Turned OFF");
}
else
{
if(Bars<100)
{
Print("Bars < 100");
}
else
{
if(TakeProfit<10)
{
Print("TakeProfit < 10");
}
else
{
//If new tick comes in for same Bar, it will not taken into consideration
if(Time[0]>BarTime)
{
BarTime = Time[0]; //Present Bar's Time Recorded
StartBarCounter=StartBarCounter+1; //BarsToWairBeforeStart Counter
if (StartBarCounter>BarsToWaitBeforeStart)
{
StartBarCounter=BarsToWaitBeforeStart; //To Prevent Overflow
Print(TimeToStr(Time[0],TIME_DATE|TIME_SECONDS));
ObjectCreate("Arrow"+StartBarCounter, OBJ_TEXT, 0, Time[0], Close[1]);
}
}
}
}
}
return(0);
}
 
Fire wrote >>
datetime BarTime=0;
//-----
int StartBarCounter=1;
extern int BarsToWaitBeforeStart=10;
//-----
extern double TakeProfit=50;

int init()
{
Print("--------------------------------------------------------------------------------------------START---");
Print("----------------------------------------------------------------------------------------------------");
ObjectsDeleteAll();
return(0);
}

int deinit()
{
Print("----------------------------------------------------------------------------------------------------");
Print("----------------------------------------------------------------------------------------------END---");
return(0);
}

int start()
{
if(IsTradeAllowed()==false)
{
Print("Trading Turned OFF");
}
else
{
if(Bars<100)
{
Print("Bars < 100");
}
else
{
if(TakeProfit<10)
{
Print("TakeProfit < 10");
}
else
{
//If new tick comes in for same Bar, it will not taken into consideration
if(Time[0]>BarTime)
{
BarTime = Time[0]; //Present Bar's Time Recorded
StartBarCounter=StartBarCounter+1; //BarsToWairBeforeStart Counter
if (StartBarCounter>BarsToWaitBeforeStart)
{
StartBarCounter=BarsToWaitBeforeStart; //To Prevent Overflow
Print(TimeToStr(Time[0],TIME_DATE|TIME_SECONDS));
ObjectCreate("Arrow"+StartBarCounter, OBJ_TEXT, 0, Time[0], Close[1]);
}
}
}
}
}
return(0);
}

Can any one please help me, I tried all sorts, but still stuck.

 
Fire wrote >>

I fixed it already but, I want to advance or puch back the arrow thus I have to play with the Time[0+1], but the arrow is not moving, can any one help

 

If you want to change the location of an existing object see ObjectSet() and set the new time coordinate.

Or create it where you want it in the first place.

Reason: