Login Page - Create Account

Support Board


Date/Time: Wed, 27 Nov 2024 08:53:06 +0000



Post From: Could you please add the Half Trend indicator?

[2021-08-17 12:07:28]
SC Support Tom - Posts: 450
I am almost finished with this, but I have a question about how Tradingview operates. Specifically, my question pertains to the following part of the Pine Script code.


if nextTrend == 1
  maxLowPrice := max(lowPrice, maxLowPrice)

  if highma < maxLowPrice and close < nz(low[1], low)
    trend := 1
    nextTrend := 0
    minHighPrice := highPrice

In the event that nextTrend == 1, but the condition highma < maxLowPrice and close < nz(low[1], low) is false, the value of minHighPrice is not explicitly updated. What does Tradingview do in that circumstance? My guess is that it retains the previous value of the variable, but since Pine Script has no equivalent of "sc.Index" in its code, I cannot know for sure. If you do not know the answer, then I will update the value as minHighPrice[sc.Index] = minHighPrice[sc.Index - 1] under the above stated conditions.