Label displays N/A


Category:
0
0

Hi Pete, how are you, how is your recovery? hey I need a little help i’m trying to write a study but the label displays N/A can you help me please, thanks

PS I am not a programmer sorry for the code.

def spike = ( close[1] * 130) / 100;
def bull = if volume > 100000 and close > open and high > spike then 1 else 0;
def up = TotalSum(bull);
def day2 = if bull and close > close [-1] then 1 else 0;
plot nextday = TotalSum(day2);

AddLabel(yes, “NEXT ” + nextday, Color.LIGHT_GRAY);

Attachments:
Marked as spam
Posted by (Questions: 8, Answers: 23)
Asked on July 5, 2019 5:36 am
120 views
0
Private answer

If you plot this on a lower study it becomes clear. The plot does not continue through to the last bar on the chart. It stops at the previous bar. The label always displays the value for the last bar on the chart. Your code is reading into the future:

def day2 = if bull and close > close [-1] then 1 else 0;

You may be able to correct this by changing that line to:

def day2 = bull[1] and close[1] > close;

However I have not really taken the time to understand what your code is trying to accomplish. Perhaps if you had explained what you were trying to accomplish I would have enough details to provide a better solution.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on July 5, 2019 12:13 pm
0
ok lets see what I want to do is count how many times the stock spike over 30% from the previous close and count them or add them together the first 3 lines of code do that for me no problem, now I want to count the next day of those spikes, how many close below the close of the day of the spike I hope it make sense, thank for your time Pete.
( at July 5, 2019 1:01 pm)
0
Thanks Pete I checked the code it worked perfect thank you so much!!!
( at July 5, 2019 2:10 pm)