Momen
Pine Script Rookie
Pine Script Rookie
Posts: 4
Joined: June 9th, 2021

Difference in values when using default function vs custom code

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

User avatar
Matthew
Site Admin
Site Admin
Posts: 92
Joined: July 1st, 2020
Location: Australia
Contact: Website Facebook Twitter TradingView Profile

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

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

Momen
Pine Script Rookie
Pine Script Rookie
Posts: 4
Joined: June 9th, 2021

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

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

Return to “Pine Script Q&A”