The following code will work:
Code: Select all
////-------
variables:
ema1(0), diff(0);
if currentbar = 0 then ema1 = close;
ema1 = xaverage(close, 8);
diff = ema1 - low;
if barstatus(1) = 2 then
begin
value1 = arw_new(date,time,low,false);
arw_settext(value1,"d:"&" "&text(diff:0:4));
end;
////------------------
If you take a look at the help you will see why there are multiple arrows on the single bar:
Usage
Arw_New (BarDate, BarTime, PriceValue, Direction)
Parameters
BarDate - a numerical expression specifying the date of the bar at which the object is to be placed; the date is indicated in the YYYMMdd format, where YYY is the number of years since 1900, MM is the month, and dd is the day of the month
BarTime - a numerical expression specifying the time of the bar at which the object is to be placed; the time is indicated in the 24-hour HHmm format, where 1300 = 1:00 PM
PriceValue - a numerical expression specifying the price value (vertical position, corresponding to a value on the price scale of a chart), where the object is to be placed
Direction - a logical expression specifying the direction of the arrow; True = Down and False = Up
-----------------
Time coordinates will be accurate within minutes.
According to the picture the neighboring bars have the same time.
There is another function that specifies time with second precision:
Arw_New_s (BarDate, BarTime_s, PriceValue, Direction)
BarTime_s - a numerical expression specifying the time of the bar, including seconds, at which the object is to be placed; the time is indicated in the 24-hour HHmmss format, where 130000 = 1:00:00 PM
Please try this way:
value1 = arw_new_s(date, time_s, low, false);