Page 1 of 1

Difference in values when using default function vs custom code

Posted: Wed Jun 09, 2021 10:04 am
by Momen
I am working on a strategy based on Ichimoku cloud.
When I perform the calculations of various ichimoku components (like baseline, conversionLine, etc) within my script and plot it on the chart and compare it with the built-in Ichimoku cloud there is a difference between all values.
Although I am using the same code (copied it from Ichimoku built-in function). Attached is a screenshot highlighting the difference.
Can somebody help on this?

Image

Re: Difference in values when using default function vs custom code

Posted: Wed Jun 09, 2021 10:34 am
by Matthew
Hi Momen, if you could post your Ichimoku code on here that would make it a lot easier to help as it's really hard to know what's happening without seeing what your code is doing :) I've had similar issues before and I can't remember what I did to fix it

Re: Difference in values when using default function vs custom code

Posted: Wed Jun 09, 2021 3:55 pm
by Momen
Hi Matthew,

I figured it out. I was passing "close" instead of "low" & "high" to "lowest" & "highest" functions respectively:

baseLine = avg(lowest(low, basePeriods), highest(high, basePeriods))

Do you have an example of custom coding a screener in TV? I am struggling with it, perhaps, your course will surely make me a better Pine coder.

Thanks

Momen