Why is the plot AHEAD of price?


0
0

I am trying to use the “tick speedometer” that you helped me with previously.

Here is the code. I am sure this is something obvious that I am overlooking. It looks like it is plotting AHEAD of price?! Can you help?

Thanks Lindsay

 

declare lower;
def barTime = GetTime() / 1000; # converts time to seconds
def seconds = barTime – barTime[1]; # number of seconds between bars

def alertPeriod = if seconds < Lowest(seconds[1], 11) then 1 else 0;
plot a = alertPeriod [1];
Alert(a[1], “climax bar!”, Alert.BAR, Sound.Chimes);

Attachments:
RESOLVED
Marked as spam
Posted by (Questions: 7, Answers: 11)
Asked on June 19, 2018 11:53 am
63 views
0

In order to answer this you are going to to have to explain exactly how that chart is constructed. The candles on this chart are not normal. Some are wider than others and they all have shading that is not easily explained. Is this an EquiVolume chart?

( at June 19, 2018 12:16 pm)
0

Equivolume 400 tick charts

( at June 19, 2018 1:14 pm)
0
Private answer

Ok, so I tested this on a tick chart to make sure it was not being caused by the EquiVolume. The same thing happens on tick charts so we know there is an issue and we can address it. The problem is that for any expansion bars (empty chart space to the right of the last bar), the value of the seconds variable is zero. Your alert is set to check if the current value of seconds is the lowest values in 11 bars. So obviously when seconds equals zero this is going to be true.

So we need to modify the seconds variable, to ensure it does not plot into the right expansion area of the chart. We do this using: !IsNaN(close).

Here is the corrected code (minus the excessive abbreviation you included in yours):

declare lower;
def barTime = GetTime() / 1000; # converts time to seconds
def seconds = if !IsNaN(close) then barTime – barTime[1] else Double.NaN; # number of seconds between bars
plot alertPeriod = seconds < Lowest(seconds[1], 11);
Alert(alertPeriod, “climax bar!”, Alert.BAR, Sound.Chimes);

 

Marked as spam
Posted by (Questions: 37, Answers: 4087)
Answered on June 19, 2018 1:43 pm