Attachments forums

List of attachments posted on this forum.


All files on forums: 135932

Re: Help to understand how to fix the array out of range

Luke, Mon Dec 04, 2023 11:53 pm

HI. I have made some changes since the last version. I created a class for the candlestick pattern.
I tried several times to create the function for calculating the body length starting from the ta.ema function:

Code: Select all

pine_ema(src, length) =>
   alpha = 2 / (length + 1)
   sum = 0.0
   sum := na(sum[1]) ? src : alpha * src + (1 - alpha) * nz(sum[1])

plot(pine_ema(close, 15))
What I understood for nz() can be used mathisvalidnumber. For na() it should match a check if the value is nan then you set it to 0.0.
I created some code that doesn't even work well. It's not a reproduction of the ema function because I'm not that good at programming and from what I see in the printouts, I don't really like how it works.
Image
Image
Can you help me understand or post a link to an indicator so I can study it by looking at how it was made?
I thank you infinitely
All files in topic